Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

fix(history): escape severity labels in scan summaries (#121)

Michaela01ab01123c2
diff --git a/sdk/typescript/src/scan-history-renderer.ts b/sdk/typescript/src/scan-history-renderer.ts
index bc59b8d00..5cdf5387f 100644
--- a/sdk/typescript/src/scan-history-renderer.ts
+++ b/sdk/typescript/src/scan-history-renderer.ts
@@ -319,7 +319,7 @@ export function renderScanHistory(
Object.keys(SEVERITY_COLORS).indexOf(right.toUpperCase()),
)
.map(([severity, count]) => {
- const label = severity.toUpperCase();
+ const label = clean(severity).toUpperCase();
return paint(
`${clean(count)} ${label}`,
SEVERITY_COLORS[label] ?? 37,
diff --git a/sdk/typescript/tests-ts/scan-history-renderer.test.ts b/sdk/typescript/tests-ts/scan-history-renderer.test.ts
index 3ef71e9a4..e164e18a4 100644
--- a/sdk/typescript/tests-ts/scan-history-renderer.test.ts
+++ b/sdk/typescript/tests-ts/scan-history-renderer.test.ts
@@ -98,7 +98,7 @@ describe("scan history renderer", () => {
expect(text).toContain("0 → 2");
});
- test("orders severity totals from critical to informational", () => {
+ test("orders severity totals and escapes labels in saved history", () => {
const text = renderScanHistory(
{
scanId: "synthetic-scan",
@@ -106,6 +106,7 @@ describe("scan history renderer", () => {
progress: { status: "complete" },
findings: [],
severityCounts: {
+ ["fu\u001b[2Jture"]: 6,
low: 4,
informational: 5,
medium: 3,
@@ -116,6 +117,8 @@ describe("scan history renderer", () => {
"show",
{ color: false },
);
+ expect(text).not.toContain("\u001b[2J");
+ expect(text).toContain("6 FUTURE");
expect(text).toMatch(
/1 CRITICAL.*2 HIGH.*3 MEDIUM.*4 LOW.*5 INFORMATIONAL/,
);