@openai/codex-security 0.6.0 → 0.7.0
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 +68 -37
- package/_bundled_plugin/.mcp.json +1 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +1 -1
- package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -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/mcp/server.mjs.br.part-002 +0 -0
- package/_bundled_plugin/references/access-advisory.md +11 -0
- package/_bundled_plugin/references/core-scan.md +30 -77
- package/_bundled_plugin/references/final-report.md +45 -189
- package/_bundled_plugin/references/scan-contract.md +2 -0
- package/_bundled_plugin/references/scan-prologue.md +1 -1
- package/_bundled_plugin/references/scan-runtime.md +1 -5
- package/_bundled_plugin/references/threat-model.md +33 -41
- package/_bundled_plugin/schemas/coverage.schema.json +12 -1
- package/_bundled_plugin/schemas/scan-manifest.schema.json +1 -0
- package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +38 -1
- package/_bundled_plugin/scripts/deep_scan_config.py +39 -39
- package/_bundled_plugin/scripts/deep_scan_workbench.py +145 -85
- package/_bundled_plugin/scripts/finalize_scan_contract.py +189 -57
- package/_bundled_plugin/scripts/report_projection.py +44 -15
- package/_bundled_plugin/scripts/threat_model_projection.py +4 -2
- package/_bundled_plugin/scripts/windows_scan_local_files.py +43 -14
- package/_bundled_plugin/scripts/workbench/retained_coverage.py +3218 -0
- package/_bundled_plugin/scripts/workbench/retained_records.py +627 -0
- package/_bundled_plugin/scripts/workbench/saved_coverage.py +644 -1
- package/_bundled_plugin/scripts/workbench/saved_outputs.py +72 -0
- package/_bundled_plugin/scripts/workbench/saved_sources.py +712 -0
- package/_bundled_plugin/scripts/workbench_cli.py +3 -0
- package/_bundled_plugin/scripts/workbench_coverage_receipts.py +479 -0
- package/_bundled_plugin/scripts/workbench_db.py +51 -22
- package/_bundled_plugin/scripts/workbench_feedback.py +0 -1
- package/_bundled_plugin/scripts/workbench_finding_workflows.py +51 -9
- package/_bundled_plugin/scripts/workbench_native_indexes.py +56 -44
- package/_bundled_plugin/scripts/workbench_saved_results.py +641 -2387
- package/_bundled_plugin/scripts/workbench_scan_history.py +72 -7
- package/_bundled_plugin/scripts/workbench_schema.py +1 -1
- package/_bundled_plugin/scripts/workbench_source_scopes.py +4 -1
- package/_bundled_plugin/scripts/workbench_target.py +142 -17
- package/_bundled_plugin/scripts/workbench_validation.py +9 -2
- package/_bundled_plugin/shared/workbench-history-repairs.json +21 -0
- package/_bundled_plugin/shared/workbench-migrations.json +28 -0
- package/_bundled_plugin/skills/assess-patch-risk/SKILL.md +3 -14
- package/_bundled_plugin/skills/assess-patch-risk/references/windows-validation.md +14 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +38 -103
- package/_bundled_plugin/skills/attack-path-analysis/references/attack-path-facts.md +11 -73
- package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +57 -116
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +28 -51
- package/_bundled_plugin/skills/define-security-policy/SKILL.md +9 -9
- package/_bundled_plugin/skills/finding-discovery/SKILL.md +26 -140
- package/_bundled_plugin/skills/fix-finding/SKILL.md +9 -28
- package/_bundled_plugin/skills/propose-security-hardening/SKILL.md +28 -218
- package/_bundled_plugin/skills/propose-security-hardening/references/proposal-format.md +29 -424
- package/_bundled_plugin/skills/publish-findings/SKILL.md +28 -24
- package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +64 -0
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +12 -12
- package/_bundled_plugin/skills/security-scan/SKILL.md +28 -16
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +11 -17
- package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +52 -69
- package/_bundled_plugin/skills/threat-model/SKILL.md +16 -9
- package/_bundled_plugin/skills/triage-finding/SKILL.md +5 -15
- package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +6 -6
- package/_bundled_plugin/skills/validation/SKILL.md +42 -104
- package/_bundled_plugin/skills/validation/references/validation-guidance.md +21 -106
- package/_bundled_plugin/skills/verify-fix/SKILL.md +4 -2
- package/_bundled_plugin/skills/vulnerability-writeup/SKILL.md +21 -159
- package/_bundled_plugin/skills/vulnerability-writeup/references/report-format.md +18 -60
- package/dist/api.d.ts +5 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +341 -37
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +4 -1
- package/dist/auth.js.map +1 -1
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +674 -419
- package/dist/cli.js.map +1 -1
- package/dist/component-scan.d.ts +8 -2
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +2 -0
- package/dist/component-scan.js.map +1 -1
- package/dist/contract.d.ts +2 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +67 -33
- package/dist/contract.js.map +1 -1
- package/dist/cost.d.ts +18 -0
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +107 -12
- package/dist/cost.js.map +1 -1
- package/dist/coverage-presentation.d.ts +6 -0
- package/dist/coverage-presentation.d.ts.map +1 -0
- package/dist/coverage-presentation.js +34 -0
- package/dist/coverage-presentation.js.map +1 -0
- package/dist/custom-validation-prompt.js +3 -3
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +30 -4
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/checkpointed-review.d.ts.map +1 -1
- package/dist/deduplication/checkpointed-review.js +3 -1
- package/dist/deduplication/checkpointed-review.js.map +1 -1
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +7 -5
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/endor-findings.d.ts +4 -3
- package/dist/endor-findings.d.ts.map +1 -1
- package/dist/endor-findings.js +16 -11
- package/dist/endor-findings.js.map +1 -1
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +13 -5
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +8 -1
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +1 -1
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +11 -3
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +11 -1
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +15 -6
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-import-contract.d.ts +3 -1
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +33 -25
- package/dist/external-import-contract.js.map +1 -1
- package/dist/external-imports-feature.d.ts +6 -0
- package/dist/external-imports-feature.d.ts.map +1 -0
- package/dist/external-imports-feature.js +51 -0
- package/dist/external-imports-feature.js.map +1 -0
- package/dist/finding-workflow.d.ts +22 -5
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js +21 -9
- package/dist/finding-workflow.js.map +1 -1
- package/dist/github-advisories.d.ts.map +1 -1
- package/dist/github-advisories.js +3 -1
- package/dist/github-advisories.js.map +1 -1
- package/dist/github-findings.d.ts +4 -3
- package/dist/github-findings.d.ts.map +1 -1
- package/dist/github-findings.js +16 -14
- package/dist/github-findings.js.map +1 -1
- package/dist/hosted-remediation.d.ts.map +1 -1
- package/dist/hosted-remediation.js +19 -2
- package/dist/hosted-remediation.js.map +1 -1
- package/dist/hosted-scan.d.ts +1 -1
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +0 -5
- package/dist/hosted-scan.js.map +1 -1
- package/dist/import-scan.js +1 -1
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.d.ts +1 -0
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +17 -8
- package/dist/knowledge-base.js.map +1 -1
- package/dist/models.d.ts +1 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/owner-evidence.d.ts +2 -0
- package/dist/owner-evidence.d.ts.map +1 -1
- package/dist/owner-evidence.js +2 -1
- package/dist/owner-evidence.js.map +1 -1
- package/dist/publish.d.ts +2 -0
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +1 -1
- package/dist/publish.js.map +1 -1
- package/dist/remediation.d.ts +1 -25
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +3 -24
- package/dist/remediation.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +7 -7
- package/dist/runtime.js.map +1 -1
- package/dist/scan-dashboard.d.ts +5 -3
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +79 -26
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +8 -2
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-owner-suggestions.d.ts +1 -1
- package/dist/scan-owner-suggestions.d.ts.map +1 -1
- package/dist/scan-owner-suggestions.js +4 -4
- package/dist/scan-owner-suggestions.js.map +1 -1
- package/dist/scan-usage-display.d.ts +8 -0
- package/dist/scan-usage-display.d.ts.map +1 -0
- package/dist/scan-usage-display.js +46 -0
- package/dist/scan-usage-display.js.map +1 -0
- package/dist/scanner-import.d.ts +1 -1
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +7 -3
- package/dist/scanner-import.js.map +1 -1
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js +1 -20
- package/dist/security-policy.js.map +1 -1
- package/dist/semgrep-findings.d.ts +4 -3
- package/dist/semgrep-findings.d.ts.map +1 -1
- package/dist/semgrep-findings.js +9 -9
- package/dist/semgrep-findings.js.map +1 -1
- package/dist/skill-authentication.d.ts +18 -0
- package/dist/skill-authentication.d.ts.map +1 -0
- package/dist/skill-authentication.js +82 -0
- package/dist/skill-authentication.js.map +1 -0
- package/dist/snyk-findings.d.ts +5 -4
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +18 -17
- package/dist/snyk-findings.js.map +1 -1
- package/dist/suggest-owners.d.ts +4 -1
- package/dist/suggest-owners.d.ts.map +1 -1
- package/dist/suggest-owners.js +53 -21
- package/dist/suggest-owners.js.map +1 -1
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +4 -1
- package/dist/targets.js.map +1 -1
- package/dist/wiz-csv.d.ts +2 -1
- package/dist/wiz-csv.d.ts.map +1 -1
- package/dist/wiz-csv.js +3 -3
- package/dist/wiz-csv.js.map +1 -1
- package/dist/wiz-findings.d.ts +2 -1
- package/dist/wiz-findings.d.ts.map +1 -1
- package/dist/wiz-findings.js +27 -23
- package/dist/wiz-findings.js.map +1 -1
- package/docs/classify-severity-records.md +3 -4
- package/docs/cli.md +155 -38
- package/docs/findings-service.md +119 -118
- package/docs/hosted-remediation.md +19 -17
- package/docs/hosted-scans.md +37 -11
- package/package.json +8 -8
- package/_bundled_plugin/scripts/generate_in_scope_files.py +0 -277
- package/_bundled_plugin/scripts/generate_rank_input.py +0 -350
- package/_bundled_plugin/scripts/rank_preview.py +0 -129
|
@@ -78,22 +78,22 @@ result validation finished; it does not imply that a patch fixed the finding:
|
|
|
78
78
|
require a reason. The host must inspect the actual changes, collect the
|
|
79
79
|
canonical diff, and run separate verification.
|
|
80
80
|
- `verification` contains `id`, `status` (`fixed`, `still_vulnerable`, or
|
|
81
|
-
`inconclusive`), nonempty `evidence`,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
81
|
+
`inconclusive`), and nonempty `evidence`, the same fields used by local
|
|
82
|
+
`verify-fix`. The finding ID must match the request. A `fixed` verdict needs
|
|
83
|
+
evidence that the original exploit path is closed and legitimate behavior
|
|
84
|
+
still works. If the selected mode cannot establish that, use `inconclusive`
|
|
85
|
+
unless the evidence shows the finding is still vulnerable.
|
|
86
|
+
|
|
87
|
+
Hosted and local verification use the same verdict parser and do not require
|
|
88
|
+
`checks`. At the hosted boundary, a `fixed` verdict is rejected if a nonempty
|
|
89
|
+
`checks` array matches the SDK 0.6.0 check format and reports a `failed` or
|
|
90
|
+
`not_run` required check. Other extra fields are ignored.
|
|
91
|
+
|
|
92
|
+
When upgrading from SDK 0.6.0, remove imports of `FindingVerificationCheck`
|
|
93
|
+
and read `verification.status` and `verification.evidence`. The SDK no longer
|
|
94
|
+
returns `verification.checks`. The executor's original report, when supplied,
|
|
95
|
+
remains in `execution.finalResponse`. Invalid or contradictory verdicts return
|
|
96
|
+
`INVALID_RESULT` with the execution receipt.
|
|
97
97
|
|
|
98
98
|
The host owns durable attempts, cancellation/reconciliation, usage, artifact
|
|
99
99
|
storage and publication. No operation publishes a pull request or marks a
|
|
@@ -124,7 +124,9 @@ the final execution receipt so usage and session identity survive cancellation.
|
|
|
124
124
|
The transport emits one terminal result. Preparation failures are JSON-RPC
|
|
125
125
|
errors; a mismatched HEAD includes `error.data.reason: "revision_mismatch"`.
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
To run the deterministic installed-package smoke check, use a source checkout
|
|
128
|
+
of this repository and run the following from `sdk/typescript`. The script is
|
|
129
|
+
not included in the npm package and needs no model credentials:
|
|
128
130
|
|
|
129
131
|
```sh
|
|
130
132
|
node scripts/smoke-hosted-remediation.mjs /path/to/node_modules/@openai/codex-security
|
package/docs/hosted-scans.md
CHANGED
|
@@ -74,17 +74,43 @@ Standard scan lifecycle. Omit `scope` for the entire repository, or pass literal
|
|
|
74
74
|
repository-relative folders/files. Model settings come from the frozen input;
|
|
75
75
|
local profiles and other local scan options are not accepted.
|
|
76
76
|
|
|
77
|
-
Set `ownerSuggestions: true`
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
77
|
+
Set `ownerSuggestions: true` to record ownership evidence during the existing
|
|
78
|
+
scan execution. The scan agent may include an optional hint on each finding:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"extensions": {
|
|
83
|
+
"ownerSuggestion": {
|
|
84
|
+
"email": "alex@example.test",
|
|
85
|
+
"commit": "0123456789012345678901234567890123456789",
|
|
86
|
+
"reason": "Maintains the affected source."
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Use an observed contributor email and a full supporting commit hash from Git
|
|
93
|
+
blame/history for the affected source. Omit the hint when ownership is unclear.
|
|
94
|
+
Hints use the scan's existing session and budget; there is no extra ownership
|
|
95
|
+
turn or model call. Security findings take priority over optional hints.
|
|
96
|
+
|
|
97
|
+
After sealing the scan, the SDK builds `owner-suggestions.json` without inference.
|
|
98
|
+
CODEOWNERS declarations take precedence. Other hints must match an observed Git
|
|
99
|
+
identity and supporting commit in the finding's evidence. Missing hints abstain;
|
|
100
|
+
invalid hints produce per-finding owner errors. Neither invalid hints nor report
|
|
101
|
+
failures invalidate sealed findings. A completed receipt includes the artifact
|
|
102
|
+
when available, or `ownerSuggestionsError` if finalization fails.
|
|
103
|
+
|
|
104
|
+
Hosts run the normal scan request and capture the optional owner report.
|
|
105
|
+
Automatic reporting uses `suggestOwnersFromScan`; it does not use the legacy
|
|
106
|
+
`ownerCodex` option or send `owner.infer` / `owner.cancel` requests.
|
|
107
|
+
|
|
108
|
+
The standalone `suggestOwners` API and `suggest-owners` command can call a
|
|
109
|
+
model under their own budget. Both paths use the same CODEOWNERS rules, Git
|
|
110
|
+
evidence, identity checks, and report format.
|
|
111
|
+
|
|
112
|
+
Report generation works after the scan reaches `maxCostUsd`. It uses the
|
|
113
|
+
hints already recorded and never starts another model call to fill gaps.
|
|
88
114
|
|
|
89
115
|
`ScanExecutor.run` receives an AbortSignal and an optional `onEvent` observer for
|
|
90
116
|
`{type: "progress", progress}` or `{type: "activity", activity}` events. Progress
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openai/codex-security",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "TypeScript SDK and CLI for Codex Security",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "OpenAI",
|
|
@@ -58,18 +58,18 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@inquirer/prompts": "8.7.3",
|
|
61
|
-
"@linear/sdk": "
|
|
61
|
+
"@linear/sdk": "98.0.0",
|
|
62
62
|
"@octokit/core": "7.0.8",
|
|
63
|
-
"@openai/codex": "0.
|
|
64
|
-
"@openai/codex-sdk": "0.
|
|
63
|
+
"@openai/codex": "0.164.0",
|
|
64
|
+
"@openai/codex-sdk": "0.164.0",
|
|
65
65
|
"ajv": "8.20.0",
|
|
66
66
|
"fflate": "0.8.3",
|
|
67
|
-
"incur": "0.7.
|
|
67
|
+
"incur": "0.7.1",
|
|
68
68
|
"ink": "8.0.0",
|
|
69
69
|
"js-tiktoken": "1.0.21",
|
|
70
70
|
"papaparse": "5.7.0",
|
|
71
71
|
"pdfjs-dist": "6.4.299",
|
|
72
|
-
"react": "19.3.
|
|
72
|
+
"react": "19.3.1",
|
|
73
73
|
"saxes": "6.0.0",
|
|
74
74
|
"semver": "7.8.5",
|
|
75
75
|
"smol-toml": "1.9.1",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"prettier": "3.9.10",
|
|
97
97
|
"typescript": "7.0.2"
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "f05a0b096cc881242ddf34a4d6b3ce0f322f3cf9",
|
|
100
100
|
"scripts": {
|
|
101
101
|
"audit:prod": "pnpm audit --prod --audit-level high",
|
|
102
102
|
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"build:plugin": "node scripts/build-plugin.mjs",
|
|
108
108
|
"check:plugin-source": "node scripts/check-plugin-source.mjs",
|
|
109
109
|
"check:package": "node scripts/check-package.mjs",
|
|
110
|
-
"format": "prettier --check --ignore-path .gitignore --ignore-path .prettierignore \"**/*.{cjs,mjs,js,ts,mts,tsx,json}\" \"../../.github/scripts/*.mts\" \"../../examples/custom-validation/*.mts\" \"../../plugins/codex-security/native/*.mts\" \"../../evals/{deep-reducer,secret-discovery,workflow-routing}/*.mts\" \"../../evals/triage-finding/{assertions,scripts,sastbench/assertions,sastbench/scripts}/*.mts\" \"../../evals/triage-finding/types.ts\" \"../../evals/tsconfig.json\" && node scripts/check-markdown.mjs",
|
|
110
|
+
"format": "prettier --check --ignore-path .gitignore --ignore-path .prettierignore \"**/*.{cjs,mjs,js,ts,mts,tsx,json}\" \"../../.github/scripts/*.mts\" \"../../examples/custom-validation/*.mts\" \"../../plugins/codex-security/native/*.mts\" \"../../evals/{deep-reducer,secret-discovery,standard-time-budget,workflow-routing}/*.mts\" \"../../evals/triage-finding/{assertions,scripts,sastbench/assertions,sastbench/scripts}/*.mts\" \"../../evals/triage-finding/types.ts\" \"../../evals/tsconfig.json\" && node scripts/check-markdown.mjs",
|
|
111
111
|
"generate:models": "node scripts/generate-models.cjs",
|
|
112
112
|
"generate:models:check": "node scripts/generate-models.cjs --check",
|
|
113
113
|
"generate:external-import-models": "node scripts/generate-external-import-models.cjs",
|
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Generate the shared, deterministically ordered security-scan file inventory."""
|
|
3
|
-
|
|
4
|
-
from __future__ import annotations
|
|
5
|
-
|
|
6
|
-
import argparse
|
|
7
|
-
import os
|
|
8
|
-
import subprocess
|
|
9
|
-
import sys
|
|
10
|
-
import tempfile
|
|
11
|
-
from pathlib import Path
|
|
12
|
-
|
|
13
|
-
# Some plugin hosts launch Python with safe-path isolation enabled.
|
|
14
|
-
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
15
|
-
from workbench_target import SOURCE_METADATA_DIRECTORIES, git_blob_samples, git_command
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class InventoryError(ValueError):
|
|
19
|
-
"""Raised when the repository, scope, or inventory cannot be used safely."""
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def windows_stream_component(path: Path) -> str | None:
|
|
23
|
-
"""Return the first NTFS alternate-data-stream component."""
|
|
24
|
-
|
|
25
|
-
if os.name != "nt":
|
|
26
|
-
return None
|
|
27
|
-
return next(
|
|
28
|
-
(component for component in path.parts if component != path.anchor and ":" in component),
|
|
29
|
-
None,
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def resolve_repository(value: str) -> Path:
|
|
34
|
-
"""Resolve the repository once so every scope is bound to its real root."""
|
|
35
|
-
try:
|
|
36
|
-
repository = Path(value).expanduser().resolve(strict=True)
|
|
37
|
-
except (OSError, ValueError) as error:
|
|
38
|
-
raise InventoryError(f"--repo: cannot resolve repository: {value}") from error
|
|
39
|
-
if not repository.is_dir():
|
|
40
|
-
raise InventoryError(f"--repo: expected a directory: {repository}")
|
|
41
|
-
return repository
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def resolve_scope(repository: Path, value: str) -> str:
|
|
45
|
-
"""Preserve ripgrep's relative path spelling while rejecting escaped scopes."""
|
|
46
|
-
if not value or "\0" in value:
|
|
47
|
-
raise InventoryError("--scope: expected a non-empty file or directory")
|
|
48
|
-
|
|
49
|
-
requested = Path(value).expanduser()
|
|
50
|
-
stream = windows_stream_component(requested)
|
|
51
|
-
if stream is not None:
|
|
52
|
-
raise InventoryError(f"--scope: NTFS alternate data streams are not supported: {stream}")
|
|
53
|
-
scope = requested if requested.is_absolute() else repository / requested
|
|
54
|
-
try:
|
|
55
|
-
resolved = scope.resolve(strict=True)
|
|
56
|
-
except (OSError, ValueError) as error:
|
|
57
|
-
raise InventoryError(f"--scope: path does not exist: {value}") from error
|
|
58
|
-
|
|
59
|
-
try:
|
|
60
|
-
relative = resolved.relative_to(repository)
|
|
61
|
-
except ValueError as error:
|
|
62
|
-
raise InventoryError(f"--scope: path must remain inside --repo: {value}") from error
|
|
63
|
-
|
|
64
|
-
if not resolved.is_dir() and not resolved.is_file():
|
|
65
|
-
raise InventoryError(f"--scope: expected a file or directory: {value}")
|
|
66
|
-
|
|
67
|
-
if requested.is_absolute():
|
|
68
|
-
return relative.as_posix() if relative.parts else "."
|
|
69
|
-
return value
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
def resolve_output(value: str) -> Path:
|
|
73
|
-
"""Reject direct symlink outputs without constraining the artifact root."""
|
|
74
|
-
if not value or "\0" in value:
|
|
75
|
-
raise InventoryError("--out: expected an inventory file path")
|
|
76
|
-
requested = Path(value).expanduser()
|
|
77
|
-
if requested.is_symlink():
|
|
78
|
-
raise InventoryError("--out: refusing to replace a symbolic link")
|
|
79
|
-
try:
|
|
80
|
-
output = requested.resolve(strict=False)
|
|
81
|
-
except (OSError, ValueError) as error:
|
|
82
|
-
raise InventoryError(f"--out: cannot resolve inventory path: {value}") from error
|
|
83
|
-
if output.exists() and not output.is_file():
|
|
84
|
-
raise InventoryError(f"--out: expected a regular file path: {output}")
|
|
85
|
-
return output
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
def generate_in_scope_files(repository: Path, scope: str, output: Path) -> int:
|
|
89
|
-
"""Atomically write the exact ripgrep inventory sorted as ``LC_ALL=C``."""
|
|
90
|
-
command = [
|
|
91
|
-
"rg",
|
|
92
|
-
"--files",
|
|
93
|
-
"--null",
|
|
94
|
-
"--hidden",
|
|
95
|
-
"--path-separator",
|
|
96
|
-
"/",
|
|
97
|
-
# Prune metadata and its contents even when the scope starts inside it.
|
|
98
|
-
"--glob",
|
|
99
|
-
"!**/{.git,.svn}",
|
|
100
|
-
"--glob",
|
|
101
|
-
"!**/{.git,.svn}/**",
|
|
102
|
-
"--",
|
|
103
|
-
scope,
|
|
104
|
-
]
|
|
105
|
-
with tempfile.TemporaryFile(mode="w+b") as inventory:
|
|
106
|
-
try:
|
|
107
|
-
result = subprocess.run(
|
|
108
|
-
command,
|
|
109
|
-
cwd=repository,
|
|
110
|
-
stdout=inventory,
|
|
111
|
-
stderr=subprocess.PIPE,
|
|
112
|
-
check=False,
|
|
113
|
-
)
|
|
114
|
-
except OSError as error:
|
|
115
|
-
raise InventoryError(f"could not run ripgrep: {error}") from error
|
|
116
|
-
|
|
117
|
-
if result.returncode not in (0, 1):
|
|
118
|
-
detail = result.stderr.decode("utf-8", errors="replace").strip()
|
|
119
|
-
message = f"ripgrep exited with status {result.returncode}"
|
|
120
|
-
if detail:
|
|
121
|
-
message = f"{message}: {detail}"
|
|
122
|
-
raise InventoryError(message)
|
|
123
|
-
|
|
124
|
-
if any((parent / ".git").exists() for parent in (repository, *repository.parents)):
|
|
125
|
-
try:
|
|
126
|
-
tracked = git_command(
|
|
127
|
-
repository,
|
|
128
|
-
"ls-files",
|
|
129
|
-
"--cached",
|
|
130
|
-
"--ignored",
|
|
131
|
-
"--exclude-standard",
|
|
132
|
-
"-z",
|
|
133
|
-
"--",
|
|
134
|
-
scope,
|
|
135
|
-
text=False,
|
|
136
|
-
)
|
|
137
|
-
except OSError:
|
|
138
|
-
tracked = None
|
|
139
|
-
if tracked is not None and tracked.returncode == 0:
|
|
140
|
-
prefix = b"./" if scope == "." or scope.startswith("./") else b""
|
|
141
|
-
for path in tracked.stdout.split(b"\0"):
|
|
142
|
-
candidate = repository / os.fsdecode(path)
|
|
143
|
-
if path and candidate.is_file() and not candidate.is_symlink():
|
|
144
|
-
inventory.write(prefix + path + b"\0")
|
|
145
|
-
|
|
146
|
-
inventory.seek(0)
|
|
147
|
-
rows: list[bytes] = []
|
|
148
|
-
for path in inventory.read().split(b"\0"):
|
|
149
|
-
if not path or not SOURCE_METADATA_DIRECTORIES.isdisjoint(os.fsdecode(path).split("/")):
|
|
150
|
-
continue
|
|
151
|
-
if b"\n" in path or b"\r" in path:
|
|
152
|
-
raise InventoryError(
|
|
153
|
-
"Repository contains a path that cannot fit in the file inventory"
|
|
154
|
-
)
|
|
155
|
-
rows.append(path + b"\n")
|
|
156
|
-
|
|
157
|
-
return write_inventory(output, sorted(set(rows)))
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
def generate_diff_in_scope_files(
|
|
161
|
-
repository: Path,
|
|
162
|
-
base: str,
|
|
163
|
-
head: str,
|
|
164
|
-
mode: str,
|
|
165
|
-
output: Path,
|
|
166
|
-
) -> int:
|
|
167
|
-
"""Reuse the existing diff selection without generating previews or duplicate worklists."""
|
|
168
|
-
from generate_rank_input import git_changed_paths
|
|
169
|
-
from rank_preview import is_binary_file
|
|
170
|
-
|
|
171
|
-
rows: list[bytes] = []
|
|
172
|
-
try:
|
|
173
|
-
changed = git_changed_paths(repository, base, head, mode)
|
|
174
|
-
revision_refs = {
|
|
175
|
-
path.relative_to(repository): (
|
|
176
|
-
f"{base if status == 'D' else head}:{path.relative_to(repository).as_posix()}"
|
|
177
|
-
)
|
|
178
|
-
for path, status in changed
|
|
179
|
-
if mode == "revisions" or status == "D"
|
|
180
|
-
}
|
|
181
|
-
revision_samples = dict(
|
|
182
|
-
zip(revision_refs, git_blob_samples(repository, list(revision_refs.values())))
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
for path, status in changed:
|
|
186
|
-
relative = path.relative_to(repository)
|
|
187
|
-
if mode == "revisions" or status == "D":
|
|
188
|
-
sample = revision_samples[relative]
|
|
189
|
-
if sample is None:
|
|
190
|
-
revision = base if status == "D" else head
|
|
191
|
-
raise InventoryError(
|
|
192
|
-
f"could not read committed diff blob: {revision}:{relative.as_posix()}"
|
|
193
|
-
)
|
|
194
|
-
_, is_binary = sample
|
|
195
|
-
if is_binary:
|
|
196
|
-
continue
|
|
197
|
-
elif path.is_symlink() or not path.is_file() or is_binary_file(path):
|
|
198
|
-
continue
|
|
199
|
-
relative_path = os.fsencode(relative.as_posix())
|
|
200
|
-
if b"\n" in relative_path or b"\r" in relative_path:
|
|
201
|
-
raise InventoryError(
|
|
202
|
-
"Git changes contain a path that cannot fit in the file inventory"
|
|
203
|
-
)
|
|
204
|
-
rows.append(relative_path + b"\n")
|
|
205
|
-
except (OSError, subprocess.CalledProcessError) as error:
|
|
206
|
-
detail = getattr(error, "stderr", None)
|
|
207
|
-
if isinstance(detail, bytes):
|
|
208
|
-
detail = detail.decode("utf-8", errors="replace")
|
|
209
|
-
message = detail.strip() if isinstance(detail, str) and detail.strip() else str(error)
|
|
210
|
-
raise InventoryError(f"could not resolve the selected Git changes: {message}") from error
|
|
211
|
-
|
|
212
|
-
return write_inventory(output, sorted(set(rows)))
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
def write_inventory(output: Path, rows: list[bytes]) -> int:
|
|
216
|
-
"""Replace a complete inventory atomically, keeping failures from corrupting the old one."""
|
|
217
|
-
output.parent.mkdir(parents=True, exist_ok=True)
|
|
218
|
-
temporary: Path | None = None
|
|
219
|
-
try:
|
|
220
|
-
with tempfile.NamedTemporaryFile(
|
|
221
|
-
mode="wb",
|
|
222
|
-
dir=output.parent,
|
|
223
|
-
# Including the output name can exceed the filesystem's 255-byte name limit.
|
|
224
|
-
prefix=".",
|
|
225
|
-
suffix=".tmp",
|
|
226
|
-
delete=False,
|
|
227
|
-
) as handle:
|
|
228
|
-
temporary = Path(handle.name)
|
|
229
|
-
handle.writelines(rows)
|
|
230
|
-
temporary.replace(output)
|
|
231
|
-
finally:
|
|
232
|
-
if temporary is not None:
|
|
233
|
-
temporary.unlink(missing_ok=True)
|
|
234
|
-
|
|
235
|
-
return len(rows)
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
def main() -> None:
|
|
239
|
-
parser = argparse.ArgumentParser(description=__doc__)
|
|
240
|
-
parser.add_argument("--repo", required=True, help="Repository root.")
|
|
241
|
-
parser.add_argument("--scope", required=True, help="File or directory within the repository.")
|
|
242
|
-
parser.add_argument("--out", required=True, help="Destination for the file inventory.")
|
|
243
|
-
parser.add_argument("--diff-base", help="Authoritative Git base for a changed-file inventory.")
|
|
244
|
-
parser.add_argument("--diff-head", default="HEAD", help="Authoritative Git head revision.")
|
|
245
|
-
parser.add_argument(
|
|
246
|
-
"--diff-mode",
|
|
247
|
-
choices=("revisions", "local-patch"),
|
|
248
|
-
default="revisions",
|
|
249
|
-
help="Use committed revisions or the current staged and unstaged patch.",
|
|
250
|
-
)
|
|
251
|
-
args = parser.parse_args()
|
|
252
|
-
|
|
253
|
-
try:
|
|
254
|
-
repository = resolve_repository(args.repo)
|
|
255
|
-
scope = resolve_scope(repository, args.scope)
|
|
256
|
-
output = resolve_output(args.out)
|
|
257
|
-
if args.diff_base is None:
|
|
258
|
-
count = generate_in_scope_files(repository, scope, output)
|
|
259
|
-
elif scope not in (".", "./"):
|
|
260
|
-
raise InventoryError("--scope: diff scans must use the repository root")
|
|
261
|
-
else:
|
|
262
|
-
count = generate_diff_in_scope_files(
|
|
263
|
-
repository,
|
|
264
|
-
args.diff_base,
|
|
265
|
-
args.diff_head,
|
|
266
|
-
args.diff_mode,
|
|
267
|
-
output,
|
|
268
|
-
)
|
|
269
|
-
except (OSError, ValueError) as error:
|
|
270
|
-
print(f"generate_in_scope_files: {error}", file=sys.stderr)
|
|
271
|
-
raise SystemExit(2) from error
|
|
272
|
-
|
|
273
|
-
print(f"Recorded {count} in-scope files.")
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
if __name__ == "__main__":
|
|
277
|
-
main()
|