refactor: explicit sentinel for validation command redaction (D-09)
This commit is contained in:
1 parent
3408c9dc77
commit
cd30a49dcc
2 files changed
+16
-5
No files matched your search
+9
-3
@@ -426,7 +426,9 @@ async function runProcess(
|
||||
logger.info(
|
||||
{
|
||||
cmd: command,
|
||||
args: redactProcessArgs(args, label),
|
||||
args: redactProcessArgs(args, label, {
|
||||
redactLastAsValidationCommand: label === "isolated repository validation"
|
||||
}),
|
||||
timeoutMs
|
||||
},
|
||||
`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);
|
||||
if (label === "isolated repository validation" && redacted.length > 0) {
|
||||
if (options.redactLastAsValidationCommand && redacted.length > 0) {
|
||||
const commandIndex = redacted.length - 1;
|
||||
redacted[commandIndex] = `[validation command: ${args[commandIndex]?.length ?? 0} chars]`;
|
||||
}
|
||||
|
||||
@@ -67,8 +67,13 @@ test("redactProcessArgs hides the goose prompt body", () => {
|
||||
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 redacted = redactProcessArgs(args, "isolated repository validation");
|
||||
const redacted = redactProcessArgs(args, "isolated repository validation", {
|
||||
redactLastAsValidationCommand: true
|
||||
});
|
||||
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");
|
||||
});
|
||||
Reference in new issue
Block a user