Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CP-50079: Parse cookies correctly #5821

Merged

Conversation

last-genius
Copy link
Contributor

Best reviewed by commit.

Currently we send and parse cookies incorrectly (internally, therefore it wasn't a big problem) with & as separators. This PR also accepts ; as separators (to be RFC-compliant), in preparation for sending cookies with ; in the future. Currently this change is limited to servers (accepting cookies), as old servers could interact with new clients sending newly-formatted cookies during upgrades, thus breaking them. We should wait until all servers we support upgrades from are new and then update the clients too. (We should really get a centralised place to track such long-term deprecation-like things.)

Removes legacy sync_config_files interface - please advise as to what's the best way to proceed here is. Should we warn that said endpoint is deprecated, only support /2 (what my PR does at the moment)? Should we respond with new data to legacy requests instead?

Expanded quicktests to verify correct parsing of cookies. Had to add new helper functions since sync_config_files requests from unix file sockets are always authenticated - we need to send a real one to check. Qt.http is not a good fit here since it eventually calls into our library which always sets the body = None, and we need to verify the body itself.

Also adds -run-only X,Y,Z and -list-tests parameters to quicktests (currently they are not 'quick' at all).

== These changes passed the quicktests, currently also running full BST+BVT.

@last-genius
Copy link
Contributor Author

Passed BST+BVT (Run 201239)

@last-genius last-genius force-pushed the private/asultanov/cookies-handling branch from f995928 to 16a5a35 Compare July 15, 2024 11:31
Copy link
Contributor

@lindig lindig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not introduce List.hd; not sure if it would be a good idea but the code could accept both delimiters - even mixed use and restricted later.

(* Determine if ';' or '&' is used as the separator.
Both are assumed to be illegal characters otherwise *)
let sep =
match Astring.String.find (fun c -> c = ';') xs with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means we don't support a mix of ; and &. You could have used Astring.String.fields ~is_sep:(fun c -> c = ';' || c = '&')

Copy link
Contributor Author

@last-genius last-genius Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a reasonable use case? Could do it if people think it's something worth supporting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think this is a bit weird but it's a simple solution because you don't have to detect the delimiter but rather accept both. Later we we restrict this by accepting only one and failing we we detect the other.

ocaml/quicktest/quicktest_http.ml Outdated Show resolved Hide resolved
ocaml/quicktest/quicktest_http.ml Outdated Show resolved Hide resolved
quality-gate.sh Outdated Show resolved Hide resolved
@last-genius last-genius force-pushed the private/asultanov/cookies-handling branch from 16a5a35 to b3f4b91 Compare July 16, 2024 07:53
@last-genius
Copy link
Contributor Author

Got rid of List.hd and simplified req_with_cookies

The suites are ordered and some take quite a long time to run, so
introduce an option to only run some of them if necessary.

Signed-off-by: Andrii Sultanov <andrii.sultanov@cloud.com>
We used to send and parse cookies (internally, therefore it
wasn't a big problem) with '&' as separators. Now we also
accept ';' as separators (RFC-compliant), as preparation
for sending cookies with ';' in the future.

Signed-off-by: Andrii Sultanov <andrii.sultanov@cloud.com>
Test helper functions had to be reworked to also allow sending HTTP
requests through normal sockets, not only file sockets.

A test was moved from the legacy endpoint to the new one.

Signed-off-by: Andrii Sultanov <andrii.sultanov@cloud.com>
Signed-off-by: Andrii Sultanov <andrii.sultanov@cloud.com>
Signed-off-by: Andrii Sultanov <andrii.sultanov@cloud.com>
@last-genius last-genius force-pushed the private/asultanov/cookies-handling branch from 41c66fa to 45cdd70 Compare July 16, 2024 09:07
@last-genius
Copy link
Contributor Author

Squashed the fixes. Ready for merging.

@lindig lindig merged commit a0464a7 into xapi-project:master Jul 16, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants