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(deep-scan): let reducers page inputs without code mode (#1910)
Michael D'Angelo0613ad4e8dc2
diff --git a/plugins/codex-security/mcp-app/src/deep-scan/worker-runner.ts b/plugins/codex-security/mcp-app/src/deep-scan/worker-runner.tsindex 8445baa15..f1666bf38 100644--- a/plugins/codex-security/mcp-app/src/deep-scan/worker-runner.ts+++ b/plugins/codex-security/mcp-app/src/deep-scan/worker-runner.ts@@ -672,8 +672,8 @@ function reducerCompletionContinuation(attempt: number): string {function reducerInputRecoveryInstructions(): string[] {return ["If input retrieval exceeded a response or IPC size limit, call get_codex_security_deep_reducer_inputs({ cursor?, maxBytes, findingRef? }) with a smaller maxBytes budget (for example, halve the failed request's budget), preserving its cursor and findingRef to retry the same page.",- "Do not repeat an oversized request unchanged. If inputs have not been read yet, paginate all assigned findings and the previous aggregate, assembling each json fragment in code and following nextCursor until absent; inspect assembled data selectively and fetch details by findingRef.",- "Persist fragments, cursor: nextCursor ?? null, and completion together in one serializable store value after each successful page. Never store an undefined cursor or append a page already committed before a later cell failure. Check MCP isError before parsing its text as a page.",+ "If inputs have not been read yet, paginate all assigned findings and the previous aggregate. Follow nextCursor until absent and assemble the json fragments in order for each findingRef. Check MCP isError before reading a page.",+ "Without code mode, call the input and submission tools directly. With code mode, persist fragments, cursor: nextCursor ?? null, and completion together in one store value after each successful page. Resume from the next unread page.","Preserve pages already read and account for every finding before submitting the aggregate.",];}diff --git a/plugins/codex-security/mcp-app/templates/deep-scan/dedup.md b/plugins/codex-security/mcp-app/templates/deep-scan/dedup.mdindex 1ac9ecea8..521ed4bbf 100644--- a/plugins/codex-security/mcp-app/templates/deep-scan/dedup.md+++ b/plugins/codex-security/mcp-app/templates/deep-scan/dedup.md@@ -6,11 +6,13 @@ Use this exact reducer configuration:{{DEDUP_CONTEXT_JSON}}```-Read the assigned, already-validated Standard findings and the previous aggregate with `get_codex_security_deep_reducer_inputs({ maxBytes, cursor? })`. Choose a `maxBytes` budget for a small response you can work with, well below the code-mode IPC frame limit. The budget counts serialized response bytes, including JSON escaping, rather than findings. Both new findings and the previous aggregate are paged; even one large finding can span pages.+Read the assigned, already-validated Standard findings and the previous aggregate with `get_codex_security_deep_reducer_inputs({ maxBytes, cursor? })`. Choose a small `maxBytes` that fits comfortably in a tool response. The budget counts serialized response bytes, including JSON escaping. Even one large finding can span pages.-Each tool response has one text content block containing `{ json, nextCursor? }`. Parse that block to obtain the page. Its `json` is a fragment, not necessarily a complete JSON value. Follow `nextCursor` until absent, concatenate the fragments inside code mode, and only then parse the assembled document as `{ discoveries, previous }`. Inspect the findings and context selectively; do not print or return the entire assembled document from code mode. Do not concatenate pages from different `findingRef` requests.+Each tool response has one text content block containing `{ json, nextCursor? }`. Its `json` is a fragment that may end inside a field. Follow `nextCursor` until absent and read the fragments in order as one document. The assigned document contains `{ discoveries, previous }`. Keep pages from different `findingRef` requests separate.-Keep fragments, cursor and completion together in one serializable `store` value. An absent terminal cursor must become `null`; `store` cannot save `undefined`. Commit the state only after a successful page, so a retry resumes at the next unread page rather than appending a completed tail again. In code mode, define this helper and call it with your selected byte budget (and optional `findingRef`); inspect only the needed fields of its returned document:+Without code mode, call `get_codex_security_deep_reducer_inputs` directly for each page. Keep the fragments in conversation order and submit the complete aggregate directly with `record_codex_security_deep_reduction`.++With code mode, use the helper below to assemble the document inside a cell and return only the fields you need. It saves the fragments, next unread cursor, and completion together after each successful page. The terminal cursor is `null` because `store` cannot save `undefined`.```javascriptasync function readReducerDocument(maxBytes, findingRef = null) {@@ -41,7 +43,7 @@ Use the exact exposed tool name if the host uses a different MCP namespace. CodeThe input view omits the retained `provenance.sourceFindings`, `previousFindings`, and `originalCandidates` bodies. The host preserves those bodies when saving the aggregate. Fetch full details when needed with the same paged tool and `findingRef`: use `source:<sourceFindingId>` for an original source, or `previous:N` for the previous aggregate's zero-based finding index, including its synthesized history. Never copy those retained bodies into your submission; submit the semantic finding and its source refs.-If a response exceeds the IPC frame limit, retry the failed page with a smaller `maxBytes` (halve the budget used for that request), keeping its cursor and findingRef. Do not retry an unchanged oversized request. Preserve already-read fragments and continue from the failed page. If the budget is too small to hold even one character and the page envelope, increase it as directed by the tool's diagnostic.+If a response is truncated or exceeds the IPC frame limit, retry the failed page with a smaller `maxBytes` (halve the budget used for that request), keeping its cursor and findingRef. Preserve already-read fragments and continue from the failed page. If the budget is too small to hold even one character and the page envelope, increase it as directed by the tool's diagnostic.Read every finding and the previous aggregate. Merge only the same actionable root issue using remediation-subsumption: fixing the retained finding must also fix every absorbed finding. Preserve distinct reachable vulnerable instances, proof tuples, useful evidence, uncertainty, locations, provenance, severity, validation, attack paths, and remediation.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 b3807ef05..990e48fc9 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@@ -1523,6 +1523,12 @@ async function testMissingReducerResultResumesExistingThread(executor.dedupContinuationPrompts[1] ?? "",/paginate all assigned findings and the previous aggregate/,);+ for (const prompt of [+ await readFile(executor.dedupPromptPaths[0], "utf8"),+ executor.dedupContinuationPrompts[1] ?? "",+ ]) {+ assert.match(prompt, /without code mode[^\n]*\bdirectly\b/i);+ }assert.equal(new Set(executor.dedupPromptPaths).size, 1);await assert.rejects(realpath(