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

refactor(cli): remove unreachable component dashboard status cases (#2230)

Michael D'Angelo6f9cfd689433
diff --git a/sdk/typescript/src/scan-dashboard.ts b/sdk/typescript/src/scan-dashboard.ts
index 8f7de4141..676b1dbc7 100644
--- a/sdk/typescript/src/scan-dashboard.ts
+++ b/sdk/typescript/src/scan-dashboard.ts
@@ -52,6 +52,11 @@ const CURSOR_HOME = "\u001B[H";
const ERASE_LINE = "\u001B[2K";
const MAX_HISTORY_ENTRIES = 2_000;
const FIXED_SCREEN_ROWS = 4; // Title, two dividers and elapsed time.
+const COMPONENT_STATUS = {
+ pending: "Queued",
+ completed: "Complete",
+ failed: "Failed",
+} as const;
interface DashboardStream {
write(chunk: string, callback?: (error?: Error | null) => void): unknown;
@@ -476,7 +481,7 @@ export class ScanDashboard {
mode: "standard",
componentName: receipt.name,
});
- dashboard.setStage("Queued");
+ dashboard.setStage(COMPONENT_STATUS.pending);
dashboard.note(`Scope: ${receipt.paths.join(", ")}`);
return { receipt: { ...receipt }, dashboard };
});
@@ -494,11 +499,12 @@ export class ScanDashboard {
dashboard.#startedAt = this.#options.clock.now();
dashboard.setStage("Preparing scan");
} else if (receipt.status !== "pending") {
+ const status = COMPONENT_STATUS[receipt.status];
dashboard.#finishedAt = this.#options.clock.now();
- dashboard.setStage(componentStatus(receipt));
+ dashboard.setStage(status);
dashboard.note(
receipt.error ??
- `${componentStatus(receipt)} · ${receipt.findingCount ?? 0} findings before deduplication`,
+ `${status} · ${receipt.findingCount ?? 0} findings before deduplication`,
);
}
}
@@ -541,8 +547,7 @@ export class ScanDashboard {
dashboard.setUsageObservation(event.value);
break;
case "workers":
- if (event.value.kind === "dispatch")
- dashboard.setStage(scanPhaseLabel(event.value.phase));
+ dashboard.setStage(scanPhaseLabel(event.value.phase));
break;
case "warning":
dashboard.note(event.value);
@@ -937,7 +942,7 @@ export class ScanDashboard {
const status =
receipt.status === "started"
? dashboard.#stage
- : componentStatus(receipt);
+ : COMPONENT_STATUS[receipt.status];
return { receipt, dashboard, status, progress };
});
const progressWidth = Math.max(
@@ -1476,15 +1481,6 @@ function formatElapsed(seconds: number): string {
return `${String(Math.floor(seconds / 60)).padStart(2, "0")}:${String(seconds % 60).padStart(2, "0")}`;
}
-function componentStatus(receipt: ComponentReceipt): string {
- return {
- pending: "Queued",
- started: "Running",
- completed: "Complete",
- failed: "Failed",
- }[receipt.status];
-}
-
function formatLocalTime(timestamp: number): string {
const date = new Date(timestamp);
return [date.getHours(), date.getMinutes(), date.getSeconds()]