fix: Fix http PathAndQuery Uri Parsing#2122
Conversation
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: fdc623d | Docs | Datadog PR Page | Give us feedback! |
📚 Documentation Check Results📦
|
Clippy Allow Annotation ReportComparing clippy allow annotations between branches:
Summary by Rule
Annotation Counts by File
Annotation Stats by Crate
About This ReportThis report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 79271436c9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
🔒 Cargo Deny Results📦
|
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
`http` version 1.4.1 became stricter in `PathAndQuery` input parsing to reject all inputs that do not start with `/`, including empty inputs. Previously, this library passed in an empty input in multiple places when constructing a `PathAndQuery`. Users are not able to upgrade `http` past 1.4.0 without this library breaking. This commit fixes the issue by replacing the empty inputs with `"/"`.
7927143 to
fdc623d
Compare
| .scheme("windows") | ||
| .authority(path) | ||
| .path_and_query("") | ||
| .path_and_query("/") |
There was a problem hiding this comment.
is this correct for windows?
There was a problem hiding this comment.
I think so. If you look at the code, it's explicitly expecting the first byte to be b'/', and I don't see any cfg flags based on OS.
https://docs.rs/http/latest/src/http/uri/path.rs.html#427-429
Here's the full path of path_and_query():
path_and_query()calls intoPathAndQuery::try_into: https://docs.rs/http/latest/src/http/uri/builder.rs.html#93-103TryFrom<&str>calls intoTryFrom<&[u8]>: https://docs.rs/http/latest/src/http/uri/builder.rs.html#93-103TryFrom<&[u8]>calls intoPathAndQuery::from_shared: https://docs.rs/http/latest/src/http/uri/path.rs.html#223-229from_sharedcallsscan_path_and_query: https://docs.rs/http/latest/src/http/uri/path.rs.html#21-39scan_path_and_queryreturns an error if the bytes are empty: https://docs.rs/http/latest/src/http/uri/path.rs.html#415-417scan_path_and_queryreturns an error if the first byte isn't one of/,?,#: https://docs.rs/http/latest/src/http/uri/path.rs.html#427-429
I see that there's two tests at the bottom of this file that call this function, are they run on Windows? If so, is that sufficient to gain confidence that it's correct on Windows? If not, is there any additional test we can add?
I'm not super familiar with this code base or with windows so it's hard for me to say with a high level of certainty if it's correct or not.
morrisonlevi
left a comment
There was a problem hiding this comment.
Have you manually tested unix domain sockets at all? I think that this probably is fine but it's one of those things I think is worth testing end-to-end. If you want help, I can show you how to do this for dd-trace-php.
@morrisonlevi I have not manually tested it, and yes I would appreciate if you could show me how. I have not done any manual testing and have been leaning on CI fully for validation. |
@morrisonlevi bump, how can I test the unix domain sockets end-to-end? |
What does this PR do?
httpversion 1.4.1 became stricter inPathAndQueryinput parsing to reject all inputs that do not start with/, including empty inputs. Previously, this library passed in an empty input in multiple places when constructing aPathAndQuery. Users are not able to upgradehttppast 1.4.0 without this library breaking. This commit fixes the issue by replacing the empty inputs with"/".Motivation
Fix this library for
httpversions >= 1.4.1.Additional Notes
See https://dd.slack.com/archives/C05M4JAM5BJ/p1781552060779329?thread_ts=1781534034.370109&cid=C05M4JAM5BJ
How to test the change?
Existing unit tests should be sufficient, assuming the modified functions have coverage.