Skip to content

Refactor query parameter redaction#19218

Merged
zanieb merged 2 commits intomainfrom
zb/refactor-query-redaction
Apr 30, 2026
Merged

Refactor query parameter redaction#19218
zanieb merged 2 commits intomainfrom
zb/refactor-query-redaction

Conversation

@zanieb
Copy link
Copy Markdown
Member

@zanieb zanieb commented Apr 29, 2026

Small follow-up to #19146 which I was looking into independently as a follow-up from the Codex security patch at zaniebot#19

@zanieb zanieb added the internal A refactor or improvement that is not user-facing label Apr 29, 2026
@zanieb zanieb force-pushed the zb/refactor-query-redaction branch from d0fe280 to 3ad4c47 Compare April 29, 2026 19:18
@zanieb zanieb marked this pull request as ready for review April 29, 2026 19:18
@zanieb zanieb requested review from woodruffw and zsol April 29, 2026 19:19
@zanieb
Copy link
Copy Markdown
Member Author

zanieb commented Apr 29, 2026

   Snapshot: unsupported_git_scheme
    Source: crates/uv/tests/it/sync.rs:12039
    ────────────────────────────────────────────────────────────────────────────────
    Expression: snapshot
    ────────────────────────────────────────────────────────────────────────────────
    -old snapshot
    +new results
    ────────────┬───────────────────────────────────────────────────────────────────
        6     6 │ Using CPython 3.12.[X] interpreter at: [PYTHON-3.12]
        7     7 │ Creating virtual environment at: .venv
        8     8 │   × Failed to build `foo @ file://[TEMP_DIR]/`
        9     9 │   ├─▶ Failed to parse entry: `foo`
       10       │-  ╰─▶ Unsupported Git URL scheme `c:` in `c:/home/ferris/projects/foo` (expected one of `https:`, `ssh:`, or `file:`)
             10 │+  ╰─▶ Unsupported Git URL scheme `c:` in `c:///home/ferris/projects/foo` (expected one of `https:`, `ssh:`, or `file:`)
    ────────────┴───────────────────────────────────────────────────────────────────
    To update snapshots run `cargo insta review`
    Stopped on the first failure. Run `cargo insta test` to run all snapshots.
    test sync::unsupported_git_scheme ... FAILED

That's annoying. Will look into that.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 29, 2026

Merging this PR will not alter performance

✅ 5 untouched benchmarks


Comparing zb/refactor-query-redaction (fa72e7c) with main (530790e)

Open in CodSpeed

write!(f, "{}:", url.scheme())?;

write!(f, "{}://", url.scheme())?;
if url.has_authority() {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This "has authority" case was the fix for a regressed snapshot where an invalid c:\... target was displayed.

Comment on lines +581 to +582
let log_safe_url =
DisplaySafeUrl::parse("mailto:ferris@example.com?X-Amz-Signature=signature").unwrap();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Alas this is a valid URL so here we are adding test coverage for some weird stuff.

Comment on lines -346 to -352
let url = url_with_redacted_sensitive_query_values(url);
let url = url.as_ref();
// For URLs that use the `git` convention (i.e., `ssh://git@github.com/...`), avoid dropping the
// username.
if is_ssh_git_username(url) || (url.username().is_empty() && url.password().is_none()) {
return write!(f, "{url}");
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I didn't like this early return pattern. I think we should just own the formatting entirely in this type.

Copy link
Copy Markdown
Member

@zsol zsol left a comment

Choose a reason for hiding this comment

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

Seems fine. I personally liked the early return better, but not enough to fight you :)

@zanieb
Copy link
Copy Markdown
Member Author

zanieb commented Apr 30, 2026

I think it was fine until we had to eagerly transform the entire URL to redact query parameters for the earl return.

@zanieb zanieb merged commit 3a43470 into main Apr 30, 2026
112 checks passed
@zanieb zanieb deleted the zb/refactor-query-redaction branch April 30, 2026 15:38
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