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
test(plugin): cover duplicate closures of a saved task (#978)
Michael Beddows279b9639dd83
diff --git a/plugins/codex-security/mcp-app/tests/test_artifact_scan_draft_recovery.ts b/plugins/codex-security/mcp-app/tests/test_artifact_scan_draft_recovery.tsindex 71f2cfe39..38ff2134c 100644--- a/plugins/codex-security/mcp-app/tests/test_artifact_scan_draft_recovery.ts+++ b/plugins/codex-security/mcp-app/tests/test_artifact_scan_draft_recovery.ts@@ -29,6 +29,17 @@ const { recordCodexSecurityScanDraftViaWorkbench, saveScanDraftCheckpoint } =const execFileAsync = promisify(execFile);const generic = { reason: "Review remains.", paths: ["src/example.py"] };const close = (id: string, reason = "Review completed.") => ({ id, reason });++async function snapshotFiles(directory: string): Promise<[string, Buffer][]> {+ const files: [string, Buffer][] = [];+ for (const entry of await readdir(directory, { withFileTypes: true })) {+ const filename = path.join(directory, entry.name);+ if (entry.isDirectory()) files.push(...(await snapshotFiles(filename)));+ else files.push([filename, await readFile(filename)]);+ }+ return files.sort(([left], [right]) => left.localeCompare(right));+}+type FixtureFinding = Record<string, unknown> & {title: string;severity: { level: string };@@ -1035,6 +1046,16 @@ for (const layout of ["standard", "diff", "worker"] as const) {assert.deepEqual(await readdir(f.root), []);second.id = "other-review";await f.writeReviewState({ deferred: [first, second] });+ const before = await snapshotFiles(f.root);+ const repeated = [+ close(first.id),+ close(first.id, "Checked both callers."),+ ];+ await assert.rejects(+ f.writeReviewState({ resolvedDeferred: repeated }, true),+ /reviewState.resolvedDeferred repeats review/,+ );+ assert.deepEqual(await snapshotFiles(f.root), before);await f.writeReviewState({ resolvedDeferred: [close(first.id)] }, true);assert.deepEqual((await f.read()).deferred, [second]);});@@ -1060,17 +1081,7 @@ for (const layout of ["standard", "diff", "worker"] as const) {(layout === "worker" ? saved.reviewState : saved).deferred = tasks;await writeJson(filename, saved);}- const snapshot = async (- directory = f.root,- ): Promise<[string, string][]> => {- const files: [string, string][] = [];- for (const entry of await readdir(directory, { withFileTypes: true })) {- const filename = path.join(directory, entry.name);- if (entry.isDirectory()) files.push(...(await snapshot(filename)));- else files.push([filename, await readFile(filename, "utf8")]);- }- return files.sort(([left], [right]) => left.localeCompare(right));- };+ const snapshot = () => snapshotFiles(f.root);const original = await snapshot();for (let attempt = 0; attempt < 2; attempt += 1) {await assert.rejects(diff --git a/plugins/codex-security/references/final-report.md b/plugins/codex-security/references/final-report.mdindex 17147fdf1..1334a4f34 100644--- a/plugins/codex-security/references/final-report.md+++ b/plugins/codex-security/references/final-report.md@@ -64,9 +64,9 @@ The plugins bundled in `npm-v0.1.32` through `npm-v0.6.0` preserve the saved `idOn builds containing `e6c7b28` (after `npm-v0.6.0`), first establish the corrected `identity` from independent evidence. Use this procedure only if no checkpoint has already saved the corrected identity alongside the original. If both identities are active, leave the scan unsealed and report the conflict. [Finding recovery change #1310](https://github.com/openai/codex-security/pull/1310)-Submit the revision with its corrected identity through `record_codex_security_scan_draft` with `complete: false`. Put each distinct prior version directly in the revision's `provenance.previousFindings` array. Copy the full saved finding, including its identity, evidence and provenance, omitting only its own `provenance.previousFindings`. The workbench restores nested history for each unambiguous match. Before submitting the final draft, verify in `findings.json` and `coverage.json` that only the corrected identity is active for this finding, its prior versions are in its history, and other findings and independently pending work are intact.+Submit the revision with its corrected identity through `record_codex_security_scan_draft` with `complete: false`. Put each distinct prior version directly in the revision's `provenance.previousFindings` array. Copy the full saved finding, including its identity, evidence and provenance, omitting only its own `provenance.previousFindings`. The workbench restores nested history for each unambiguous match. Before submitting the final draft, verify in `findings.json` that only the corrected identity is active for this finding, its prior versions are in its history, and other findings are intact. Check independently pending work in the unsealed `scan-manifest.json` under `scan.reviewState`, or in `coverage.json` if the manifest references it.-A finding or a `rejected` or `not_applicable` disposition for the same candidate can resolve a `needs_follow_up` surface. Since `npm-v0.2.0`, `coverage.resolvedDeferred` closes generic tasks by saved ID and reason. Omission alone does not retire a surface or explicit exclusion. There is no general operation to remove either entry by request or to migrate a copy of a 0.1.32 scan for these corrections. If the required correction is unsupported or still absent from the saved result, leave the scan unsealed, preserve its checkpoints and outstanding work, and report which entry still needs correction.+A finding or a `rejected` or `not_applicable` disposition for the same candidate can resolve a `needs_follow_up` surface. To close a generic task, submit its saved ID and completion reason in `reviewState.resolvedDeferred`. Older draft tools used `coverage.resolvedDeferred` beginning in `npm-v0.2.0`. Omission alone does not retire a surface or explicit exclusion. There is no general operation to remove either entry by request or to migrate a copy of a 0.1.32 scan for these corrections. If the required correction is unsupported or still absent from the saved result, leave the scan unsealed, preserve its checkpoints and outstanding work, and report which entry still needs correction.## Response