Skip to content

Commit fb2a16f

Browse files
authored
[codex-security] Remove scan error prefixes (#115)
* [codex-security] remove scan error prefixes * [codex-security] update launcher error expectations
1 parent 630810b commit fb2a16f

3 files changed

Lines changed: 13 additions & 16 deletions

File tree

sdk/typescript/src/cli.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,17 +2622,13 @@ async function runScan(
26222622
failure instanceof OutputInsideProtectedRootError
26232623
? cliErrorMessage(protectedRootErrorMessage(failure))
26242624
: scanFailureMessage(failure, selectedAuthentication);
2625-
if (failure instanceof OutputInsideProtectedRootError) {
2626-
errorOutput.write(`${message}\n`);
2627-
} else {
2628-
errorOutput.write(`codex-security: ${message}\n`);
2629-
}
2625+
errorOutput.write(`${message}\n`);
26302626
if (failure instanceof ScanInterruptedError) {
26312627
return { exitCode: 2, error: message };
26322628
}
26332629
if (scanDir !== null) {
26342630
errorOutput.write(
2635-
`codex-security: Partial output was kept at ${cliErrorMessage(scanDir)}.\n`,
2631+
`Partial output was kept at ${cliErrorMessage(scanDir)}.\n`,
26362632
);
26372633
}
26382634
return { exitCode: 2, error: message };
@@ -2642,7 +2638,7 @@ async function runScan(
26422638
return { exitCode: 0, data: { dryRun: true, ...preflight } };
26432639
}
26442640
if (result === null) {
2645-
errorOutput.write("codex-security: scan completed without a result\n");
2641+
errorOutput.write("scan completed without a result\n");
26462642
return { exitCode: 2, error: "Scan completed without a result." };
26472643
}
26482644
const threshold = arguments_.failOnSeverity;
@@ -2844,7 +2840,7 @@ function protectedRootErrorMessage(
28442840
? "Set TMPDIR (or TEMP on Windows) to a writable directory outside the protected root."
28452841
: `Set TMPDIR (or TEMP on Windows) to ${quoteCliPath(suggestion)} after creating that directory.`;
28462842
return [
2847-
`codex-security: ${description} must be outside the scanned directory and any enclosing Git worktree.`,
2843+
`${description} must be outside the scanned directory and any enclosing Git worktree.`,
28482844
` Resolved path: ${error.outputDirectory}`,
28492845
` Protected root: ${error.protectedRoot}`,
28502846
` Reason: ${reason}`,

sdk/typescript/tests-ts/cli-launcher.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe("CLI launcher", () => {
5757
expect(child.status).toBe(2);
5858
expect(child.stdout).toBe("");
5959
expect(child.stderr).toBe(
60-
`codex-security: working directory is unavailable: ${REDACTED_CREDENTIALS}\n`,
60+
`working directory is unavailable: ${REDACTED_CREDENTIALS}\n`,
6161
);
6262
} finally {
6363
await rm(root, { recursive: true, force: true });
@@ -183,7 +183,7 @@ describe("CLI launcher", () => {
183183
expect([failed.status, failed.stdout, failed.stderr]).toEqual([
184184
2,
185185
"",
186-
"codex-security: working directory is unavailable\n",
186+
"working directory is unavailable\n",
187187
]);
188188
} finally {
189189
await rm(root, { recursive: true, force: true });

sdk/typescript/tests-ts/cli.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ describe("CLI", () => {
14301430
expect([failed.status, failed.stdout, failed.stderr]).toEqual([
14311431
2,
14321432
"",
1433-
"codex-security: working directory is unavailable\n",
1433+
"working directory is unavailable\n",
14341434
]);
14351435
} finally {
14361436
await rm(root, { recursive: true, force: true });
@@ -2029,7 +2029,8 @@ describe("CLI", () => {
20292029
await main(["scan", ".", "--json"], stdout.stream, stderr.stream, deps),
20302030
).toBe(2);
20312031
expect(stdout.text()).toBe("");
2032-
expect(stderr.text()).toContain(`codex-security: ${message}\n`);
2032+
expect(stderr.text()).toContain(`${message}\n`);
2033+
expect(stderr.text()).not.toContain("codex-security:");
20332034
expect(stderr.text()).not.toContain("model service could not be reached");
20342035
}
20352036
});
@@ -2769,7 +2770,7 @@ describe("CLI", () => {
27692770
await main(["scan", "."], stdout.stream, stderr.stream, failing),
27702771
).toBe(2);
27712772
expect(stdout.text()).toBe("");
2772-
expect(stderr.text()).toContain("codex-security: invalid scan request\n");
2773+
expect(stderr.text()).toContain("invalid scan request\n");
27732774
expect(stderr.text()).not.toContain("Running scan");
27742775
expect(stderr.text()).not.toContain("CodexSecurityError");
27752776
});
@@ -2794,7 +2795,7 @@ describe("CLI", () => {
27942795
),
27952796
).toBe(2);
27962797
expect(stdout.text()).toBe("");
2797-
expect(stderr.text()).toContain("codex-security: invalid scan request\n");
2798+
expect(stderr.text()).toContain("invalid scan request\n");
27982799

27992800
const unavailableCwd = dependencies();
28002801
unavailableCwd.currentDirectory = () => {
@@ -2922,6 +2923,7 @@ describe("CLI", () => {
29222923
"Isolated Codex runtime directory must be outside the scanned directory and any enclosing Git worktree.",
29232924
);
29242925
expect(stderr.text()).toContain(`Partial output was kept at ${partial}.`);
2926+
expect(stderr.text()).not.toContain("codex-security:");
29252927
});
29262928

29272929
test("redacts credentials embedded in protected-root diagnostics", async () => {
@@ -2982,8 +2984,7 @@ describe("CLI", () => {
29822984
).toBe(2);
29832985
expect(stdout.text()).toBe("");
29842986
expect(stderr.text()).toBe(
2985-
"[00:00] Preparing scan\n" +
2986-
`codex-security: scan failed ${REDACTED_CREDENTIALS}\n`,
2987+
"[00:00] Preparing scan\n" + `scan failed ${REDACTED_CREDENTIALS}\n`,
29872988
);
29882989
}
29892990
});

0 commit comments

Comments
 (0)