Skip to content

Commit

Permalink
Redact Git credentials in lockfile (#6070)
Browse files Browse the repository at this point in the history
## Summary

Closes #6055.
  • Loading branch information
charliermarsh authored Aug 13, 2024
1 parent 1bbb05d commit 9226310
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions crates/uv-resolver/src/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,10 @@ impl From<GitSourceKind> for GitReference {
fn locked_git_url(git_dist: &GitSourceDist) -> Url {
let mut url = git_dist.git.repository().clone();

// Redact the credentials.
let _ = url.set_username("");
let _ = url.set_password(None);

// Clear out any existing state.
url.set_fragment(None);
url.set_query(None);
Expand Down
4 changes: 2 additions & 2 deletions crates/uv/tests/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5312,7 +5312,7 @@ fn lock_redact_git() -> Result<()> {
[[package]]
name = "uv-private-pypackage"
version = "0.1.0"
source = { git = "https://***@github.com/astral-test/uv-private-pypackage#d780faf0ac91257d4d5a4f0c5a0e4509608c0071" }
source = { git = "https://github.com/astral-test/uv-private-pypackage#d780faf0ac91257d4d5a4f0c5a0e4509608c0071" }
"###
);
});
Expand All @@ -5339,7 +5339,7 @@ fn lock_redact_git() -> Result<()> {
Prepared 2 packages in [TIME]
Installed 2 packages in [TIME]
+ foo==0.1.0 (from file://[TEMP_DIR]/)
+ uv-private-pypackage==0.1.0 (from git+https://***@github.com/astral-test/uv-private-pypackage@d780faf0ac91257d4d5a4f0c5a0e4509608c0071)
+ uv-private-pypackage==0.1.0 (from git+https://github.com/astral-test/uv-private-pypackage@d780faf0ac91257d4d5a4f0c5a0e4509608c0071)
"###);

Ok(())
Expand Down

0 comments on commit 9226310

Please sign in to comment.