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: stop Deep Scan from starting extra reviews during result checks (#1630)
ianw-oai1595fe4d37cd
diff --git a/plugins/codex-security/mcp-app/src/deep-scan/coordinator.ts b/plugins/codex-security/mcp-app/src/deep-scan/coordinator.tsindex 67cafde97..b19fb6383 100644--- a/plugins/codex-security/mcp-app/src/deep-scan/coordinator.ts+++ b/plugins/codex-security/mcp-app/src/deep-scan/coordinator.ts@@ -716,10 +716,9 @@ export class DeepScanCoordinator {}/**- * Keep the discovery pool full until the reducer establishes convergence or- * the configured run cap is exhausted. Completed discoveries enter a stable- * FIFO buffer. One reducer claims the current buffer snapshot; discoveries- * that finish during that reduction wait for the next one.+ * Refill discovery between reductions so a slow reducer cannot build an+ * unchecked backlog. One reducer claims the FIFO buffer. Discoveries that+ * finish during reduction wait for the next one.*/private async runScheduler(): Promise<SchedulerResult> {const config = this.state.config;@@ -905,6 +904,7 @@ export class DeepScanCoordinator {}if (settlements.length === 0) {while (+ !reducer &&!this.discoveryDeadlineReached &&(!previousReducerResultPath ||this.state.noNewStreak < config.stopAfterNoNew) &&diff --git a/plugins/codex-security/mcp-app/tests/test_deep_scan_coordinator.ts b/plugins/codex-security/mcp-app/tests/test_deep_scan_coordinator.tsindex dbcef1ec5..98ab8d708 100644--- a/plugins/codex-security/mcp-app/tests/test_deep_scan_coordinator.ts+++ b/plugins/codex-security/mcp-app/tests/test_deep_scan_coordinator.ts@@ -720,9 +720,14 @@ async function testSettledReducerIsNotStarvedByDiscoveryBacklog() {await executor.dedupStarted.promise;await eventually(- () => executor.discoveryCalls >= 8 && executor.runningDiscovery === 4,+ () =>+ executor.runningDiscovery > 0 &&+ [...store.workers.values()].filter(+ (worker) =>+ worker.kind === "discovery" && worker.status === "succeeded",+ ).length === 4,);- const dispatchedBeforeConvergence = executor.discoveryCalls;+ const dispatchedBeforeConvergence = coordinator.snapshot().dispatchedCount;executor.dedupGate.resolve();const terminal = await coordinator.wait(undefined, 5_000);@@ -735,6 +740,45 @@ async function testSettledReducerIsNotStarvedByDiscoveryBacklog() {assert.equal(executor.discoveryAttempts.size, dispatchedBeforeConvergence);}+async function testSlowReducerPausesDiscoveryRefill() {+ const { fixture, store } = await coordinatorFixture({+ workers: 4,+ subagents: 0,+ stopAfterNoNew: 2,+ maxDiscoveryRuns: 40,+ });+ const executor = new FakeExecutor();+ executor.dedupGate = Promise.withResolvers<void>();+ const coordinator = createCoordinator(fixture, store, executor);+ coordinator.start();++ await executor.dedupStarted.promise;+ const dispatchedAtReduction = coordinator.snapshot().dispatchedCount;+ await eventually(+ () =>+ [...store.workers.values()].filter(+ (worker) =>+ worker.kind === "discovery" && worker.status === "succeeded",+ ).length >= dispatchedAtReduction,+ );+ const dispatchedWhileReducing = coordinator.snapshot().dispatchedCount;+ executor.dedupGate.resolve();++ const terminal = await coordinator.wait(undefined, 5_000);+ assert.equal(+ dispatchedWhileReducing,+ dispatchedAtReduction,+ "wait for novelty before refilling discovery",+ );+ assert.equal(terminal?.terminalReason, "saturated", terminal?.error);+ assert.equal(terminal?.dispatchedCount, dispatchedAtReduction);+ assert.equal(+ new Set(store.dedupClaims.flatMap((claim) => claim.workerIds)).size,+ dispatchedAtReduction,+ );+ assert.equal(store.run.noNewStreak, dispatchedAtReduction);+}+async function testSingletonHardCapReduction() {const { fixture, store } = await coordinatorFixture({workers: 4,@@ -4176,6 +4220,7 @@ try {await testDiscoveryDeadlineBeforeWorkerDispatchReturnsPartialEvidence();await testSaturationIgnoresWorkerFailureSettledAfterStop();await testSettledReducerIsNotStarvedByDiscoveryBacklog();+ await testSlowReducerPausesDiscoveryRefill();await testSingletonHardCapReduction();await testExhaustedRetryFailsScan();await testProviderCybersecurityRiskMessagesReplaceRefusedDiscoveryImmediately();