refactor: explicit sentinel for validation command redaction (D-09)

This commit is contained in:
wdawdwa committed 2026-08-23 11:43:04 +08:00
1 parent 3408c9dc77
commit cd30a49dcc
2 files changed
+16 -5

No files matched your search

+9 -3
View File
@@ -426,7 +426,9 @@ async function runProcess(
logger.info( logger.info(
{ {
cmd: command, cmd: command,
args: redactProcessArgs(args, label), args: redactProcessArgs(args, label, {
redactLastAsValidationCommand: label === "isolated repository validation"
}),
timeoutMs timeoutMs
}, },
`Spawning ${label}.` `Spawning ${label}.`
@@ -618,9 +620,13 @@ function redactPrompt(args: string[]): string[] {
); );
} }
export function redactProcessArgs(args: string[], label: string): string[] { export function redactProcessArgs(
args: string[],
label: string,
options: { redactLastAsValidationCommand?: boolean } = {}
): string[] {
const redacted = redactPrompt(args); const redacted = redactPrompt(args);
if (label === "isolated repository validation" && redacted.length > 0) { if (options.redactLastAsValidationCommand && redacted.length > 0) {
const commandIndex = redacted.length - 1; const commandIndex = redacted.length - 1;
redacted[commandIndex] = `[validation command: ${args[commandIndex]?.length ?? 0} chars]`; redacted[commandIndex] = `[validation command: ${args[commandIndex]?.length ?? 0} chars]`;
} }
+7 -2
View File
@@ -67,8 +67,13 @@ test("redactProcessArgs hides the goose prompt body", () => {
assert.equal(redacted[0], "run"); assert.equal(redacted[0], "run");
}); });
test("redactProcessArgs hides the validation command", () => { test("redactProcessArgs hides the validation command via explicit sentinel", () => {
const args = ["sh", "-lc", "bootstrap", "ghbot-validation", "npm test && cat secrets"]; const args = ["sh", "-lc", "bootstrap", "ghbot-validation", "npm test && cat secrets"];
const redacted = redactProcessArgs(args, "isolated repository validation"); const redacted = redactProcessArgs(args, "isolated repository validation", {
redactLastAsValidationCommand: true
});
assert.equal(redacted.at(-1), "[validation command: 23 chars]"); assert.equal(redacted.at(-1), "[validation command: 23 chars]");
// Without the sentinel the label alone must not trigger redaction (D-09).
const untouched = redactProcessArgs(args, "isolated repository validation");
assert.equal(untouched.at(-1), "npm test && cat secrets");
}); });