Skip to content

Commit

Permalink
Don't use CARGO_REGISTRIES_* configuration in hash keys
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Jan 3, 2025
1 parent 989e7e3 commit 8642030
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/compiler/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1466,12 +1466,21 @@ where
.collect();
env_vars.sort();
for (var, val) in env_vars.iter() {
if !var.starts_with("CARGO_") {
continue;
}

// CARGO_MAKEFLAGS will have jobserver info which is extremely non-cacheable.
if var.starts_with("CARGO_") && var != "CARGO_MAKEFLAGS" {
var.hash(&mut HashToDigest { digest: &mut m });
m.update(b"=");
val.hash(&mut HashToDigest { digest: &mut m });
// CARGO_REGISTRIES_*_TOKEN contains non-cacheable secrets.
// Registry override config doesn't need to be hashed, because deps' package IDs
// already uniquely identify the relevant registries.
if var == "CARGO_MAKEFLAGS" || var.starts_with("CARGO_REGISTRIES_") {
continue;
}

var.hash(&mut HashToDigest { digest: &mut m });
m.update(b"=");
val.hash(&mut HashToDigest { digest: &mut m });
}
// 8. The cwd of the compile. This will wind up in the rlib.
cwd.hash(&mut HashToDigest { digest: &mut m });
Expand Down Expand Up @@ -3397,6 +3406,10 @@ proc_macro false
(OsString::from("CARGO_PKG_NAME"), OsString::from("foo")),
(OsString::from("FOO"), OsString::from("bar")),
(OsString::from("CARGO_BLAH"), OsString::from("abc")),
(
OsString::from("CARGO_REGISTRIES_A_TOKEN"),
OsString::from("ignored"),
),
]
.to_vec(),
false,
Expand Down

0 comments on commit 8642030

Please sign in to comment.