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: report when Deep Scan times out before completing a review (#2434)
Michael D'Angelo85b54b34df8c
diff --git a/plugins/codex-security/mcp-app/src/deep-scan/coordinator.ts b/plugins/codex-security/mcp-app/src/deep-scan/coordinator.tsindex 93a3a71d6..b55d2960b 100644--- a/plugins/codex-security/mcp-app/src/deep-scan/coordinator.ts+++ b/plugins/codex-security/mcp-app/src/deep-scan/coordinator.ts@@ -55,6 +55,8 @@ import type {const RETRY_DELAYS_MS = [60_000, 180_000, 540_000] as const;const COORDINATOR_HEARTBEAT_INTERVAL_MS = 5_000;const DEFAULT_DISCOVERY_TIMEOUT_HOURS = 96;+const NO_REVIEW_BEFORE_DEADLINE =+ "The configured discovery time limit elapsed before any source review completed.";interface LoopResult {reason: DeepScanTerminalReason;@@ -372,15 +374,11 @@ export class DeepScanCoordinator {: scanDraftInputSchema.parse({scanId: this.state.scanId,findings: [],+ scope: { limitations: [NO_REVIEW_BEFORE_DEADLINE] },reviewState: {surfaces: [],explicitExclusions: [],- deferred: [- {- reason:- "The configured discovery time limit elapsed before any source review completed.",- },- ],+ deferred: [{ reason: NO_REVIEW_BEFORE_DEADLINE }],},});if (draft.scanId !== this.state.scanId) {diff --git a/plugins/codex-security/mcp-app/tests/test_deep_scan_stdio_lifecycle.ts b/plugins/codex-security/mcp-app/tests/test_deep_scan_stdio_lifecycle.tsindex 30de1491a..303f9d358 100644--- a/plugins/codex-security/mcp-app/tests/test_deep_scan_stdio_lifecycle.ts+++ b/plugins/codex-security/mcp-app/tests/test_deep_scan_stdio_lifecycle.ts@@ -295,7 +295,17 @@ service_tier = "ultrafast"true,);const coverage = await readFixtureCoverage(expiredState.scanDir, stateDir);- assert.match(coverage.deferred[0].reason, /discovery time limit elapsed/);+ const limitation = coverage.deferred[0].reason;+ assert.match(limitation, /discovery time limit elapsed/);+ const manifest = await readJson(+ path.join(expiredState.scanDir, "scan-manifest.json"),+ );+ assert.ok(manifest.scan.scope.limitations?.includes(limitation));+ const report = await readFile(+ path.join(expiredState.scanDir, "report.md"),+ "utf8",+ );+ assert.ok(report.includes(limitation));assert.deepEqual(await readLogLines(startLogPath), []);const targetRequest = {diff --git a/sdk/typescript/docs/cli.md b/sdk/typescript/docs/cli.mdindex 10df99517..10a9e32cd 100644--- a/sdk/typescript/docs/cli.md+++ b/sdk/typescript/docs/cli.md@@ -926,6 +926,8 @@ that `subagents` can be zero. Discovery time accepts positive fractional minutesits default and maximum are 5760 minutes (96 hours). Unlike Standard'sadvisory allowance, the Deep discovery limit is enforced. Resuming aDeep scan keeps its original deadline; rerunning starts a new scan.+If the deadline expires before any source review completes, the saved report+and scan manifest record that limitation.`--max-time-hours`, SDK `maxTimeHours`, project `scan.deep.max_time_hours`, andlegacy TOML `deep_scan.max_time_hours` remain deprecated Deep-only aliases inhours. Explicit settings override lower-priority configuration across units.diff --git a/sdk/typescript/src/cli.ts b/sdk/typescript/src/cli.tsindex e06870b99..5fc8ef0e7 100644--- a/sdk/typescript/src/cli.ts+++ b/sdk/typescript/src/cli.ts@@ -11646,9 +11646,13 @@ async function readDeepScanStop(}if (state?.terminalReason !== "capped") return undefined;const { maxDiscoveryRuns, maxTimeHours } = state.config;- if (state.dispatchedCount >= maxDiscoveryRuns) {+ // A capped run with no completed reviews can finish only at its discovery deadline.+ if (+ state.completionSequence > 0 &&+ state.dispatchedCount >= maxDiscoveryRuns+ ) {return {- reason: `Reached the limit of ${maxDiscoveryRuns} review rounds. ${state.completionSequence > 0 && state.noNewStreak === 0 ? "The latest review still found new issues." : "More issues may remain."}`,+ reason: `Reached the limit of ${maxDiscoveryRuns} review rounds. ${state.noNewStreak === 0 ? "The latest review still found new issues." : "More issues may remain."}`,nextStep: `To scan further, rerun with --max-discovery-runs greater than ${maxDiscoveryRuns}.`,};}@@ -11659,7 +11663,7 @@ async function readDeepScanStop(const roundedMinutes = Number(maxTimeMinutes.toPrecision(15));if (roundedMinutes / 60 === maxTimeHours) maxTimeMinutes = roundedMinutes;return {- reason: `Reached the ${maxTimeMinutes}-minute time limit. More issues may remain.`,+ reason: `Reached the ${maxTimeMinutes}-minute time limit. ${state.completionSequence === 0 ? "No source review completed." : "More issues may remain."}`,nextStep:maxTimeHours < 96? `To scan further, rerun with --max-time greater than ${maxTimeMinutes}.`diff --git a/sdk/typescript/tests-ts/cli-deep-scan-summary.test.ts b/sdk/typescript/tests-ts/cli-deep-scan-summary.test.tsindex f72be3ed3..695750e17 100644--- a/sdk/typescript/tests-ts/cli-deep-scan-summary.test.ts+++ b/sdk/typescript/tests-ts/cli-deep-scan-summary.test.ts@@ -41,6 +41,23 @@ describe("deep scan completion summary", () => {"40 review rounds. The latest review still found new issues","--max-discovery-runs greater than 40",],+ [+ "completed review limit even if finalization outlasts the deadline",+ { completedAt: "2026-01-05T00:01:00Z" },+ "40 review rounds. The latest review still found new issues",+ "--max-discovery-runs greater than 40",+ ],+ [+ "time limit before any dispatched review completed",+ {+ dispatchedCount: 1,+ completionSequence: 0,+ config: { maxDiscoveryRuns: 1, maxTimeHours: 5 / 60 },+ completedAt: "2026-01-01T00:05:01Z",+ },+ "5-minute time limit. No source review completed.",+ "--max-time greater than 5",+ ],["quiet round",{ noNewStreak: 1 },