Skip to content

Make credential-preserving URL serialization explicit - #22357

Closed
zsol wants to merge 1 commit into
zsol/url-persistence-01-safefrom
zsol/url-persistence-02-credentials
Closed

zsol wants to merge 1 commit into
zsol/url-persistence-01-safefrom
zsol/url-persistence-02-credentials

Conversation

@zsol

@zsol zsol commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Some URL fields need to retain credentials when serialized, while their display and debug output should still redact them. DisplaySafeUrl currently provides both behaviors through its generic serialization implementation.

Add CredentialPersistingUrl for these fields. It serializes the complete parsed URL, including userinfo and query parameters, while retaining DisplaySafeUrl redaction for display and debug output. It deserializes URL strings without the ambiguity checks intended for human input.

Use the wrapper for authentication services, proxy URLs, OSV references, direct requirement sources, pyproject.toml sources, and pylock.toml URLs. That should result in this PR not changing uv's behavior.

Adapted from #21973. Stacked on #22356.

@zsol
zsol force-pushed the zsol/url-persistence-01-safe branch from 695d01a to be603e3 Compare October 8, 2026 11:04
@zsol
zsol force-pushed the zsol/url-persistence-02-credentials branch from 4a67650 to 210cf5c Compare October 8, 2026 11:04
@zsol
zsol force-pushed the zsol/url-persistence-02-credentials branch from 210cf5c to 787a7d8 Compare October 9, 2026 15:46
@zsol
zsol force-pushed the zsol/url-persistence-01-safe branch from be603e3 to 405882c Compare October 9, 2026 15:46
@zsol
zsol added this pull request to stack #22393 October 9, 2026 15:50
@zsol
zsol force-pushed the zsol/url-persistence-01-safe branch from 405882c to 95f6e01 Compare October 12, 2026 11:50
@zsol
zsol force-pushed the zsol/url-persistence-02-credentials branch from 787a7d8 to 8fb2e72 Compare October 12, 2026 11:50
@zsol
zsol force-pushed the zsol/url-persistence-01-safe branch from 95f6e01 to 0644502 Compare October 12, 2026 12:02
@zsol
zsol force-pushed the zsol/url-persistence-02-credentials branch from 8fb2e72 to 43c35c6 Compare October 12, 2026 12:02
@zsol
zsol force-pushed the zsol/url-persistence-01-safe branch from 0644502 to f0d4b5b Compare October 13, 2026 09:23
@zsol
zsol force-pushed the zsol/url-persistence-02-credentials branch from 43c35c6 to 5c6644b Compare October 13, 2026 09:23
@zsol zsol added the internal A refactor or improvement that is not user-facing label Oct 13, 2026
@zsol
zsol force-pushed the zsol/url-persistence-02-credentials branch from 5c6644b to 0cdd712 Compare October 13, 2026 10:35
@zsol
zsol marked this pull request as ready for review October 13, 2026 10:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T10:31:37.942032Z a6dd1b4 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@zsol
zsol force-pushed the zsol/url-persistence-02-credentials branch from da4ecd7 to a6dd1b4 Compare October 15, 2026 10:28
@zsol
zsol force-pushed the zsol/url-persistence-01-safe branch from 88db503 to 2efe898 Compare October 15, 2026 10:28
@codspeed

codspeed Bot commented Oct 15, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 0.09%

⚠️ 8 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

⚡ 3 improved benchmarks
❌ 3 regressed benchmarks
✅ 48 untouched benchmarks
🆕 15 new benchmarks
⏩ 54 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ ⚠️ Simulation discover_workspace_from_all_members 131 ms 156 ms -16.02%
❌ ⚠️ Simulation discover_workspace_from_all_members_with_excludes 139.5 ms 162.3 ms -14.05%
❌ ⚠️ Simulation run_python_version_synthetic_workspace 540.6 ms 572.8 ms -5.61%
⚡ Simulation load_python_download_catalog 455.5 ms 348.7 ms +30.6%
⚡ Simulation pypi_json[32] 300.6 µs 282.8 µs +6.31%
⚡ Simulation pypi_json[4096] 35.9 ms 34.1 ms +5.17%
🆕 WallTime git_fetch_cold_precise[django] N/A 5.3 s N/A
🆕 WallTime git_fetch_cold_precise[flask] N/A 279.6 ms N/A
🆕 WallTime git_fetch_cold_precise[sampleproject] N/A 36.3 ms N/A
🆕 WallTime git_fetch_revision_history[django/1] N/A 5.3 s N/A
🆕 WallTime git_fetch_revision_history[django/10] N/A 7.5 s N/A
🆕 WallTime git_fetch_revision_history[django/4] N/A 6.1 s N/A
🆕 WallTime git_fetch_warm_commit[django] N/A 2.6 ms N/A
🆕 WallTime git_fetch_warm_commit[flask] N/A 2.6 ms N/A
🆕 WallTime git_fetch_warm_commit[sampleproject] N/A 2.6 ms N/A
🆕 WallTime git_fetch_warm_precise[django] N/A 2.6 ms N/A
🆕 WallTime git_fetch_warm_precise[flask] N/A 2.6 ms N/A
🆕 WallTime git_fetch_warm_precise[sampleproject] N/A 2.5 ms N/A
🆕 WallTime git_fetch_warm_reference[django] N/A 8.1 ms N/A
🆕 WallTime git_fetch_warm_reference[flask] N/A 8.2 ms N/A
... ... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

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-02-credentials (a6dd1b4) with zsol/url-persistence-01-safe (88db503)2

Open in CodSpeed

Footnotes

  1. 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. ↩

  2. No successful run was found on zsol/url-persistence-01-safe (2efe898) during the generation of this report, so 95b6e63 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

assert_snapshot!(serde_json::to_string(&url)?, @r#""https://user:[email protected]/files/project:build@nightly?sig=abc%2Bdef%3D&other=a+b""#);
assert_eq!(url.as_url().as_str(), input);
assert_eq!(url.to_string(), url.as_url().to_string());
assert_eq!(format!("{url:?}"), format!("{:?}", url.as_url()));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This test only checks equally, but not whether the values are redacted, we should snapshot the redacted form here instead

zanieb pushed a commit that referenced this pull request Oct 16, 2026
`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]>
@zsol
zsol removed this pull request from stack #22393 October 16, 2026 15:25
@zsol zsol closed this Oct 16, 2026

This branch was previously deployed

1 inactive deployment
automations — a6dd1b41 Deployed Oct 15, 2026 by zsol via review / security review #51081
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user-facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants