Repository navigation
Conversation
695d01a to
be603e3
Compare
uv test inventory changesThis PR changes the tests when compared with the
|
be603e3 to
405882c
Compare
405882c to
95f6e01
Compare
95f6e01 to
0644502
Compare
0644502 to
f0d4b5b
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f0d4b5b385
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Url::parse(url) | ||
| .map(DisplaySafeUrl::from_url) |
There was a problem hiding this comment.
Preserve credential ambiguity checks for persisted URLs
When an existing direct_url.json contains ambiguous userinfo such as https://user/name:password@domain/a, Url::parse interprets user as the host and leaves name:password@domain in the path. Wrapping that result with DisplaySafeUrl::from_url bypasses the credential check, so commands such as uv pip freeze subsequently print the apparent password unredacted from dist.url. Before this change, DisplaySafeUrl::parse rejected the same metadata and treated the distribution as registry-installed; retain that protection or explicitly sanitize credential-like path and fragment content before accepting persisted URLs.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This is a deliberate tradeoff. We apply ambiguity checks to human input, but use ordinary URL parsing for persisted metadata so valid paths containing : and @ are accepted. Credential-like text in those paths can therefore appear literally in output.
| Self::VcsUrl { | ||
| url: value.url.url().to_string(), | ||
| url: value.url.url().clone().into(), |
There was a problem hiding this comment.
Retain the Git username after stripping the VCS prefix
For an input such as git+https://[email protected]/repo.git, GitUrl has already removed the git+ prefix, so the value wrapped here has the scheme https, not git+https. PersistSafeUrl::serialize therefore does not recognize it as a Git URL and strips the passwordless git username, causing both direct_url.json and a later uv pip freeze to omit a username that the new persistence type explicitly promises to retain and that authenticated HTTPS Git servers may require. Preserve the VCS context when serializing or recognize the underlying HTTPS Git URL in this conversion.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This is pre-existing. Before this PR, the same conversion wrote https://****@example.com/repo.git. The new code writes https://example.com/repo.git, so neither version preserves the git username.
f0d4b5b to
88db503
Compare
| /// Direct URL metadata whose URL has not yet been parsed. | ||
| #[derive(Deserialize)] | ||
| #[serde(transparent)] | ||
| // hide the `Serialize` and `Debug` implementations to avoid accidentally leaking credentials |
There was a problem hiding this comment.
How are they "hidden"? what is this commenting on?
There was a problem hiding this comment.
Codex says this just means we don't impl them here, I guess I'd put this kind of commentary in the doc comment explaining what invariants this type provides?
There was a problem hiding this comment.
They're hidden in the sense that they're not implemented on DirectUrlMetadata, as opposed to above.
Hmm Codex originally put this in the doc comment when I asked it to capture why this is a struct wrapper instead of a "newtype" like ParsedDirectUrl, but I thought this was more implementation detail, and a user of the type shouldn't care
There was a problem hiding this comment.
"hidden" implies a more complex operation than "This type does not implement [Serialize] and cannot be serialized"
88db503 to
2efe898
Compare
| dir_info: _, | ||
| } => { | ||
| let mut url = Self::parse(url)?; | ||
| let mut url = url.as_url().clone(); |
There was a problem hiding this comment.
Self::parse would call Self::reject_ambiguous_credentials and we're not doing that anymore, I believe that's unintended?
(it rejects e.g. https://user/name:password@domain/project)
There was a problem hiding this comment.
I see, you replied to a bot comment saying this is intentional...
There was a problem hiding this comment.
Yes - let me know if you disagree with this though! You're more likely to change my mind than the clanker
Merging this PR will regress 1 benchmark
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ |
Simulation | discover_workspace_from_all_members_with_excludes |
140.1 ms | 150.9 ms | -7.12% |
| ⚡ |
Simulation | discover_workspace_from_all_members |
156 ms | 133.8 ms | +16.58% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing zsol/url-persistence-01-safe (2efe898) with main (9385290)
Footnotes
-
54 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
|
I think the problem was introduced/precedent was set in #21971 that we want to pass through query parameters etc. But the spec says we should not be persisting sensitive information in these files. So I think we should be stripping rather than leaving things un-redacted. And then figuring out if we can work with that. Also, worth noting that |
`SafeUrl` currently serializes the full URL, so fields can persist credentials without an explicit choice. Add a type-level policy that defaults to `Unserializable`; `Stripped` removes sensitive userinfo while retaining the complete query, and `Raw` serializes the full parsed URL. `Display` and `Debug` continue to redact passwords and recognized sensitive query parameters. Index URLs in `pylock.toml` and publish URLs in tool receipts use `Stripped`. The inherent `serialize` and `serialize_internal` methods prevent those method calls from falling through `Deref` to `Url`. Ordinary Serde serialization of `SafeUrl` requires `Stripped` or `Raw`; the internal serialization method requires `Raw`. The serialization policies are an alternative to the wrapper types in #22356, #22357, and #22358, combined in astral-sh#2712 for comparison. `Stripped` and `Raw` follow the same serialization rules as `PersistSafeUrl` and `CredentialPersistingUrl`. Using `SafeUrl<P>` carries the policy through `VerbatimUrl`, stored fields, and transformations such as `join`; shared implementations are generic over the policy. The aforementioned stack also changes how `DirectUrl` metadata is parsed and written; those changes are outside this PR's scope. See also #22600 (comment) Stacked on #22599. Co-authored-by: zaniebot <[email protected]>
direct_url.jsonrecords the origin of an installed distribution. Git URLs currently pass through display redaction when the metadata is constructed, which can redact query parameters needed to identify or access the source.Add
PersistSafeUrlto retain the parsed URL in memory and remove sensitive userinfo when serializing. Use it for direct URL metadata and index URLs. Serialization preserves the complete query string and retains a passwordlessgitusername forssh,git+ssh, andgit+httpsURLs.Parse persisted URLs without the ambiguity checks intended for human input, including when comparing installed sources against requirements. If a
direct_url.jsonURL cannot be parsed, fall back to registry metadata; malformed metadata still produces an error.