@openai/codex-security 0.1.17 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +127 -18
- package/_bundled_plugin/.mcp.json +1 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/references/core-scan.md +1 -1
- package/_bundled_plugin/references/final-report.md +4 -2
- package/_bundled_plugin/references/scan-artifacts.md +1 -1
- package/_bundled_plugin/references/scan-contract.md +18 -7
- package/_bundled_plugin/schemas/scan-manifest.schema.json +2 -2
- package/_bundled_plugin/schemas/tools/scan-draft.schema.json +23 -0
- package/_bundled_plugin/scripts/deep_scan_workbench.py +88 -1
- package/_bundled_plugin/scripts/finalize_scan_contract.py +58 -18
- package/_bundled_plugin/scripts/report_projection.py +19 -8
- package/_bundled_plugin/scripts/workbench_cli.py +13 -0
- package/_bundled_plugin/scripts/workbench_db.py +149 -167
- package/_bundled_plugin/scripts/workbench_finding_index.py +101 -0
- package/_bundled_plugin/scripts/workbench_remediation.py +19 -0
- package/_bundled_plugin/scripts/workbench_saved_results.py +1289 -0
- package/_bundled_plugin/scripts/workbench_schema.py +28 -0
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +4 -4
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +1 -1
- package/_bundled_plugin/skills/security-scan/SKILL.md +1 -1
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +1 -1
- package/dist/api.d.ts +2 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +54 -7
- package/dist/api.js.map +1 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +247 -25
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts +16 -0
- package/dist/cloud-publish.d.ts.map +1 -0
- package/dist/cloud-publish.js +138 -0
- package/dist/cloud-publish.js.map +1 -0
- package/dist/contract.d.ts +1 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +4 -0
- package/dist/contract.js.map +1 -1
- package/dist/custom-validation-prompt.js +3 -3
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/linear.d.ts.map +1 -1
- package/dist/linear.js +17 -6
- package/dist/linear.js.map +1 -1
- package/dist/models.d.ts +1 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/publication.d.ts +1 -0
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js +1 -0
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts +1 -0
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -118,20 +118,21 @@ Pass runtime configuration to the `CodexSecurity` constructor:
|
|
|
118
118
|
Pass scan configuration to `security.run(repository, options)` or
|
|
119
119
|
`security.preflight(repository, options)`:
|
|
120
120
|
|
|
121
|
-
| Option | Description
|
|
122
|
-
| ----------------------- |
|
|
123
|
-
| `auth` | Select `"auto"`, `"chatgpt"`, or `"api-key"`.
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
126
|
-
| `
|
|
127
|
-
| `
|
|
128
|
-
| `
|
|
129
|
-
| `
|
|
130
|
-
| `
|
|
131
|
-
| `
|
|
132
|
-
| `
|
|
133
|
-
| `
|
|
134
|
-
| `
|
|
121
|
+
| Option | Description |
|
|
122
|
+
| ----------------------- | ------------------------------------------------------------------------------------------ |
|
|
123
|
+
| `auth` | Select `"auto"`, `"chatgpt"`, or `"api-key"`. |
|
|
124
|
+
| `safetyIdentifier` | Stable hashed end-user ID for this scan's model requests; requires API-key authentication. |
|
|
125
|
+
| `target` | Select a repository, repository-relative paths, committed diff, or working-tree diff. |
|
|
126
|
+
| `mode` | Select `"standard"` or `"deep"`; deep mode supports repositories and paths. |
|
|
127
|
+
| `knowledgeBasePaths` | Add architecture documents, security policies, threat models, or directories. |
|
|
128
|
+
| `outputDir` | Choose an artifact directory outside the enclosing Git worktree. |
|
|
129
|
+
| `archiveExisting` | Archive results already in `outputDir` before starting a scan. |
|
|
130
|
+
| `maxCostUsd` | Stop after the estimated model cost exceeds a positive USD amount. |
|
|
131
|
+
| `maxTimeHours` | Limit deep-scan discovery to a positive number of hours, up to 96. |
|
|
132
|
+
| `failureSeverity` | Record a finding-severity policy in the saved scan recipe. |
|
|
133
|
+
| `parentScanId` | Link a rerun to an existing parent scan. |
|
|
134
|
+
| `expectedPluginVersion` | Require the original plugin version when replaying a scan. |
|
|
135
|
+
| `signal` | Cancel a scan with an `AbortSignal`. |
|
|
135
136
|
|
|
136
137
|
Progress and lifecycle callbacks are `onAuthentication`, `onCost`,
|
|
137
138
|
`onOutputArchived`, `onOutputDirReady`, `onScanStarted`,
|
|
@@ -335,6 +336,35 @@ Repeat `--knowledge-base PATH` for multiple files or directories; `bulk-scan`
|
|
|
335
336
|
shares them with every repository. Directories are searched recursively for
|
|
336
337
|
Markdown, text, PDF, and Word (`.docx`) files.
|
|
337
338
|
|
|
339
|
+
### Attribute scans to end users
|
|
340
|
+
|
|
341
|
+
For an application that serves multiple users, pass the originating user's
|
|
342
|
+
stable hashed ID on each scan:
|
|
343
|
+
|
|
344
|
+
```ts
|
|
345
|
+
await security.run("/path/to/repository", {
|
|
346
|
+
auth: "api-key",
|
|
347
|
+
safetyIdentifier: hashedUserId,
|
|
348
|
+
});
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
codex-security scan /path/to/repository --auth api-key --safety-identifier hashed-user-id
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
The ID must contain 1–64 characters and cannot be blank or contain NUL.
|
|
356
|
+
Do not use an email address or other personal data. The ID is passed to Codex
|
|
357
|
+
for the scan, nested workers, retries, and follow-up work. It is not saved in
|
|
358
|
+
shared configuration or the scan recipe. Supply it again for a later rerun.
|
|
359
|
+
Concurrent SDK clients can use different IDs without changing `process.env`.
|
|
360
|
+
|
|
361
|
+
This requires a Codex runtime with native `--safety-identifier` support and a
|
|
362
|
+
plugin that forwards it to workers. The current bundled runtime does not yet
|
|
363
|
+
support this option. Use `CODEX_CLI_PATH` to select a compatible build.
|
|
364
|
+
The SDK does not check runtime or plugin compatibility; older versions may
|
|
365
|
+
omit the identifier. Omitting the option leaves ordinary scans unchanged.
|
|
366
|
+
Preflight checks the ID's format; authentication is checked when the scan starts.
|
|
367
|
+
|
|
338
368
|
### Scan project components
|
|
339
369
|
|
|
340
370
|
`scan --path` runs one scan across the selected paths. Use `scan-components`
|
|
@@ -700,6 +730,80 @@ and scans stopped at their configured cost limit do not start another turn.
|
|
|
700
730
|
invocation and defaults to `1`. Results remain under `--output-dir`; rerun the
|
|
701
731
|
same command to resume.
|
|
702
732
|
|
|
733
|
+
### Publish multiple completed scans to Cloud
|
|
734
|
+
|
|
735
|
+
Choose completed scans from your local history:
|
|
736
|
+
|
|
737
|
+
```bash
|
|
738
|
+
npx @openai/codex-security publish scan --to cloud --dry-run --json
|
|
739
|
+
```
|
|
740
|
+
|
|
741
|
+
The picker shows each scan's repository, finding count, age, and scan ID.
|
|
742
|
+
Choose scans, then select **Done**. No scans are selected automatically.
|
|
743
|
+
|
|
744
|
+
For scripts, repeat `--scan` with saved scan IDs or unique ID prefixes (at
|
|
745
|
+
least eight characters):
|
|
746
|
+
|
|
747
|
+
```bash
|
|
748
|
+
npx @openai/codex-security publish scan \
|
|
749
|
+
--scan SCAN_ID_A --scan SCAN_ID_B \
|
|
750
|
+
--to cloud --dry-run --json
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
Use `scans list --json` to find IDs for the current repository. `--scan latest`
|
|
754
|
+
selects its latest completed scan. The CLI resolves IDs through saved history,
|
|
755
|
+
processes each selected scan once, and checks that its sealed artifacts match
|
|
756
|
+
the selected ID. The artifacts must still be available locally.
|
|
757
|
+
|
|
758
|
+
`--dry-run` validates the scans and prints their findings without uploading or
|
|
759
|
+
requiring a login. Remove `--dry-run` to upload. Live uploads require ChatGPT
|
|
760
|
+
credentials explicitly stored in a file. Set this in your Codex `config.toml`,
|
|
761
|
+
then sign in with ChatGPT again:
|
|
762
|
+
|
|
763
|
+
```toml
|
|
764
|
+
cli_auth_credentials_store = "file"
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
Automatic and keyring credential storage are not accepted for Cloud
|
|
768
|
+
publication, even when an `auth.json` file exists, because that file may be
|
|
769
|
+
stale and belong to a different account. The CLI sends one scan at a time,
|
|
770
|
+
with each scan's findings and metadata in a separate request.
|
|
771
|
+
|
|
772
|
+
For artifacts outside local history, use repeated `--scan-dir PATH` instead.
|
|
773
|
+
A single positional directory is still accepted and can be combined with
|
|
774
|
+
`--scan-dir`. Do not combine directory inputs with `--scan`. Each directory
|
|
775
|
+
must contain one completed, sealed scan; bulk-run directories and
|
|
776
|
+
`results.jsonl` files are not accepted. Relative paths start at the current
|
|
777
|
+
directory, and `~/...` starts at your home directory. Each resolved directory
|
|
778
|
+
is processed once.
|
|
779
|
+
|
|
780
|
+
For multiple distinct scans, output contains:
|
|
781
|
+
|
|
782
|
+
- `results`: receipts or dry-run previews, each with its `scanId` and `scanDir`.
|
|
783
|
+
- `failed`: errors with `scanDir` and, for saved selections, `scanId`.
|
|
784
|
+
- `notAttempted`: saved scan IDs, or paths for directory inputs, that the command
|
|
785
|
+
did not reach before cancellation.
|
|
786
|
+
|
|
787
|
+
For one distinct scan, the CLI returns the scan result directly,
|
|
788
|
+
without the batch fields above.
|
|
789
|
+
|
|
790
|
+
The CLI continues after a failed scan and exits with code `2` if any scan
|
|
791
|
+
fails. Ctrl-C or SIGTERM stops new requests and returns the results collected
|
|
792
|
+
so far. When cancellation stops work before every requested publication is
|
|
793
|
+
confirmed, the exit code is `130` for Ctrl-C and `143` for SIGTERM. If the
|
|
794
|
+
single response or final batch response has already confirmed the complete
|
|
795
|
+
publication, the command exits with code `0`. Cloud publication receipts
|
|
796
|
+
appear in command output; the CLI does not save them to scan history.
|
|
797
|
+
|
|
798
|
+
A successful receipt contains one opaque Cloud finding ID for each submitted
|
|
799
|
+
finding, in request order. These are not local finding IDs. The CLI verifies
|
|
800
|
+
the authenticated response status, count, and ID uniqueness, but cannot map
|
|
801
|
+
opaque server IDs back to individual local findings independently.
|
|
802
|
+
|
|
803
|
+
The CLI never retries an upload automatically. An upload with a missing or
|
|
804
|
+
invalid receipt may already have been accepted. Check whether Cloud accepted
|
|
805
|
+
that scan before retrying it. Do not resend scans with confirmed receipts.
|
|
806
|
+
|
|
703
807
|
### Custom validation
|
|
704
808
|
|
|
705
809
|
Use a prompt file to replace the final validation step in a standard or diff
|
|
@@ -772,17 +876,21 @@ Publish every finding from a completed standard, deep, or scoped scan to one
|
|
|
772
876
|
Linear team:
|
|
773
877
|
|
|
774
878
|
```bash
|
|
775
|
-
npx @openai/codex-security publish scan
|
|
879
|
+
npx @openai/codex-security publish scan --scan SCAN_ID \
|
|
776
880
|
--to linear \
|
|
777
881
|
--linear-team TEAM_ID
|
|
778
882
|
```
|
|
779
883
|
|
|
884
|
+
Linear accepts one scan. Use a saved scan ID, a unique ID prefix, or `latest`.
|
|
885
|
+
For external artifacts, a positional directory or `--scan-dir PATH` is also
|
|
886
|
+
accepted.
|
|
887
|
+
|
|
780
888
|
Add `--linear-project PROJECT_ID` to place the issues in a Linear project.
|
|
781
889
|
The existing `--project` flag remains an alias. Without a project, issues are
|
|
782
890
|
created directly in the selected team.
|
|
783
891
|
|
|
784
892
|
To choose from all completed scans saved in your local scan history, omit the
|
|
785
|
-
scan
|
|
893
|
+
scan selector. The selector highlights each repository and shows its finding
|
|
786
894
|
count, relative run time, and abbreviated scan ID:
|
|
787
895
|
|
|
788
896
|
```bash
|
|
@@ -995,8 +1103,9 @@ for a personal API key, or `LINEAR_ACCESS_TOKEN` for an OAuth access token.
|
|
|
995
1103
|
`LINEAR_API_KEY` is also accepted. `--linear-api-key KEY` overrides these
|
|
996
1104
|
environment settings; prefer the environment variable to keep keys out of shell
|
|
997
1105
|
history. Imported content is always literal, and issue URLs must match the
|
|
998
|
-
selected workspace.
|
|
999
|
-
|
|
1106
|
+
selected workspace. Each imported issue includes its title, description, and
|
|
1107
|
+
all comments with their source links. Linear access is read-only, and its
|
|
1108
|
+
credentials are not passed to the patch subprocess.
|
|
1000
1109
|
|
|
1001
1110
|
Use `verify-fix` to check whether an existing security fix actually closes its
|
|
1002
1111
|
original vulnerability without modifying the repository. Pass a finding
|
|
Binary file
|
|
Binary file
|
|
@@ -9,7 +9,7 @@ Perform one complete, evidence-backed security audit of the exact supplied repos
|
|
|
9
9
|
3. While the baseline runs, read `threat-model.md` once and obtain its independent architecture review within the available worker allowance. Verify its resource rows against their actual consumers, use the returned canonical `threatModel` as the generated model, and build source-backed investigation packets from it. Carry that object and its evidence into the final result instead of reconstructing a shorter summary. Preserve any user-supplied threat model unchanged as the authoritative security assumptions; map its real surfaces and controls without replacing it.
|
|
10
10
|
4. Group related source-backed security questions into investigation packets. Each group shares its plausible attacker, protected asset, entry points, expected controls, sensitive operations, component relationships, and actual repository-relative source anchors. Keep each question concrete, preserve distinct attacker boundaries and security mechanisms, and let investigators establish the detailed dataflow.
|
|
11
11
|
5. Launch focused investigator subagents with `fork_turns: "none"` as soon as useful packet groups exist. Choose their number and assignments from the amount, complexity, and independence of source-backed work, bounded by the supplied available subagent allowance; use fewer for related packets and more only when distinct surfaces justify them. Keep mapping other surfaces while they run. Send each only its focused-investigator prompt below, assigned packets, investigator perspective, repository path, authorized scope, any supplied scoped-source inventory, exact user context, supplied threat model, applicable packet-specific security guidance and its resolver command, the optional authoritative knowledge-base location, and verified search command. Do not include this reference or another worker's prompt. Supporting code may be outside a requested path, but an affected entry point, control, or operation must be in scope.
|
|
12
|
-
6. Reconcile source coverage before combining findings. Union only the baseline and focused investigators' `fully_reviewed_files` with files the parent fully security-audited, then intersect that set with the supplied authorized inventory or an inventory of the selected current scope. Architecture mapping alone and supporting files outside that inventory do not count toward completed audit coverage. Finish the remaining in-scope files in coherent groups, reusing available investigators within the same allowance. Inspect implementation-owning generated or compressed code as data. Do not add overlapping worker counts or claim that a search hit completed a file. Keep this one transient set; do not create a separate progress ledger or receipt format. If a user limit or unavailable source prevents completion, identify the actual remaining paths and report partial coverage. Then combine baseline and investigator findings once. Group observations only when they share the same broken security control and effective remediation; preserve every affected route, operation, sink, and supporting source location. Never merge different security failures solely because they share a CWE.
|
|
12
|
+
6. Before combining or revalidating any returned baseline or investigator result, persist it through the caller's bound `record_codex_security_scan_draft` tool when available, using `complete: false` and partial coverage. Give each candidate a stable `candidateId`; put candidates awaiting parent validation in `coverage.deferred` with a meaningful reason and their original finding payload under `candidate`. Preserve returned counterevidence and unresolved questions too. Checkpoint again after each validation decision, without waiting for other workers or the final report. Put source-validated findings in `findings` with the same `provenance.candidateId`; for a rejection, retain the candidate ID, original evidence, and source-backed counterevidence on a `rejected` coverage surface. An unfinished scan must retain its saved findings and pending candidates without presenting pending work as validated. Reconcile source coverage before combining findings. Union only the baseline and focused investigators' `fully_reviewed_files` with files the parent fully security-audited, then intersect that set with the supplied authorized inventory or an inventory of the selected current scope. Architecture mapping alone and supporting files outside that inventory do not count toward completed audit coverage. Finish the remaining in-scope files in coherent groups, reusing available investigators within the same allowance. Inspect implementation-owning generated or compressed code as data. Do not add overlapping worker counts or claim that a search hit completed a file. Keep this one transient set; do not create a separate progress ledger or receipt format. If a user limit or unavailable source prevents completion, identify the actual remaining paths and report partial coverage. Then combine baseline and investigator findings once. Group observations only when they share the same broken security control and effective remediation; preserve every affected route, operation, sink, and supporting source location. Never merge different security failures solely because they share a CWE.
|
|
13
13
|
7. Independently validate each unique finding against local source once. Establish its attacker, entry point, trust boundary, attacker-controlled dataflow, transformations, broken control, sensitive operation, prerequisites, effective mitigations, strongest counterevidence, and concrete impact. Record concise, source-backed `rootCause.summary`, `validation.summary`, `attackPath.dataflow.summary`, and `attackPath.reachability.summary` alongside their supporting facts; determine impact, likelihood, and severity from those established facts. State optional configuration, dependency-version, or deployment prerequisites; do not require proof of a real deployment or runtime reproduction. A public library or parser boundary is sufficient when callers control the input. Reject only with source-backed counterevidence, preserve valid baseline findings, record material unresolved proof gaps, and apply the severity rules below.
|
|
14
14
|
8. Assemble complete semantic `scope`, `threatModel`, `findings`, and `coverage` using the plugin's `examples/completed-scan/` and `schemas/` as shape references, never as values to copy. Use the canonical field mapping and scenario reconciliation in `threat-model.md`, preserving supplied models unchanged and retaining source-backed architecture, capability, deployment, and uncertainty facts. Give each finding a stable lowercase vulnerability-family `ruleId`, its precise `taxonomy.category` and `taxonomy.cwe` values, genuine `provenance.source`, an instance when separately reported findings would otherwise collide, a `root_control` location when identifiable, all materially affected locations, calibrated severity and rationale, confidence and rationale, verified nonempty source evidence, attacker-to-sink reachability, and practical remediation. Use actual coverage surface labels and dispositions; report reviewed surfaces, explicit exclusions, deferred work, and unresolved questions honestly, and mark coverage `complete` only when the requested source scope was actually reviewed. Preserve every genuine finding, evidence item, user-supplied assumption, and unresolved proof gap in the caller's complete semantic result.
|
|
15
15
|
|
|
@@ -22,13 +22,15 @@ For each finding, supply an evidence-supported lowercase vulnerability-family `r
|
|
|
22
22
|
|
|
23
23
|
Supply semantic coverage as `{ completeness, surfaces, explicitExclusions, deferred }`, with each surface using the actual `label` and one existing `disposition`. Mark coverage `partial` when a deferred item or `needs_follow_up` surface remains; preserve its real reason and supporting context. Each deferred item needs a meaningful reason; preserve any existing `id` or `candidateId`. The workbench derives a missing ID from its candidate identity or stable deferred-work details. Open questions may be nonempty strings or `{ question, followUpPrompt? }` objects. The workbench derives target and scope metadata, scope include and exclude paths, coverage mode and inventory strategy, finding identities and fingerprints, and surface IDs. Do not put those workbench-owned values or top-level coverage receipt references into the semantic draft.
|
|
24
24
|
|
|
25
|
-
After a workbench-owned Standard or workbench-backed diff draft is accepted, or the Deep coordinator returns its parent scan's canonical manifest, call `complete_codex_security_scan({ scanId, handoffClaimToken? })` and use its returned completion metadata. An SDK-owned scan returns its unsealed canonical files without calling a completion tool or finalizer; the SDK owns completion and report generation. Read full canonical results only when explicitly requested. For a terminal/chat workflow without a `scanId` or completion tool, retain `python <plugin_dir>/scripts/finalize_scan_contract.py --scan-dir <scan_dir> --source-root <repo_root>` after writing the canonical JSON. Outside the SDK path, do not mark the scan goal complete until finalization succeeds and the generated report exists.
|
|
25
|
+
During a host-backed scan, checkpoint saved findings and pending candidates with `complete: false`; a checkpoint is not a completed audit. After a final workbench-owned Standard or workbench-backed diff draft is accepted with `complete: true` (or the backwards-compatible omitted flag), or the Deep coordinator returns its parent scan's canonical manifest, call `complete_codex_security_scan({ scanId, handoffClaimToken? })` and use its returned completion metadata. An SDK-owned scan returns its unsealed canonical files without calling a completion tool or finalizer; the SDK owns completion and report generation. Read full canonical results only when explicitly requested. For a terminal/chat workflow without a `scanId` or completion tool, retain `python <plugin_dir>/scripts/finalize_scan_contract.py --scan-dir <scan_dir> --source-root <repo_root>` after writing the canonical JSON. Outside the SDK path, do not mark the scan goal complete until finalization succeeds and the generated report exists.
|
|
26
|
+
|
|
27
|
+
On a confirmed failure or explicit cancellation, the workbench preserves saved results without marking the scan successful. Report validated findings separately from pending candidates and explain the incomplete coverage. Use the retained report and exports; do not start additional model work after cancellation or replace saved results with a no-findings response.
|
|
26
28
|
|
|
27
29
|
After `complete_codex_security_scan` succeeds, include its returned `usage.totalTokens`, `usage.inputTokens`, and `usage.cachedInputTokens` in the final response when `usage.coverage` is `complete` or `partial`; explicitly label a partial measurement. If coverage is `unavailable`, say that token usage could not be measured instead of reporting zero or estimating a cost. Report only measured completion metadata in a terminal/chat host. Token usage is workbench metadata, not a reason to modify sealed scan artifacts or the deterministic report.
|
|
28
30
|
|
|
29
31
|
Before workbench-owned Standard or workbench-backed diff completion, require `record_codex_security_scan_draft` to succeed. Before Deep completion, require the coordinator to return the parent scan's already-authored canonical manifest; do not submit another draft or rerun worker phases. SDK-owned Standard and terminal diff workflows instead verify their canonical JSON before the appropriate owner finalizes it. Completion validates and seals existing canonical artifacts and generates `report.md`; it does not create missing artifacts or run skipped scan phases.
|
|
30
32
|
|
|
31
|
-
An MCP `-32602` input rejection, an `isError: true` result reporting `Input validation error`, or an explicit pre-write rejection of complete coverage containing deferred work or a follow-up surface makes no draft write. Correct only the named paths in the same draft, preserving all valid findings, fields, evidence, and deferred work; retry the same scan at most twice. Stop after the first accepted draft. Do not blindly retry an ambiguous transport or write failure.
|
|
33
|
+
An MCP `-32602` input rejection, an `isError: true` result reporting `Input validation error`, or an explicit pre-write rejection of complete coverage containing deferred work or a follow-up surface makes no draft write. Correct only the named paths in the same draft, preserving all valid findings, fields, evidence, and deferred work; retry the same scan at most twice. Stop final submission after the first accepted complete draft; an accepted complete:false checkpoint does not end the audit. Do not blindly retry an ambiguous transport or write failure.
|
|
32
34
|
|
|
33
35
|
For any other required scan phase, canonical-artifact write, or on-disk existence check that fails before completion, stop the current response and surface the exact workflow blocker. Do not call completion with missing artifacts, return a final report or no-findings result, or satisfy a structured output schema. Leave the durable scan available for a later continuation instead of canceling or failing it solely because canonical assembly is blocked.
|
|
34
36
|
|
|
@@ -40,7 +40,7 @@ End each repository-scoped threat model with these two lines:
|
|
|
40
40
|
|
|
41
41
|
### Compact Deep And Workbench-Backed Diff Discovery
|
|
42
42
|
|
|
43
|
-
Workbench-owned Standard scans submit findings and coverage through `record_codex_security_scan_draft`; SDK-owned Standard scans write unsealed canonical files directly. Deep scans run complete Standard scan workers, each of which submits its validated findings, coverage, threat model, and optional scope through its bound `record_codex_security_scan_draft` tool. The coordinator semantically reduces those complete results and writes the parent scan's unsealed `scan-manifest.json`, `findings.json`, and `coverage.json`. The parent does not list candidates, rerun validation or attack-path phases, or submit another draft. Workbench-backed diff scans retain the compact artifacts described below.
|
|
43
|
+
Workbench-owned Standard scans submit findings and coverage through `record_codex_security_scan_draft`; SDK-owned Standard scans write unsealed canonical files directly. Deep scans run complete Standard scan workers, each of which saves `complete: false` checkpoints and submits its final validated findings, coverage, threat model, and optional scope through its bound `record_codex_security_scan_draft` tool. Pending candidates retain their original evidence in `coverage.deferred`. Host-owned immutable checkpoints survive retries, cancellation, and failure; a checkpoint alone is never an accepted complete worker result. The coordinator semantically reduces those complete results and writes the parent scan's unsealed `scan-manifest.json`, `findings.json`, and `coverage.json`. The parent does not list candidates, rerun validation or attack-path phases, or submit another draft. Workbench-backed diff scans retain the compact artifacts described below.
|
|
44
44
|
|
|
45
45
|
- A workbench-backed diff scan records all candidates once with `record_codex_security_discovery_candidates({ scanId, candidates })` and reads the canonical candidates with `list_codex_security_candidates({ scanId, cursor?, limit? })`.
|
|
46
46
|
- The writer validates candidates against assigned source paths, merges rows with the same CWE ids, locations, and optional instance, preserves their text, and assigns deterministic `candidate_id` values.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Sealed Scan Contract
|
|
2
2
|
|
|
3
|
-
This contract defines the canonical machine-readable documents for
|
|
3
|
+
This contract defines the canonical machine-readable documents for scans that reached a sealed terminal outcome and their readable markdown report projection.
|
|
4
4
|
|
|
5
5
|
## Canonical Documents
|
|
6
6
|
|
|
7
|
-
A
|
|
7
|
+
A sealed terminal bundle contains these files under `<scan_dir>`:
|
|
8
8
|
|
|
9
|
-
- `scan-manifest.json`: immutable
|
|
10
|
-
- `findings.json`: semantic finding records
|
|
9
|
+
- `scan-manifest.json`: immutable terminal scan receipt after finalization
|
|
10
|
+
- `findings.json`: semantic finding records retained when the scan reached its terminal outcome
|
|
11
11
|
- `coverage.json`: structured coverage summary with detailed receipt references
|
|
12
12
|
|
|
13
13
|
Canonical UTF-8 document sizes are bounded consistently by the producer and SDK: `scan-manifest.json` is limited to 16 MiB, `findings.json` to 128 MiB, and `coverage.json` to 32 MiB. Finalization rejects oversized inputs or generated documents before sealing or changing scan outputs. Keep detailed evidence in scan-local artifacts and reference it from the canonical summaries.
|
|
@@ -20,11 +20,22 @@ Deep-scan SARIF results and CSV rows preserve their existing instance-level pres
|
|
|
20
20
|
|
|
21
21
|
This bundle records immutable scan observations. It is not a workflow-state database. Consumers must store mutable annotations, lifecycle decisions, external links, retention policy, and synchronization state separately.
|
|
22
22
|
|
|
23
|
-
Retention is an explicit consumer decision. Producing a
|
|
23
|
+
Retention is an explicit consumer decision. Producing a sealed bundle must not silently copy it into an archive.
|
|
24
24
|
|
|
25
25
|
## Manifest Semantics
|
|
26
26
|
|
|
27
|
-
A sealed manifest records the
|
|
27
|
+
A sealed manifest records the terminal timestamp and hashes for the canonical documents and immutable evidence receipts included in that bundle. Readable reports and generated exports are projections and are not included in the canonical seal. Later adapters may read the sealed bundle to create projections, but must not mutate the sealed manifest or canonical documents. Store projections separately. Every sealed manifest includes exactly one artifact record for each canonical JSON document, and artifact paths must not repeat.
|
|
28
|
+
|
|
29
|
+
`scan.status` records why the bundle was sealed:
|
|
30
|
+
|
|
31
|
+
| Status | Meaning |
|
|
32
|
+
| --- | --- |
|
|
33
|
+
| `completed` | The requested scan reached normal completion. |
|
|
34
|
+
| `failed` | The scan stopped after an unrecoverable failure; retained artifacts may be partial. |
|
|
35
|
+
| `canceled` | The scan stopped after an explicit cancellation; retained artifacts may be partial. |
|
|
36
|
+
| `interrupted` | The scan stopped before normal completion because execution was interrupted; retained artifacts may be partial. |
|
|
37
|
+
|
|
38
|
+
Only `completed` supports a completed-scan conclusion. For every stopped outcome, consumers must preserve retained findings and coverage while treating absence of findings as inconclusive.
|
|
28
39
|
|
|
29
40
|
## Target Snapshots
|
|
30
41
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://openai.com/codex-security/schemas/scan-manifest.schema.json",
|
|
4
|
-
"title": "Codex Security
|
|
4
|
+
"title": "Codex Security sealed scan manifest",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"required": [
|
|
7
7
|
"documentType",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"status": {
|
|
56
|
-
"
|
|
56
|
+
"enum": ["completed", "failed", "canceled", "interrupted"]
|
|
57
57
|
},
|
|
58
58
|
"startedAt": {
|
|
59
59
|
"type": "string",
|
|
@@ -574,6 +574,25 @@
|
|
|
574
574
|
"provenance": {
|
|
575
575
|
"type": "object",
|
|
576
576
|
"properties": {
|
|
577
|
+
"sourceFindingIds": {
|
|
578
|
+
"type": "array",
|
|
579
|
+
"items": { "$ref": "#/$defs/text" },
|
|
580
|
+
"uniqueItems": true,
|
|
581
|
+
"description": "Host-provided source finding references represented by this Deep reduction. Preserve every assigned reference exactly once."
|
|
582
|
+
},
|
|
583
|
+
"sourceFindings": {
|
|
584
|
+
"type": "array",
|
|
585
|
+
"items": {
|
|
586
|
+
"type": "object",
|
|
587
|
+
"properties": {
|
|
588
|
+
"id": { "$ref": "#/$defs/text" },
|
|
589
|
+
"finding": { "type": "object", "additionalProperties": true }
|
|
590
|
+
},
|
|
591
|
+
"required": ["id", "finding"],
|
|
592
|
+
"additionalProperties": false
|
|
593
|
+
},
|
|
594
|
+
"description": "Original source payloads retained by the host for lossless semantic merges."
|
|
595
|
+
},
|
|
577
596
|
"source": {
|
|
578
597
|
"$ref": "#/$defs/text",
|
|
579
598
|
"description": "The actual finding producer. Use local_plugin only for a finding discovered by this plugin."
|
|
@@ -805,6 +824,10 @@
|
|
|
805
824
|
"scanDraftInput": {
|
|
806
825
|
"type": "object",
|
|
807
826
|
"properties": {
|
|
827
|
+
"complete": {
|
|
828
|
+
"type": "boolean",
|
|
829
|
+
"description": "Set false to save progress without declaring this worker or parent audit finished. Omit or set true only for the terminal result. Put provisional candidates in coverage.deferred, not findings."
|
|
830
|
+
},
|
|
808
831
|
"scanId": {
|
|
809
832
|
"$ref": "#/$defs/scanId"
|
|
810
833
|
},
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import argparse
|
|
6
|
+
import hashlib
|
|
6
7
|
import json
|
|
7
8
|
import os
|
|
8
9
|
import shutil
|
|
@@ -39,6 +40,8 @@ DEEP_SCAN_TERMINAL_REASONS = ("saturated", "capped")
|
|
|
39
40
|
DEEP_SCAN_WORKFLOW_VERSION = "deep-security-scan/v1"
|
|
40
41
|
DEEP_SCAN_COORDINATOR_LEASE_SECONDS = 30
|
|
41
42
|
DEEP_SCAN_LEGACY_COORDINATOR_GRACE_SECONDS = 120
|
|
43
|
+
DEEP_SCAN_MAX_ERROR_LENGTH = 2400
|
|
44
|
+
DEEP_SCAN_PUBLICATION_ERROR_SEPARATOR = "\nOriginal Deep Scan failure:\n"
|
|
42
45
|
|
|
43
46
|
|
|
44
47
|
def register_subcommands(subparsers: Any, positive_int: Callable[[str], int]) -> None:
|
|
@@ -120,6 +123,11 @@ def register_subcommands(subparsers: Any, positive_int: Callable[[str], int]) ->
|
|
|
120
123
|
)
|
|
121
124
|
fail_deep_scan.add_argument("--coordinator-generation", type=positive_int)
|
|
122
125
|
|
|
126
|
+
publication_failure = subparsers.add_parser("record-deep-scan-publication-failure")
|
|
127
|
+
publication_failure.add_argument("--scan-id", required=True)
|
|
128
|
+
publication_failure.add_argument("--message", required=True)
|
|
129
|
+
publication_failure.add_argument("--coordinator-generation", type=positive_int)
|
|
130
|
+
|
|
123
131
|
|
|
124
132
|
def non_negative_int(value: str) -> int:
|
|
125
133
|
parsed = int(value)
|
|
@@ -143,6 +151,7 @@ class DeepScanDependencies:
|
|
|
143
151
|
safe_segment: Callable[[str], str]
|
|
144
152
|
compact_timestamp: Callable[[], str]
|
|
145
153
|
scan_completion_lock: Callable[[str], Any]
|
|
154
|
+
preserve_stopped_results: Callable[[sqlite3.Connection, str], None]
|
|
146
155
|
|
|
147
156
|
|
|
148
157
|
_dependencies: DeepScanDependencies | None = None
|
|
@@ -163,6 +172,34 @@ def now() -> str:
|
|
|
163
172
|
return dependencies().now()
|
|
164
173
|
|
|
165
174
|
|
|
175
|
+
def _bounded_error_text(message: str, maximum: int) -> str:
|
|
176
|
+
if len(message) <= maximum:
|
|
177
|
+
return message
|
|
178
|
+
digest = hashlib.sha256(message.encode()).hexdigest()
|
|
179
|
+
suffix = f"\n...[truncated; sha256:{digest}]"
|
|
180
|
+
if len(suffix) >= maximum:
|
|
181
|
+
return message[:maximum]
|
|
182
|
+
return f"{message[: maximum - len(suffix)]}{suffix}"
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def deep_scan_error(run: sqlite3.Row) -> str | None:
|
|
186
|
+
original = run["error_message"]
|
|
187
|
+
publication = run["publication_error_message"]
|
|
188
|
+
if not isinstance(publication, str):
|
|
189
|
+
return original if isinstance(original, str) else None
|
|
190
|
+
if not isinstance(original, str):
|
|
191
|
+
return publication
|
|
192
|
+
available = DEEP_SCAN_MAX_ERROR_LENGTH - len(DEEP_SCAN_PUBLICATION_ERROR_SEPARATOR)
|
|
193
|
+
publication_budget = min(len(publication), available // 2)
|
|
194
|
+
original_budget = min(len(original), available - publication_budget)
|
|
195
|
+
publication_budget = min(len(publication), available - original_budget)
|
|
196
|
+
return (
|
|
197
|
+
_bounded_error_text(publication, publication_budget)
|
|
198
|
+
+ DEEP_SCAN_PUBLICATION_ERROR_SEPARATOR
|
|
199
|
+
+ _bounded_error_text(original, original_budget)
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
|
|
166
203
|
def _parse_timestamp(value: str) -> datetime:
|
|
167
204
|
if isinstance(value, str) and value.endswith(("Z", "z")):
|
|
168
205
|
value = value[:-1] + "+00:00"
|
|
@@ -439,7 +476,7 @@ def deep_scan_state(connection: sqlite3.Connection, scan_id: str) -> dict[str, A
|
|
|
439
476
|
"canonicalArtifacts": canonical_artifacts,
|
|
440
477
|
"manifestPath": run["manifest_path"],
|
|
441
478
|
"terminalReason": run["terminal_reason"],
|
|
442
|
-
"error": run
|
|
479
|
+
"error": deep_scan_error(run),
|
|
443
480
|
"createdAt": run["created_at"],
|
|
444
481
|
"updatedAt": run["updated_at"],
|
|
445
482
|
"completedAt": run["completed_at"],
|
|
@@ -2022,9 +2059,59 @@ def fail_deep_scan_locked(
|
|
|
2022
2059
|
raise
|
|
2023
2060
|
if promotion is not None:
|
|
2024
2061
|
finish_staged_file(promotion)
|
|
2062
|
+
dependencies().preserve_stopped_results(connection, scan_id)
|
|
2063
|
+
return deep_scan_result(connection, scan_id)
|
|
2064
|
+
|
|
2065
|
+
|
|
2066
|
+
def record_deep_scan_publication_failure(
|
|
2067
|
+
connection: sqlite3.Connection, args: argparse.Namespace
|
|
2068
|
+
) -> dict[str, Any]:
|
|
2069
|
+
scan_id = require_uuid(args.scan_id, "scan-id")
|
|
2070
|
+
message = optional_text(args.message, maximum=2400)
|
|
2071
|
+
if message is None:
|
|
2072
|
+
raise SystemExit("message is required.")
|
|
2073
|
+
with scan_completion_lock(scan_id):
|
|
2074
|
+
connection.execute("BEGIN IMMEDIATE")
|
|
2075
|
+
try:
|
|
2076
|
+
run = require_deep_scan_run(connection, scan_id)
|
|
2077
|
+
require_current_coordinator(run, args)
|
|
2078
|
+
scan = require_scan(connection, scan_id)
|
|
2079
|
+
if (
|
|
2080
|
+
run["status"] not in {"failed", "canceled", "interrupted"}
|
|
2081
|
+
or scan["status"] != "failed"
|
|
2082
|
+
):
|
|
2083
|
+
raise SystemExit(
|
|
2084
|
+
"Saved result publication failures can only update a stopped Deep Scan."
|
|
2085
|
+
)
|
|
2086
|
+
if scan["seal_manifest_digest"] is not None:
|
|
2087
|
+
connection.commit()
|
|
2088
|
+
return deep_scan_result(connection, scan_id)
|
|
2089
|
+
if run["publication_error_message"] != message:
|
|
2090
|
+
timestamp = now()
|
|
2091
|
+
connection.execute(
|
|
2092
|
+
"""
|
|
2093
|
+
UPDATE deep_scan_runs
|
|
2094
|
+
SET publication_error_message = ?, updated_at = ?
|
|
2095
|
+
WHERE scan_id = ?
|
|
2096
|
+
""",
|
|
2097
|
+
(message, timestamp, scan_id),
|
|
2098
|
+
)
|
|
2099
|
+
connection.commit()
|
|
2100
|
+
except BaseException:
|
|
2101
|
+
connection.rollback()
|
|
2102
|
+
raise
|
|
2025
2103
|
return deep_scan_result(connection, scan_id)
|
|
2026
2104
|
|
|
2027
2105
|
|
|
2106
|
+
def clear_deep_scan_publication_failure(connection: sqlite3.Connection, scan_id: str) -> None:
|
|
2107
|
+
with connection:
|
|
2108
|
+
connection.execute(
|
|
2109
|
+
"UPDATE deep_scan_runs SET publication_error_message = NULL, updated_at = ? "
|
|
2110
|
+
"WHERE scan_id = ? AND publication_error_message IS NOT NULL",
|
|
2111
|
+
(now(), scan_id),
|
|
2112
|
+
)
|
|
2113
|
+
|
|
2114
|
+
|
|
2028
2115
|
def fail_from_parent_scan(
|
|
2029
2116
|
connection: sqlite3.Connection,
|
|
2030
2117
|
scan_id: str,
|