Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion actions/setup/js/redact_secrets.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function redactSecrets(content, secretValues) {
const sortedSecrets = secretValues.slice().sort((a, b) => b.length - a.length);
for (const secretValue of sortedSecrets) {
// Skip empty or very short values (likely not actual secrets)
if (!secretValue || secretValue.length < 8) {
if (!secretValue || secretValue.length < 6) {
continue;
}
// Count occurrences before replacement
Expand Down
13 changes: 10 additions & 3 deletions actions/setup/js/redact_secrets.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,18 @@ describe("redact_secrets.cjs", () => {
expect(callString).not.toContain(secretValue);
}
}),
it("should skip very short values", async () => {
it("should skip very short values (less than 6 characters)", async () => {
const testFile = path.join(tempDir, "test.txt");
(fs.writeFileSync(testFile, "Short: abc123"), (process.env.GH_AW_SECRET_NAMES = "SHORT_SECRET"), (process.env.SECRET_SHORT_SECRET = "abc"));
(fs.writeFileSync(testFile, "Short: 12345"), (process.env.GH_AW_SECRET_NAMES = "SHORT_SECRET"), (process.env.SECRET_SHORT_SECRET = "12345"));
const modifiedScript = redactScript.replace('findFiles("/tmp/gh-aw", targetExtensions)', `findFiles("${tempDir.replace(/\\/g, "\\\\")}", targetExtensions)`);
(await eval(`(async () => { ${modifiedScript}; await main(); })()`), expect(fs.readFileSync(testFile, "utf8")).toBe("Short: abc123"));
(await eval(`(async () => { ${modifiedScript}; await main(); })()`), expect(fs.readFileSync(testFile, "utf8")).toBe("Short: 12345"));
}),
it("should redact 6-character secrets", async () => {
const testFile = path.join(tempDir, "test.txt");
const secretValue = "abc123";
(fs.writeFileSync(testFile, `Secret: ${secretValue} test`), (process.env.GH_AW_SECRET_NAMES = "SIX_CHAR_SECRET"), (process.env.SECRET_SIX_CHAR_SECRET = secretValue));
const modifiedScript = redactScript.replace('findFiles("/tmp/gh-aw", targetExtensions)', `findFiles("${tempDir.replace(/\\/g, "\\\\")}", targetExtensions)`);
(await eval(`(async () => { ${modifiedScript}; await main(); })()`), expect(fs.readFileSync(testFile, "utf8")).toBe("Secret: abc*** test"));
}),
it("should handle multiple secrets in same file", async () => {
const testFile = path.join(tempDir, "test.txt"),
Expand Down
Loading