From c4f3eceb2f53a23357978cf498635c0e5919c421 Mon Sep 17 00:00:00 2001 From: Dominik Nakamura Date: Mon, 14 Mar 2022 12:28:14 +0900 Subject: [PATCH] Only include env vars that are specific to Rust --- dist/restore/index.js | 13 ++++++++++++- dist/save/index.js | 13 ++++++++++++- src/common.ts | 14 +++++++++++++- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/dist/restore/index.js b/dist/restore/index.js index f8069d3..e1550d8 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -59597,8 +59597,19 @@ async function getCargoBins() { } function getEnvKey() { const hasher = external_crypto_default().createHash("sha1"); + const validKeys = [ + /^CARGO_.+$/, + /^CC_.+$/, + /^CXX_.+$/, + /^RUSTC_.+$/, + /^RUSTC$/, + /^RUSTDOC$/, + /^RUSTDOCFLAGS$/, + /^RUSTFLAGS$/, + /^RUSTFMT$/, + ]; for (const [key, value] of Object.entries(process.env)) { - if (value) { + if (validKeys.some((re) => re.test(key)) && value) { hasher.update(`${key}=${value}`); } } diff --git a/dist/save/index.js b/dist/save/index.js index be0df7c..2ca6491 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -59597,8 +59597,19 @@ async function getCargoBins() { } function getEnvKey() { const hasher = external_crypto_default().createHash("sha1"); + const validKeys = [ + /^CARGO_.+$/, + /^CC_.+$/, + /^CXX_.+$/, + /^RUSTC_.+$/, + /^RUSTC$/, + /^RUSTDOC$/, + /^RUSTDOCFLAGS$/, + /^RUSTFLAGS$/, + /^RUSTFMT$/, + ]; for (const [key, value] of Object.entries(process.env)) { - if (value) { + if (validKeys.some((re) => re.test(key)) && value) { hasher.update(`${key}=${value}`); } } diff --git a/src/common.ts b/src/common.ts index 83ba944..63236b9 100644 --- a/src/common.ts +++ b/src/common.ts @@ -108,8 +108,20 @@ export async function getCargoBins(): Promise> { function getEnvKey(): string { const hasher = crypto.createHash("sha1"); + const validKeys = [ + /^CARGO_.+$/, + /^CC_.+$/, + /^CXX_.+$/, + /^RUSTC_.+$/, + /^RUSTC$/, + /^RUSTDOC$/, + /^RUSTDOCFLAGS$/, + /^RUSTFLAGS$/, + /^RUSTFMT$/, + ]; + for (const [key, value] of Object.entries(process.env)) { - if (value) { + if (validKeys.some((re) => re.test(key)) && value) { hasher.update(`${key}=${value}`); } }