OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security
TypeScript ai-securityapplication-securityclicode-scanningcodexcodex-securitycybersecuritydevsecopsnodejsnpmopenaisdksecuritytypescriptvulnerability-scanning
fix(dashboard): align the component cost column with its header (#2004)
wj0ea991c118da
diff --git a/sdk/typescript/src/scan-dashboard.ts b/sdk/typescript/src/scan-dashboard.tsindex 676b1dbc7..550b3de0c 100644--- a/sdk/typescript/src/scan-dashboard.ts+++ b/sdk/typescript/src/scan-dashboard.ts@@ -975,7 +975,7 @@ export class ScanDashboard {findings: string,cost: string,): string =>- ` ${marker} ${fitCell(terminalText(name), nameWidth)} ${fitCell(terminalText(status), statusWidth)} ${progress.padStart(progressWidth)} ${findings.padStart(8)}${this.#showCost ? ` ${cost.padStart(8)}` : ""}`;+ ` ${marker} ${fitCell(terminalText(name), nameWidth)} ${fitCell(terminalText(status), statusWidth)} ${progress.padStart(progressWidth)} ${findings.padStart(8)}${this.#showCost ? ` ${cost}` : ""}`;const table = visible.map(({ receipt, dashboard, status, progress }, index) =>row(diff --git a/sdk/typescript/tests-ts/scan-dashboard.test.ts b/sdk/typescript/tests-ts/scan-dashboard.test.tsindex 43416bf7f..950d93169 100644--- a/sdk/typescript/tests-ts/scan-dashboard.test.ts+++ b/sdk/typescript/tests-ts/scan-dashboard.test.ts@@ -2699,6 +2699,7 @@ test.each([80, 160])("a".repeat(74),"界".repeat(37),"e\u0301".repeat(37),+ "unpriced",].map((name, index) => ({id: String(index),name,@@ -2708,7 +2709,7 @@ test.each([80, 160])(}));dashboard.start();dashboard.setComponents(receipts);- for (const [index, receipt] of receipts.entries()) {+ for (const [index, receipt] of receipts.slice(0, -1).entries()) {if (index < 2) {dashboard.updateComponent({ ...receipt, status: "started" });dashboard.recordComponentEvent({@@ -2724,6 +2725,7 @@ test.each([80, 160])(},});}+ const max = index === 2 ? 1 : 12.34;dashboard.recordComponentEvent({componentId: receipt.id,type: "cost",@@ -2734,7 +2736,7 @@ test.each([80, 160])(cacheWriteInputTokens: 0,outputTokens: 1,estimatedUsd: 1,- estimatedUsdRange: { min: 1, max: 12.34, context: "unknown" },+ estimatedUsdRange: { min: 1, max, context: "unknown" },},});}@@ -2747,17 +2749,19 @@ test.each([80, 160])(/Status\s+Progress\s+Findings\s+Cost/u.test(line),);expect(header).toBeGreaterThanOrEqual(0);- const rows = lines.slice(header + 1, header + 4);- expect(rows).toHaveLength(3);+ const rows = lines.slice(header + 1, header + 1 + receipts.length);+ expect(rows).toHaveLength(receipts.length);expect(rows[0]).toContain("2/8 files");expect(rows[1]).toContain("1,234/12,345 reviews");- expect(rows[2]).toMatch(/Queued\s+—\s+—\s+\$1\.00/u);- for (const row of rows) expect(row).toContain("$1.00–$12.34");- expect(- new Set(- rows.map((row) => stringWidth(row.slice(0, row.indexOf("$1.00")))),- ).size,- ).toBe(1);+ expect(rows[2]).toMatch(/Queued\s+—\s+—\s+\$1\.00(?:\s|$)/u);+ const column = (line: string, value: string) =>+ stringWidth(line.slice(0, line.lastIndexOf(value)));+ const costColumn = column(lines[header]!, "Cost");+ for (const row of rows.slice(0, 2)) expect(row).toContain("$1.00–$12.34");+ for (const row of rows.slice(0, -1)) {+ expect(column(row, "$1.00")).toBe(costColumn);+ }+ expect(column(rows.at(-1)!, "—")).toBe(costColumn);dashboard.stop();},);