@openai/codex-security 0.1.31 → 0.2.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 +295 -32
- package/_bundled_plugin/.mcp.json +1 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +4 -4
- 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/linux-x64-musl/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/references/artifact-storage.md +4 -4
- package/_bundled_plugin/references/config-preflight.md +1 -1
- package/_bundled_plugin/references/core-scan.md +14 -2
- package/_bundled_plugin/references/final-report.md +4 -2
- package/_bundled_plugin/references/scan-artifacts.md +2 -2
- package/_bundled_plugin/references/scan-contract.md +2 -2
- package/_bundled_plugin/references/threat-model.md +2 -2
- package/_bundled_plugin/schemas/coverage.schema.json +22 -0
- package/_bundled_plugin/schemas/scan-manifest.schema.json +100 -85
- package/_bundled_plugin/schemas/tools/scan-draft.schema.json +116 -102
- package/_bundled_plugin/scripts/config_preflight.py +4 -8
- package/_bundled_plugin/scripts/deep_scan_workbench.py +83 -217
- package/_bundled_plugin/scripts/filesystem_identity.py +1 -5
- package/_bundled_plugin/scripts/finalize_scan_contract.py +441 -166
- package/_bundled_plugin/scripts/finding_preview.py +42 -82
- package/_bundled_plugin/scripts/generate_in_scope_files.py +30 -34
- package/_bundled_plugin/scripts/generate_rank_input.py +58 -99
- package/_bundled_plugin/scripts/launch_codex_security_mcp +5 -1
- package/_bundled_plugin/scripts/rank_preview.py +85 -68
- package/_bundled_plugin/scripts/report_projection.py +37 -58
- package/_bundled_plugin/scripts/threat_model_projection.py +164 -0
- package/_bundled_plugin/scripts/windows_scan_local_files.py +11 -6
- package/_bundled_plugin/scripts/workbench/storage.py +11 -0
- package/_bundled_plugin/scripts/workbench_cli.py +11 -17
- package/_bundled_plugin/scripts/workbench_constants.py +6 -14
- package/_bundled_plugin/scripts/workbench_db.py +116 -228
- package/_bundled_plugin/scripts/workbench_finding_index.py +1 -6
- package/_bundled_plugin/scripts/workbench_native_indexes.py +1 -4
- package/_bundled_plugin/scripts/workbench_progress.py +12 -34
- package/_bundled_plugin/scripts/workbench_publication.py +47 -62
- package/_bundled_plugin/scripts/workbench_remediation.py +2 -20
- package/_bundled_plugin/scripts/workbench_saved_results.py +1246 -230
- package/_bundled_plugin/scripts/workbench_scan_start.py +4 -11
- package/_bundled_plugin/scripts/workbench_scan_usage.py +7 -15
- package/_bundled_plugin/scripts/workbench_schema.py +86 -271
- package/_bundled_plugin/scripts/workbench_severity.py +3 -0
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +5 -6
- package/_bundled_plugin/scripts/workbench_target.py +98 -10
- package/_bundled_plugin/scripts/workbench_target_state.py +1 -5
- package/_bundled_plugin/scripts/workbench_validation.py +6 -20
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +3 -3
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +3 -3
- package/_bundled_plugin/skills/security-scan/SKILL.md +2 -2
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +2 -2
- package/_bundled_plugin/skills/threat-model/SKILL.md +2 -2
- package/dist/api.d.ts +3 -5
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +201 -207
- package/dist/api.js.map +1 -1
- package/dist/artifact-export.d.ts +70 -0
- package/dist/artifact-export.d.ts.map +1 -0
- package/dist/artifact-export.js +277 -0
- package/dist/artifact-export.js.map +1 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +8 -3
- package/dist/auth.js.map +1 -1
- package/dist/bulk-scan-discovery.d.ts +1 -0
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +8 -9
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/classify-scan-severity.d.ts.map +1 -1
- package/dist/classify-scan-severity.js +2 -5
- package/dist/classify-scan-severity.js.map +1 -1
- package/dist/classify-severity.d.ts +2 -8
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +3 -5
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-help.d.ts +3 -0
- package/dist/cli-help.d.ts.map +1 -0
- package/dist/cli-help.js +281 -0
- package/dist/cli-help.js.map +1 -0
- package/dist/cli.d.ts +19 -22
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +631 -714
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +1 -8
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codex-prompt.d.ts.map +1 -1
- package/dist/codex-prompt.js +1 -2
- package/dist/codex-prompt.js.map +1 -1
- package/dist/codex-sdk-environment.d.ts +2 -0
- package/dist/codex-sdk-environment.d.ts.map +1 -0
- package/dist/codex-sdk-environment.js +30 -0
- package/dist/codex-sdk-environment.js.map +1 -0
- package/dist/component-plan.d.ts.map +1 -1
- package/dist/component-plan.js +2 -6
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.d.ts +1 -0
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +31 -9
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +32 -33
- package/dist/config.js.map +1 -1
- package/dist/contract.d.ts +2 -1
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +63 -122
- package/dist/contract.js.map +1 -1
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +65 -34
- package/dist/cost-model.js.map +1 -1
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +15 -31
- package/dist/cost.js.map +1 -1
- package/dist/custom-validation-prompt.js +4 -4
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +17 -16
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/checkpointed-review.d.ts.map +1 -1
- package/dist/deduplication/checkpointed-review.js +10 -11
- package/dist/deduplication/checkpointed-review.js.map +1 -1
- package/dist/deduplication/codex-review.d.ts +2 -0
- package/dist/deduplication/codex-review.d.ts.map +1 -1
- package/dist/deduplication/codex-review.js +3 -3
- package/dist/deduplication/codex-review.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
- package/dist/deduplication/deduplication-reviewer.js +2 -0
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/deduplication.js +40 -62
- package/dist/deduplication/deduplication.js.map +1 -1
- package/dist/deduplication/records-protocol.d.ts.map +1 -1
- package/dist/deduplication/records-protocol.js +1 -4
- package/dist/deduplication/records-protocol.js.map +1 -1
- package/dist/deduplication/records.d.ts +2 -1
- package/dist/deduplication/records.d.ts.map +1 -1
- package/dist/deduplication/records.js +24 -6
- package/dist/deduplication/records.js.map +1 -1
- package/dist/deduplication/review.d.ts +7 -0
- package/dist/deduplication/review.d.ts.map +1 -1
- package/dist/deduplication/review.js.map +1 -1
- package/dist/deduplication/scan.js +3 -7
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-config.d.ts.map +1 -1
- package/dist/deep-config.js +3 -19
- package/dist/deep-config.js.map +1 -1
- package/dist/deep-progress.d.ts +0 -1
- package/dist/deep-progress.d.ts.map +1 -1
- package/dist/deep-progress.js +22 -40
- package/dist/deep-progress.js.map +1 -1
- package/dist/errors.d.ts +3 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +5 -7
- package/dist/errors.js.map +1 -1
- package/dist/finding-catalogue.d.ts.map +1 -1
- package/dist/finding-catalogue.js +22 -22
- package/dist/finding-catalogue.js.map +1 -1
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js +4 -7
- package/dist/finding-workflow.js.map +1 -1
- package/dist/findings-import.d.ts.map +1 -1
- package/dist/findings-import.js +7 -17
- package/dist/findings-import.js.map +1 -1
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +2 -3
- package/dist/github.js.map +1 -1
- package/dist/import-scan.js +2 -2
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.js +2 -2
- package/dist/knowledge-base.js.map +1 -1
- package/dist/linear.d.ts.map +1 -1
- package/dist/linear.js +2 -3
- package/dist/linear.js.map +1 -1
- package/dist/models.d.ts +24 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +36 -31
- package/dist/multiscan.js.map +1 -1
- package/dist/owner-evidence.d.ts.map +1 -1
- package/dist/owner-evidence.js +2 -6
- package/dist/owner-evidence.js.map +1 -1
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +2 -4
- package/dist/patch-tui.js.map +1 -1
- package/dist/project-config-schema.d.ts +10 -0
- package/dist/project-config-schema.d.ts.map +1 -1
- package/dist/project-config-schema.js +1 -0
- package/dist/project-config-schema.js.map +1 -1
- package/dist/project-config.d.ts +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +2 -0
- package/dist/project-config.js.map +1 -1
- package/dist/prompt-files.d.ts +0 -1
- package/dist/prompt-files.d.ts.map +1 -1
- package/dist/prompt-files.js +2 -4
- package/dist/prompt-files.js.map +1 -1
- package/dist/publication-events.d.ts.map +1 -1
- package/dist/publication-events.js +15 -29
- package/dist/publication-events.js.map +1 -1
- package/dist/publication-store.d.ts.map +1 -1
- package/dist/publication-store.js +9 -13
- package/dist/publication-store.js.map +1 -1
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js +11 -14
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +31 -41
- package/dist/publish.js.map +1 -1
- package/dist/record.d.ts +2 -0
- package/dist/record.d.ts.map +1 -0
- package/dist/record.js +4 -0
- package/dist/record.js.map +1 -0
- package/dist/result.d.ts +4 -1
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +7 -0
- package/dist/result.js.map +1 -1
- package/dist/runtime.d.ts +10 -13
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +203 -131
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan.d.ts.map +1 -1
- package/dist/saved-scan.js +10 -20
- package/dist/saved-scan.js.map +1 -1
- package/dist/scan-activity.d.ts.map +1 -1
- package/dist/scan-activity.js +8 -22
- package/dist/scan-activity.js.map +1 -1
- package/dist/scan-comparison.d.ts +3 -3
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +38 -73
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +0 -1
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +10 -19
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +1 -2
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +2 -6
- package/dist/scan-logs.js.map +1 -1
- package/dist/scan-sessions.d.ts.map +1 -1
- package/dist/scan-sessions.js +1 -3
- package/dist/scan-sessions.js.map +1 -1
- package/dist/scan-settings.d.ts +5 -0
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +4 -0
- package/dist/scan-settings.js.map +1 -1
- package/dist/security-policy-cli.d.ts.map +1 -1
- package/dist/security-policy-cli.js +8 -6
- package/dist/security-policy-cli.js.map +1 -1
- package/dist/security-policy.d.ts +8 -4
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js +98 -84
- package/dist/security-policy.js.map +1 -1
- package/dist/server/dashboard/app.js +5 -5
- package/dist/server/embeddings.d.ts.map +1 -1
- package/dist/server/embeddings.js +1 -0
- package/dist/server/embeddings.js.map +1 -1
- package/dist/server/routes.d.ts +3 -2
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +19 -7
- package/dist/server/routes.js.map +1 -1
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +2 -3
- package/dist/server/server.js.map +1 -1
- package/dist/server/sqlite-store.d.ts.map +1 -1
- package/dist/server/sqlite-store.js +4 -14
- package/dist/server/sqlite-store.js.map +1 -1
- package/dist/severity-store.js +8 -15
- package/dist/severity-store.js.map +1 -1
- package/dist/suggest-owners.d.ts +2 -3
- package/dist/suggest-owners.d.ts.map +1 -1
- package/dist/suggest-owners.js +4 -5
- package/dist/suggest-owners.js.map +1 -1
- package/dist/targets.d.ts +1 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +24 -21
- package/dist/targets.js.map +1 -1
- package/dist/trusted-executable.d.ts +5 -0
- package/dist/trusted-executable.d.ts.map +1 -1
- package/dist/trusted-executable.js +22 -5
- package/dist/trusted-executable.js.map +1 -1
- package/dist/value.d.ts +2 -0
- package/dist/value.d.ts.map +1 -0
- package/dist/value.js +20 -0
- package/dist/value.js.map +1 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +3 -6
- package/dist/version.js.map +1 -1
- package/dist/windows-path.d.ts.map +1 -1
- package/dist/windows-path.js +1 -2
- package/dist/windows-path.js.map +1 -1
- package/dist/worker-progress.d.ts +1 -0
- package/dist/worker-progress.d.ts.map +1 -1
- package/dist/worker-progress.js +13 -34
- package/dist/worker-progress.js.map +1 -1
- package/docs/dedupe-records.md +24 -0
- package/package.json +11 -10
- package/schemas/project-config.schema.json +5 -0
- package/_bundled_plugin/scripts/normalize_candidates.py +0 -338
- package/dist/server/findings-service.d.ts +0 -20
- package/dist/server/findings-service.d.ts.map +0 -1
- package/dist/server/findings-service.js +0 -31
- package/dist/server/findings-service.js.map +0 -1
package/dist/windows-path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"windows-path.js","sourceRoot":"","sources":["../src/windows-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,MAAM,gBAAgB,GAAG,+BAA+B,CAAC;AACzD,MAAM,kBAAkB,GACtB,2EAA2E,CAAC;AAE9E,MAAM,UAAU,4BAA4B,CAAC,KAAa;IACxD,OAAO,CACL,KAAK,KAAK,EAAE;QACZ,KAAK,KAAK,GAAG;QACb,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CACjE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,IAAY;IACrD,
|
|
1
|
+
{"version":3,"file":"windows-path.js","sourceRoot":"","sources":["../src/windows-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,MAAM,gBAAgB,GAAG,+BAA+B,CAAC;AACzD,MAAM,kBAAkB,GACtB,2EAA2E,CAAC;AAE9E,MAAM,UAAU,4BAA4B,CAAC,KAAa;IACxD,OAAO,CACL,KAAK,KAAK,EAAE;QACZ,KAAK,KAAK,GAAG;QACb,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CACjE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,IAAY;IACrD,OAAO,IAAI;SACR,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;SAC9B,KAAK,CAAC,QAAQ,CAAC;SACf,IAAI,CAAC,4BAA4B,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import { parse } from \"node:path\";\n\nconst UNSAFE_COMPONENT = /[<>:\"|?*\\u0000-\\u001f]|[ .]$/u;\nconst RESERVED_COMPONENT =\n /^(?:con|prn|aux|nul|conin\\$|conout\\$|com[1-9¹²³]|lpt[1-9¹²³])(?:\\..*)?$/iu;\n\nexport function isWindowsUnsafePathComponent(value: string): boolean {\n return (\n value !== \"\" &&\n value !== \".\" &&\n (UNSAFE_COMPONENT.test(value) || RESERVED_COMPONENT.test(value))\n );\n}\n\nexport function windowsUnsafePathComponent(path: string): string | undefined {\n return path\n .slice(parse(path).root.length)\n .split(/[\\\\/]/u)\n .find(isWindowsUnsafePathComponent);\n}\n"]}
|
|
@@ -18,4 +18,5 @@ export type ScanWorkerStatus = {
|
|
|
18
18
|
};
|
|
19
19
|
export declare function workerStatusFromEvent(event: Readonly<Record<string, unknown>>): ScanWorkerStatus | null;
|
|
20
20
|
export declare function scanProgressUpdatesFromEvent(event: Readonly<Record<string, unknown>>): ScanProgress[];
|
|
21
|
+
export declare function scanProgressUpdatesFromText(output: string): ScanProgress[];
|
|
21
22
|
//# sourceMappingURL=worker-progress.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-progress.d.ts","sourceRoot":"","sources":["../src/worker-progress.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"worker-progress.d.ts","sourceRoot":"","sources":["../src/worker-progress.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,eAAe,GACzB,SAAS,GAAG,aAAa,GAAG,YAAY,GAAG,aAAa,CAAC;AAE3D,MAAM,MAAM,SAAS,GACjB,WAAW,GACX,cAAc,GACd,WAAW,GACX,YAAY,GACZ,aAAa,GACb,WAAW,CAAC;AAEhB,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,SAAS,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,GAAG,MAAM,CAWzE;AAED,MAAM,MAAM,gBAAgB,GACxB;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,EAAE,WAAW,GAAG,aAAa,GAAG,SAAS,CAAC;IACpD,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,eAAe,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACvC,gBAAgB,GAAG,IAAI,CAQzB;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACvC,YAAY,EAAE,CAYhB;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE,CAa1E"}
|
package/dist/worker-progress.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isRecord } from "./record.js";
|
|
2
|
+
import { isSafeNonNegativeInteger, parseJson } from "./value.js";
|
|
1
3
|
const WORKER_STATUS_PREFIX = "CODEX_SECURITY_WORKER_STATUS ";
|
|
2
4
|
const SCAN_PROGRESS_PREFIX = "CODEX_SECURITY_SCAN_PROGRESS ";
|
|
3
5
|
const PREFLIGHT_COMMAND = /(?:^|[\\/])config_preflight\.py(?=$|["'\s])/u;
|
|
@@ -40,8 +42,9 @@ export function scanProgressUpdatesFromEvent(event) {
|
|
|
40
42
|
: item["type"] === "command_execution"
|
|
41
43
|
? item["aggregated_output"]
|
|
42
44
|
: null;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
return typeof output === "string" ? scanProgressUpdatesFromText(output) : [];
|
|
46
|
+
}
|
|
47
|
+
export function scanProgressUpdatesFromText(output) {
|
|
45
48
|
const updates = [];
|
|
46
49
|
let codeFence = false;
|
|
47
50
|
for (const line of output.split(/\r?\n/u)) {
|
|
@@ -58,17 +61,11 @@ export function scanProgressUpdatesFromEvent(event) {
|
|
|
58
61
|
return updates;
|
|
59
62
|
}
|
|
60
63
|
function scanProgressFromMarker(marker) {
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
payload = JSON.parse(marker.slice(SCAN_PROGRESS_PREFIX.length));
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
64
|
+
const payload = parseJson(() => marker.slice(SCAN_PROGRESS_PREFIX.length));
|
|
68
65
|
if (!isRecord(payload) ||
|
|
69
66
|
!isScanPhase(payload["phase"]) ||
|
|
70
|
-
!
|
|
71
|
-
!
|
|
67
|
+
!isSafeNonNegativeInteger(payload["filesCompleted"]) ||
|
|
68
|
+
!isSafeNonNegativeInteger(payload["filesTotal"]) ||
|
|
72
69
|
payload["filesCompleted"] > payload["filesTotal"]) {
|
|
73
70
|
return null;
|
|
74
71
|
}
|
|
@@ -84,13 +81,7 @@ function preflightStatus(item) {
|
|
|
84
81
|
typeof item["aggregated_output"] !== "string") {
|
|
85
82
|
return null;
|
|
86
83
|
}
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
payload = JSON.parse(item["aggregated_output"]);
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
84
|
+
const payload = parseJson(() => item["aggregated_output"]);
|
|
94
85
|
if (!isRecord(payload) ||
|
|
95
86
|
(payload["profile"] !== "security_scan" &&
|
|
96
87
|
payload["profile"] !== "security_diff_scan") ||
|
|
@@ -119,7 +110,7 @@ function preflightStatus(item) {
|
|
|
119
110
|
const capacityResult = capacity[0];
|
|
120
111
|
const configuredSlots = capacity.length === 1 &&
|
|
121
112
|
capacityResult !== undefined &&
|
|
122
|
-
|
|
113
|
+
isSafeNonNegativeInteger(capacityResult["actual"])
|
|
123
114
|
? capacityResult["actual"]
|
|
124
115
|
: null;
|
|
125
116
|
return { kind: "preflight", delegation, configuredSlots };
|
|
@@ -133,18 +124,12 @@ function dispatchStatus(item) {
|
|
|
133
124
|
const marker = markers[0];
|
|
134
125
|
if (markers.length !== 1 || marker === undefined)
|
|
135
126
|
return null;
|
|
136
|
-
|
|
137
|
-
try {
|
|
138
|
-
payload = JSON.parse(marker.slice(WORKER_STATUS_PREFIX.length));
|
|
139
|
-
}
|
|
140
|
-
catch {
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
127
|
+
const payload = parseJson(() => marker.slice(WORKER_STATUS_PREFIX.length));
|
|
143
128
|
if (!isRecord(payload) ||
|
|
144
129
|
typeof payload["phase"] !== "string" ||
|
|
145
130
|
!WORKER_PHASES.has(payload["phase"]) ||
|
|
146
|
-
!
|
|
147
|
-
!
|
|
131
|
+
!isSafeNonNegativeInteger(payload["planned"]) ||
|
|
132
|
+
!isSafeNonNegativeInteger(payload["started"]) ||
|
|
148
133
|
payload["started"] > payload["planned"]) {
|
|
149
134
|
return null;
|
|
150
135
|
}
|
|
@@ -155,9 +140,6 @@ function dispatchStatus(item) {
|
|
|
155
140
|
started: payload["started"],
|
|
156
141
|
};
|
|
157
142
|
}
|
|
158
|
-
function isProgressCount(value) {
|
|
159
|
-
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
160
|
-
}
|
|
161
143
|
function isScanPhase(value) {
|
|
162
144
|
return (value === "preflight" ||
|
|
163
145
|
value === "threat_model" ||
|
|
@@ -166,7 +148,4 @@ function isScanPhase(value) {
|
|
|
166
148
|
value === "attack_path" ||
|
|
167
149
|
value === "reporting");
|
|
168
150
|
}
|
|
169
|
-
function isRecord(value) {
|
|
170
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
171
|
-
}
|
|
172
151
|
//# sourceMappingURL=worker-progress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-progress.js","sourceRoot":"","sources":["../src/worker-progress.ts"],"names":[],"mappings":"AAAA,MAAM,oBAAoB,GAAG,+BAA+B,CAAC;AAC7D,MAAM,oBAAoB,GAAG,+BAA+B,CAAC;AAC7D,MAAM,iBAAiB,GAAG,8CAA8C,CAAC;AACzE,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,SAAS;IACT,aAAa;IACb,YAAY;IACZ,aAAa;CACd,CAAC,CAAC;AAmBH,MAAM,UAAU,cAAc,CAAC,KAAkC;IAC/D,OAAO;QACL,SAAS,EAAE,WAAW;QACtB,YAAY,EAAE,uBAAuB;QACrC,SAAS,EAAE,iBAAiB;QAC5B,OAAO,EAAE,sBAAsB;QAC/B,WAAW,EAAE,iBAAiB;QAC9B,UAAU,EAAE,qBAAqB;QACjC,WAAW,EAAE,wBAAwB;QACrC,SAAS,EAAE,gBAAgB;KAC5B,CAAC,KAAK,CAAC,CAAC;AACX,CAAC;AAeD,MAAM,UAAU,qBAAqB,CACnC,KAAwC;IAExC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,gBAAgB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,mBAAmB;QAAE,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;IACvE,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,eAAe;QAAE,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;IAClE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,KAAwC;IAExC,IAAI,KAAK,CAAC,M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AAS,CAAC;KAC5B,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,CACL,KAAK,KAAK,WAAW;QACrB,KAAK,KAAK,cAAc;QACxB,KAAK,KAAK,WAAW;QACrB,KAAK,KAAK,YAAY;QACtB,KAAK,KAAK,aAAa;QACvB,KAAK,KAAK,WAAW,CACtB,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["const WORKER_STATUS_PREFIX = \"CODEX_SECURITY_WORKER_STATUS \";\nconst SCAN_PROGRESS_PREFIX = \"CODEX_SECURITY_SCAN_PROGRESS \";\nconst PREFLIGHT_COMMAND = /(?:^|[\\\\/])config_preflight\\.py(?=$|[\"'\\s])/u;\nconst WORKER_PHASES = new Set([\n \"ranking\",\n \"file_review\",\n \"validation\",\n \"attack_path\",\n]);\n\nexport type ScanWorkerPhase =\n \"ranking\" | \"file_review\" | \"validation\" | \"attack_path\";\n\nexport type ScanPhase =\n | \"preflight\"\n | \"threat_model\"\n | \"discovery\"\n | \"validation\"\n | \"attack_path\"\n | \"reporting\";\n\nexport interface ScanProgress {\n phase: ScanPhase;\n filesCompleted: number;\n filesTotal: number;\n}\n\nexport function scanPhaseLabel(value: ScanWorkerPhase | ScanPhase): string {\n return {\n preflight: \"preflight\",\n threat_model: \"building threat model\",\n discovery: \"reviewing files\",\n ranking: \"ranking scan targets\",\n file_review: \"reviewing files\",\n validation: \"validating findings\",\n attack_path: \"analyzing attack paths\",\n reporting: \"writing report\",\n }[value];\n}\n\nexport type ScanWorkerStatus =\n | {\n kind: \"preflight\";\n delegation: \"available\" | \"unavailable\" | \"unknown\";\n configuredSlots: number | null;\n }\n | {\n kind: \"dispatch\";\n phase: ScanWorkerPhase;\n planned: number;\n started: number;\n };\n\nexport function workerStatusFromEvent(\n event: Readonly<Record<string, unknown>>,\n): ScanWorkerStatus | null {\n if (event[\"type\"] !== \"item.completed\" || !isRecord(event[\"item\"])) {\n return null;\n }\n const item = event[\"item\"];\n if (item[\"type\"] === \"command_execution\") return preflightStatus(item);\n if (item[\"type\"] === \"agent_message\") return dispatchStatus(item);\n return null;\n}\n\nexport function scanProgressUpdatesFromEvent(\n event: Readonly<Record<string, unknown>>,\n): ScanProgress[] {\n if (event[\"type\"] !== \"item.completed\" || !isRecord(event[\"item\"])) {\n return [];\n }\n const item = event[\"item\"];\n const output =\n item[\"type\"] === \"agent_message\"\n ? item[\"text\"]\n : item[\"type\"] === \"command_execution\"\n ? item[\"aggregated_output\"]\n : null;\n if (typeof output !== \"string\") return [];\n const updates: ScanProgress[] = [];\n let codeFence = false;\n for (const line of output.split(/\\r?\\n/u)) {\n if (/^\\s*```/u.test(line)) {\n codeFence = !codeFence;\n continue;\n }\n if (codeFence || !line.startsWith(SCAN_PROGRESS_PREFIX)) continue;\n const progress = scanProgressFromMarker(line);\n if (progress !== null) updates.push(progress);\n }\n return updates;\n}\n\nfunction scanProgressFromMarker(marker: string): ScanProgress | null {\n let payload: unknown;\n try {\n payload = JSON.parse(marker.slice(SCAN_PROGRESS_PREFIX.length));\n } catch {\n return null;\n }\n if (\n !isRecord(payload) ||\n !isScanPhase(payload[\"phase\"]) ||\n !isProgressCount(payload[\"filesCompleted\"]) ||\n !isProgressCount(payload[\"filesTotal\"]) ||\n payload[\"filesCompleted\"] > payload[\"filesTotal\"]\n ) {\n return null;\n }\n return {\n phase: payload[\"phase\"],\n filesCompleted: payload[\"filesCompleted\"],\n filesTotal: payload[\"filesTotal\"],\n };\n}\n\nfunction preflightStatus(\n item: Readonly<Record<string, unknown>>,\n): ScanWorkerStatus | null {\n if (\n typeof item[\"command\"] !== \"string\" ||\n !PREFLIGHT_COMMAND.test(item[\"command\"]) ||\n typeof item[\"aggregated_output\"] !== \"string\"\n ) {\n return null;\n }\n let payload: unknown;\n try {\n payload = JSON.parse(item[\"aggregated_output\"]);\n } catch {\n return null;\n }\n if (\n !isRecord(payload) ||\n (payload[\"profile\"] !== \"security_scan\" &&\n payload[\"profile\"] !== \"security_diff_scan\") ||\n !Array.isArray(payload[\"results\"])\n ) {\n return null;\n }\n const results = payload[\"results\"];\n const delegated = results.filter(\n (result): result is Record<string, unknown> =>\n isRecord(result) && result[\"capability\"] === \"delegated_workers\",\n );\n const delegatedResult = delegated[0];\n if (delegated.length !== 1 || delegatedResult === undefined) return null;\n const delegation =\n delegatedResult[\"status\"] === \"pass\"\n ? \"available\"\n : delegatedResult[\"status\"] === \"fail\"\n ? \"unavailable\"\n : delegatedResult[\"status\"] === \"unknown\"\n ? \"unknown\"\n : null;\n if (delegation === null) return null;\n const capacity = results.filter(\n (result): result is Record<string, unknown> =>\n isRecord(result) &&\n typeof result[\"capability\"] === \"string\" &&\n result[\"capability\"].startsWith(\"usable_worker_slots_\"),\n );\n if (capacity.length > 1) return null;\n const capacityResult = capacity[0];\n const configuredSlots =\n capacity.length === 1 &&\n capacityResult !== undefined &&\n isProgressCount(capacityResult[\"actual\"])\n ? capacityResult[\"actual\"]\n : null;\n return { kind: \"preflight\", delegation, configuredSlots };\n}\n\nfunction dispatchStatus(\n item: Readonly<Record<string, unknown>>,\n): ScanWorkerStatus | null {\n if (typeof item[\"text\"] !== \"string\") return null;\n const markers = item[\"text\"]\n .split(/\\r?\\n/u)\n .filter((line) => line.startsWith(WORKER_STATUS_PREFIX));\n const marker = markers[0];\n if (markers.length !== 1 || marker === undefined) return null;\n let payload: unknown;\n try {\n payload = JSON.parse(marker.slice(WORKER_STATUS_PREFIX.length));\n } catch {\n return null;\n }\n if (\n !isRecord(payload) ||\n typeof payload[\"phase\"] !== \"string\" ||\n !WORKER_PHASES.has(payload[\"phase\"]) ||\n !isProgressCount(payload[\"planned\"]) ||\n !isProgressCount(payload[\"started\"]) ||\n payload[\"started\"] > payload[\"planned\"]\n ) {\n return null;\n }\n return {\n kind: \"dispatch\",\n phase: payload[\"phase\"] as ScanWorkerPhase,\n planned: payload[\"planned\"],\n started: payload[\"started\"],\n };\n}\n\nfunction isProgressCount(value: unknown): value is number {\n return typeof value === \"number\" && Number.isSafeInteger(value) && value >= 0;\n}\n\nfunction isScanPhase(value: unknown): value is ScanPhase {\n return (\n value === \"preflight\" ||\n value === \"threat_model\" ||\n value === \"discovery\" ||\n value === \"validation\" ||\n value === \"attack_path\" ||\n value === \"reporting\"\n );\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"worker-progress.js","sourceRoot":"","sources":["../src/worker-progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEjE,MAAM,oBAAoB,GAAG,+BAA+B,CAAC;AAC7D,MAAM,oBAAoB,GAAG,+BAA+B,CAAC;AAC7D,MAAM,iBAAiB,GAAG,8CAA8C,CAAC;AACzE,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,SAAS;IACT,aAAa;IACb,YAAY;IACZ,aAAa;CACd,CAAC,CAAC;AAmBH,MAAM,UAAU,cAAc,CAAC,KAAkC;IAC/D,OAAO;QACL,SAAS,EAAE,WAAW;QACtB,YAAY,EAAE,uBAAuB;QACrC,SAAS,EAAE,iBAAiB;QAC5B,OAAO,EAAE,sBAAsB;QAC/B,WAAW,EAAE,iBAAiB;QAC9B,UAAU,EAAE,qBAAqB;QACjC,WAAW,EAAE,wBAAwB;QACrC,SAAS,EAAE,gBAAgB;KAC5B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AAO,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC,wBAAwB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC7C,CAAC,wBAAwB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC7C,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,EACvC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,OAAO,CAAC,OAAO,CAAoB;QAC1C,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;QAC3B,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;KAC5B,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,CACL,KAAK,KAAK,WAAW;QACrB,KAAK,KAAK,cAAc;QACxB,KAAK,KAAK,WAAW;QACrB,KAAK,KAAK,YAAY;QACtB,KAAK,KAAK,aAAa;QACvB,KAAK,KAAK,WAAW,CACtB,CAAC;AACJ,CAAC","sourcesContent":["import { isRecord } from \"./record.js\";\nimport { isSafeNonNegativeInteger, parseJson } from \"./value.js\";\n\nconst WORKER_STATUS_PREFIX = \"CODEX_SECURITY_WORKER_STATUS \";\nconst SCAN_PROGRESS_PREFIX = \"CODEX_SECURITY_SCAN_PROGRESS \";\nconst PREFLIGHT_COMMAND = /(?:^|[\\\\/])config_preflight\\.py(?=$|[\"'\\s])/u;\nconst WORKER_PHASES = new Set([\n \"ranking\",\n \"file_review\",\n \"validation\",\n \"attack_path\",\n]);\n\nexport type ScanWorkerPhase =\n \"ranking\" | \"file_review\" | \"validation\" | \"attack_path\";\n\nexport type ScanPhase =\n | \"preflight\"\n | \"threat_model\"\n | \"discovery\"\n | \"validation\"\n | \"attack_path\"\n | \"reporting\";\n\nexport interface ScanProgress {\n phase: ScanPhase;\n filesCompleted: number;\n filesTotal: number;\n}\n\nexport function scanPhaseLabel(value: ScanWorkerPhase | ScanPhase): string {\n return {\n preflight: \"preflight\",\n threat_model: \"building threat model\",\n discovery: \"reviewing files\",\n ranking: \"ranking scan targets\",\n file_review: \"reviewing files\",\n validation: \"validating findings\",\n attack_path: \"analyzing attack paths\",\n reporting: \"writing report\",\n }[value];\n}\n\nexport type ScanWorkerStatus =\n | {\n kind: \"preflight\";\n delegation: \"available\" | \"unavailable\" | \"unknown\";\n configuredSlots: number | null;\n }\n | {\n kind: \"dispatch\";\n phase: ScanWorkerPhase;\n planned: number;\n started: number;\n };\n\nexport function workerStatusFromEvent(\n event: Readonly<Record<string, unknown>>,\n): ScanWorkerStatus | null {\n if (event[\"type\"] !== \"item.completed\" || !isRecord(event[\"item\"])) {\n return null;\n }\n const item = event[\"item\"];\n if (item[\"type\"] === \"command_execution\") return preflightStatus(item);\n if (item[\"type\"] === \"agent_message\") return dispatchStatus(item);\n return null;\n}\n\nexport function scanProgressUpdatesFromEvent(\n event: Readonly<Record<string, unknown>>,\n): ScanProgress[] {\n if (event[\"type\"] !== \"item.completed\" || !isRecord(event[\"item\"])) {\n return [];\n }\n const item = event[\"item\"];\n const output =\n item[\"type\"] === \"agent_message\"\n ? item[\"text\"]\n : item[\"type\"] === \"command_execution\"\n ? item[\"aggregated_output\"]\n : null;\n return typeof output === \"string\" ? scanProgressUpdatesFromText(output) : [];\n}\n\nexport function scanProgressUpdatesFromText(output: string): ScanProgress[] {\n const updates: ScanProgress[] = [];\n let codeFence = false;\n for (const line of output.split(/\\r?\\n/u)) {\n if (/^\\s*```/u.test(line)) {\n codeFence = !codeFence;\n continue;\n }\n if (codeFence || !line.startsWith(SCAN_PROGRESS_PREFIX)) continue;\n const progress = scanProgressFromMarker(line);\n if (progress !== null) updates.push(progress);\n }\n return updates;\n}\n\nfunction scanProgressFromMarker(marker: string): ScanProgress | null {\n const payload = parseJson(() => marker.slice(SCAN_PROGRESS_PREFIX.length));\n if (\n !isRecord(payload) ||\n !isScanPhase(payload[\"phase\"]) ||\n !isSafeNonNegativeInteger(payload[\"filesCompleted\"]) ||\n !isSafeNonNegativeInteger(payload[\"filesTotal\"]) ||\n payload[\"filesCompleted\"] > payload[\"filesTotal\"]\n ) {\n return null;\n }\n return {\n phase: payload[\"phase\"],\n filesCompleted: payload[\"filesCompleted\"],\n filesTotal: payload[\"filesTotal\"],\n };\n}\n\nfunction preflightStatus(\n item: Readonly<Record<string, unknown>>,\n): ScanWorkerStatus | null {\n if (\n typeof item[\"command\"] !== \"string\" ||\n !PREFLIGHT_COMMAND.test(item[\"command\"]) ||\n typeof item[\"aggregated_output\"] !== \"string\"\n ) {\n return null;\n }\n const payload = parseJson(() => item[\"aggregated_output\"] as string);\n if (\n !isRecord(payload) ||\n (payload[\"profile\"] !== \"security_scan\" &&\n payload[\"profile\"] !== \"security_diff_scan\") ||\n !Array.isArray(payload[\"results\"])\n ) {\n return null;\n }\n const results = payload[\"results\"];\n const delegated = results.filter(\n (result): result is Record<string, unknown> =>\n isRecord(result) && result[\"capability\"] === \"delegated_workers\",\n );\n const delegatedResult = delegated[0];\n if (delegated.length !== 1 || delegatedResult === undefined) return null;\n const delegation =\n delegatedResult[\"status\"] === \"pass\"\n ? \"available\"\n : delegatedResult[\"status\"] === \"fail\"\n ? \"unavailable\"\n : delegatedResult[\"status\"] === \"unknown\"\n ? \"unknown\"\n : null;\n if (delegation === null) return null;\n const capacity = results.filter(\n (result): result is Record<string, unknown> =>\n isRecord(result) &&\n typeof result[\"capability\"] === \"string\" &&\n result[\"capability\"].startsWith(\"usable_worker_slots_\"),\n );\n if (capacity.length > 1) return null;\n const capacityResult = capacity[0];\n const configuredSlots =\n capacity.length === 1 &&\n capacityResult !== undefined &&\n isSafeNonNegativeInteger(capacityResult[\"actual\"])\n ? capacityResult[\"actual\"]\n : null;\n return { kind: \"preflight\", delegation, configuredSlots };\n}\n\nfunction dispatchStatus(\n item: Readonly<Record<string, unknown>>,\n): ScanWorkerStatus | null {\n if (typeof item[\"text\"] !== \"string\") return null;\n const markers = item[\"text\"]\n .split(/\\r?\\n/u)\n .filter((line) => line.startsWith(WORKER_STATUS_PREFIX));\n const marker = markers[0];\n if (markers.length !== 1 || marker === undefined) return null;\n const payload = parseJson(() => marker.slice(WORKER_STATUS_PREFIX.length));\n if (\n !isRecord(payload) ||\n typeof payload[\"phase\"] !== \"string\" ||\n !WORKER_PHASES.has(payload[\"phase\"]) ||\n !isSafeNonNegativeInteger(payload[\"planned\"]) ||\n !isSafeNonNegativeInteger(payload[\"started\"]) ||\n payload[\"started\"] > payload[\"planned\"]\n ) {\n return null;\n }\n return {\n kind: \"dispatch\",\n phase: payload[\"phase\"] as ScanWorkerPhase,\n planned: payload[\"planned\"],\n started: payload[\"started\"],\n };\n}\n\nfunction isScanPhase(value: unknown): value is ScanPhase {\n return (\n value === \"preflight\" ||\n value === \"threat_model\" ||\n value === \"discovery\" ||\n value === \"validation\" ||\n value === \"attack_path\" ||\n value === \"reporting\"\n );\n}\n"]}
|
package/docs/dedupe-records.md
CHANGED
|
@@ -95,6 +95,11 @@ The CLI sends one review at a time:
|
|
|
95
95
|
"method": "review.run",
|
|
96
96
|
"params": {
|
|
97
97
|
"requestId": "<same review UUID>",
|
|
98
|
+
"attribution": {
|
|
99
|
+
"version": 1,
|
|
100
|
+
"beneficiaryObservationIds": ["observation-1"],
|
|
101
|
+
"contextObservationIds": ["observation-2"]
|
|
102
|
+
},
|
|
98
103
|
"stage": "screening",
|
|
99
104
|
"model": "gpt-5.6-luna",
|
|
100
105
|
"effort": "xhigh",
|
|
@@ -106,6 +111,25 @@ The CLI sends one review at a time:
|
|
|
106
111
|
}
|
|
107
112
|
```
|
|
108
113
|
|
|
114
|
+
Every records review includes `attribution.version: 1`. The two ID arrays name
|
|
115
|
+
the exact original host observations participating in that screening or pair
|
|
116
|
+
review, using the structured assignment rather than the prompt or final groups.
|
|
117
|
+
`beneficiaryObservationIds` contains participants that have an anchor entry in
|
|
118
|
+
this invocation's `candidateRelationships`; `contextObservationIds` contains
|
|
119
|
+
the remaining participants. Both arrays are sorted, distinct, and disjoint,
|
|
120
|
+
and beneficiaries are nonempty. Candidate-only observations never become
|
|
121
|
+
beneficiaries, even when selected as the final representative. An incoming
|
|
122
|
+
observation participating in several reviews appears in each review's metadata.
|
|
123
|
+
|
|
124
|
+
This is additive metadata: JSON-RPC remains 2.0 and input/result versions remain 1.
|
|
125
|
+
Older hosts may ignore it; hosts that require attribution must validate it
|
|
126
|
+
and reject missing or unknown identities before executing a review. Persist the
|
|
127
|
+
request UUID and attribution before provisioning remote execution. The host owns
|
|
128
|
+
accounting and any partitioning of invocation anchors by origin scan; the CLI
|
|
129
|
+
preserves the supplied batch and does not assign costs or infer scan ownership.
|
|
130
|
+
The `model` field remains the configured review model. A new invocation produces
|
|
131
|
+
new request UUIDs; this metadata does not introduce cross-invocation replay.
|
|
132
|
+
|
|
109
133
|
`stage` is `screening` or `pair-review`. Screening uses `gpt-5.6-luna`/`xhigh`;
|
|
110
134
|
independent pair validation uses `gpt-5.6-sol`/`high`. Execute each request in a
|
|
111
135
|
fresh review context: pair reviews must not inherit screening answers or prior
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openai/codex-security",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "TypeScript SDK and CLI for Codex Security",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "OpenAI",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@inquirer/prompts": "8.7.2",
|
|
53
|
-
"@linear/sdk": "
|
|
53
|
+
"@linear/sdk": "97.0.0",
|
|
54
54
|
"@octokit/core": "7.0.8",
|
|
55
|
-
"@openai/codex": "0.
|
|
56
|
-
"@openai/codex-sdk": "0.
|
|
55
|
+
"@openai/codex": "0.162.0-alpha.15",
|
|
56
|
+
"@openai/codex-sdk": "0.162.0-alpha.15",
|
|
57
57
|
"ajv": "8.20.0",
|
|
58
58
|
"fflate": "0.8.3",
|
|
59
59
|
"incur": "0.5.1",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"pdfjs-dist": "6.3.289",
|
|
64
64
|
"react": "19.3.0",
|
|
65
65
|
"semver": "7.8.5",
|
|
66
|
-
"smol-toml": "1.
|
|
66
|
+
"smol-toml": "1.9.0",
|
|
67
67
|
"yaml": "2.9.1",
|
|
68
68
|
"yauzl": "3.4.0",
|
|
69
69
|
"zod": "4.6.5"
|
|
@@ -73,35 +73,36 @@
|
|
|
73
73
|
"@stryker-mutator/core": "10.0.0",
|
|
74
74
|
"@tailwindcss/postcss": "4.3.3",
|
|
75
75
|
"@types/bun": "1.4.2",
|
|
76
|
-
"@types/node": "26.6.
|
|
76
|
+
"@types/node": "26.6.3",
|
|
77
77
|
"@types/papaparse": "5.5.2",
|
|
78
78
|
"@types/react": "19.3.0",
|
|
79
79
|
"@types/react-dom": "19.3.0",
|
|
80
80
|
"@types/semver": "7.8.0",
|
|
81
81
|
"@types/yauzl": "3.4.0",
|
|
82
82
|
"esbuild": "0.28.2",
|
|
83
|
-
"fast-check": "4.10.
|
|
83
|
+
"fast-check": "4.10.2",
|
|
84
84
|
"ink-testing-library": "4.0.0",
|
|
85
85
|
"json-schema-to-typescript": "16.0.0",
|
|
86
86
|
"minimatch": "10.2.6",
|
|
87
87
|
"postcss": "8.5.28",
|
|
88
|
-
"prettier": "3.9.
|
|
88
|
+
"prettier": "3.9.9",
|
|
89
89
|
"react-dom": "19.3.0",
|
|
90
90
|
"saxes": "6.0.0",
|
|
91
91
|
"tailwindcss": "4.3.3",
|
|
92
92
|
"typescript": "7.0.2"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "4949af70fcfadff154f6e8fdf100faa5bf2f8169",
|
|
95
95
|
"scripts": {
|
|
96
96
|
"audit:prod": "pnpm audit --prod --audit-level high",
|
|
97
97
|
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
98
98
|
"build": "node --run clean && node scripts/generate-deep-defaults.mjs && tsc -p tsconfig.build.json && node scripts/generate-project-config-schema.mjs && node scripts/build-dashboard.mjs",
|
|
99
99
|
"build:ci": "tsc -p tsconfig.ci.json",
|
|
100
|
+
"build:evals": "node --run build && tsc -p ../../evals/tsconfig.json",
|
|
100
101
|
"build:examples": "tsc -p tsconfig.examples.json",
|
|
101
102
|
"build:plugin": "node scripts/build-plugin.mjs",
|
|
102
103
|
"check:plugin-source": "node scripts/check-plugin-source.mjs",
|
|
103
104
|
"check:package": "node scripts/check-package.mjs",
|
|
104
|
-
"format": "prettier --check --ignore-path .gitignore --ignore-path .prettierignore \"**/*.{cjs,mjs,js,ts,mts,tsx,json,md}\" \"../../.github/scripts/*.mts\" \"../../examples/custom-validation/*.{mts,md}\" \"../../plugins/codex-security/native/*.{mts,md}\"",
|
|
105
|
+
"format": "prettier --check --ignore-path .gitignore --ignore-path .prettierignore \"**/*.{cjs,mjs,js,ts,mts,tsx,json,md}\" \"../../.github/scripts/*.mts\" \"../../examples/custom-validation/*.{mts,md}\" \"../../plugins/codex-security/native/*.{mts,md}\" \"../../evals/{deep-reducer,secret-discovery}/*.mts\" \"../../evals/triage-finding/{assertions,scripts,sastbench/assertions,sastbench/scripts}/*.mts\" \"../../evals/triage-finding/types.ts\" \"../../evals/tsconfig.json\"",
|
|
105
106
|
"generate:models": "node scripts/generate-models.cjs",
|
|
106
107
|
"generate:models:check": "node scripts/generate-models.cjs --check",
|
|
107
108
|
"lint": "tsc --noEmit",
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
"type": "string",
|
|
22
22
|
"enum": ["standard", "deep"]
|
|
23
23
|
},
|
|
24
|
+
"cyber_access_program": {
|
|
25
|
+
"description": "Experimental Cyber access program for scan turns (OpenAI provider only). Omit to preserve Codex defaults.",
|
|
26
|
+
"type": "string",
|
|
27
|
+
"enum": ["standard", "daybreak_blue", "daybreak_red"]
|
|
28
|
+
},
|
|
24
29
|
"scope": {
|
|
25
30
|
"description": "One scope variant. Omit for the whole repository. Mode compatibility is checked after overrides.",
|
|
26
31
|
"anyOf": [
|
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Validate and combine security-scan candidates into deterministic JSONL."""
|
|
3
|
-
|
|
4
|
-
from __future__ import annotations
|
|
5
|
-
|
|
6
|
-
import argparse
|
|
7
|
-
import hashlib
|
|
8
|
-
import json
|
|
9
|
-
import re
|
|
10
|
-
import sys
|
|
11
|
-
import tempfile
|
|
12
|
-
from pathlib import Path, PurePosixPath
|
|
13
|
-
from typing import Any
|
|
14
|
-
|
|
15
|
-
CWE = re.compile(r"(?i)CWE-(\d+)")
|
|
16
|
-
ROLES = {
|
|
17
|
-
"entrypoint": 0,
|
|
18
|
-
"entrypoint/wrapper": 1,
|
|
19
|
-
"source": 2,
|
|
20
|
-
"root_control": 3,
|
|
21
|
-
"sink": 4,
|
|
22
|
-
"concrete_implementation": 5,
|
|
23
|
-
"evidence": 6,
|
|
24
|
-
}
|
|
25
|
-
FIELDS = {
|
|
26
|
-
"candidate_id",
|
|
27
|
-
"cwe_ids",
|
|
28
|
-
"locations",
|
|
29
|
-
"summary",
|
|
30
|
-
"evidence",
|
|
31
|
-
"context",
|
|
32
|
-
"instance",
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def text_field(row: dict[str, Any], field: str, *, required: bool = True) -> str | None:
|
|
37
|
-
value = row.get(field)
|
|
38
|
-
if value is None and not required:
|
|
39
|
-
return None
|
|
40
|
-
if not isinstance(value, str) or not value.strip():
|
|
41
|
-
raise ValueError(f"{field}: expected a non-empty string")
|
|
42
|
-
return value.strip()
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def cwe_ids(row: dict[str, Any]) -> list[str]:
|
|
46
|
-
value = row.get("cwe_ids")
|
|
47
|
-
if not isinstance(value, list):
|
|
48
|
-
raise ValueError("cwe_ids: expected an array")
|
|
49
|
-
found: set[int] = set()
|
|
50
|
-
for item in value:
|
|
51
|
-
if not isinstance(item, str):
|
|
52
|
-
raise ValueError("cwe_ids: expected CWE strings")
|
|
53
|
-
match = CWE.fullmatch(item.strip())
|
|
54
|
-
if match is None or int(match[1]) < 1:
|
|
55
|
-
raise ValueError(f"cwe_ids: unsupported value {item!r}")
|
|
56
|
-
found.add(int(match[1]))
|
|
57
|
-
return [f"CWE-{number}" for number in sorted(found)]
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
def relative_file(value: Any, repo_root: Path) -> tuple[str, Path]:
|
|
61
|
-
if not isinstance(value, str) or not value or "\0" in value:
|
|
62
|
-
raise ValueError("path: expected a non-empty repository-relative path")
|
|
63
|
-
raw = value
|
|
64
|
-
if sys.platform == "win32":
|
|
65
|
-
raw = raw.replace("\\", "/")
|
|
66
|
-
path = PurePosixPath(raw)
|
|
67
|
-
if (
|
|
68
|
-
path.is_absolute()
|
|
69
|
-
or ".." in path.parts
|
|
70
|
-
or (sys.platform == "win32" and re.match(r"^[A-Za-z]:", raw))
|
|
71
|
-
):
|
|
72
|
-
raise ValueError("path: expected a repository-relative path without traversal")
|
|
73
|
-
resolved = (repo_root / raw).resolve(strict=True)
|
|
74
|
-
try:
|
|
75
|
-
relative = resolved.relative_to(repo_root).as_posix()
|
|
76
|
-
except ValueError as error:
|
|
77
|
-
raise ValueError("path: must resolve inside --repo-root") from error
|
|
78
|
-
if not resolved.is_file():
|
|
79
|
-
raise ValueError("path: expected a regular file")
|
|
80
|
-
return relative, resolved
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def positive_line(value: Any, field: str) -> int:
|
|
84
|
-
if not isinstance(value, int) or isinstance(value, bool) or value < 1:
|
|
85
|
-
raise ValueError(f"{field}: expected a positive integer")
|
|
86
|
-
return value
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def normalize_locations(
|
|
90
|
-
row: dict[str, Any], repo_root: Path, line_counts: dict[Path, int]
|
|
91
|
-
) -> list[dict[str, Any]]:
|
|
92
|
-
value = row.get("locations")
|
|
93
|
-
if not isinstance(value, list) or not value:
|
|
94
|
-
raise ValueError("locations: expected a non-empty array")
|
|
95
|
-
normalized: dict[tuple[str, int, int, str], dict[str, Any]] = {}
|
|
96
|
-
for item in value:
|
|
97
|
-
if not isinstance(item, dict):
|
|
98
|
-
raise ValueError("locations: expected location objects")
|
|
99
|
-
unknown = set(item) - {"path", "start_line", "end_line", "role"}
|
|
100
|
-
if unknown:
|
|
101
|
-
raise ValueError(f"locations: unsupported fields {', '.join(sorted(unknown))}")
|
|
102
|
-
relative, source = relative_file(item.get("path"), repo_root)
|
|
103
|
-
if (
|
|
104
|
-
not relative.strip()
|
|
105
|
-
or "\\" in relative
|
|
106
|
-
or any(":" in part for part in PurePosixPath(relative).parts)
|
|
107
|
-
):
|
|
108
|
-
raise ValueError("path: expected a safe repository-relative POSIX path")
|
|
109
|
-
start = positive_line(item.get("start_line"), "start_line")
|
|
110
|
-
end = positive_line(item.get("end_line", start), "end_line")
|
|
111
|
-
if end < start:
|
|
112
|
-
raise ValueError("end_line: must be greater than or equal to start_line")
|
|
113
|
-
if source not in line_counts:
|
|
114
|
-
line_counts[source] = len(source.read_bytes().splitlines())
|
|
115
|
-
if end > line_counts[source]:
|
|
116
|
-
raise ValueError(f"line range {start}-{end} exceeds {relative}:{line_counts[source]}")
|
|
117
|
-
role = item.get("role")
|
|
118
|
-
if not isinstance(role, str) or role not in ROLES:
|
|
119
|
-
raise ValueError(f"role: unsupported value {role!r}")
|
|
120
|
-
key = (relative, start, end, role)
|
|
121
|
-
normalized[key] = {
|
|
122
|
-
"path": relative,
|
|
123
|
-
"start_line": start,
|
|
124
|
-
"end_line": end,
|
|
125
|
-
"role": role,
|
|
126
|
-
}
|
|
127
|
-
return sorted(
|
|
128
|
-
normalized.values(),
|
|
129
|
-
key=lambda item: (
|
|
130
|
-
ROLES[item["role"]],
|
|
131
|
-
item["path"],
|
|
132
|
-
item["start_line"],
|
|
133
|
-
item["end_line"],
|
|
134
|
-
),
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
def read_scope(path: Path, repo_root: Path, *, allow_missing: bool = False) -> set[str]:
|
|
139
|
-
contents = path.read_bytes().decode("utf-8")
|
|
140
|
-
lines = contents.split("\n")
|
|
141
|
-
listed_rows = set(lines)
|
|
142
|
-
|
|
143
|
-
def is_scope_file(value: str) -> bool:
|
|
144
|
-
try:
|
|
145
|
-
relative_file(value, repo_root)
|
|
146
|
-
except (OSError, ValueError):
|
|
147
|
-
return False
|
|
148
|
-
return True
|
|
149
|
-
|
|
150
|
-
carriage_rows = {
|
|
151
|
-
line: (is_scope_file(line), is_scope_file(line.removesuffix("\r")))
|
|
152
|
-
for line in lines
|
|
153
|
-
if line.endswith("\r") and line != "\r" and sys.platform != "win32"
|
|
154
|
-
}
|
|
155
|
-
crlf_evidence = any(line == "\r" for line in lines) or any(
|
|
156
|
-
stripped and not literal for literal, stripped in carriage_rows.values()
|
|
157
|
-
)
|
|
158
|
-
literal_evidence = any(literal and not stripped for literal, stripped in carriage_rows.values())
|
|
159
|
-
|
|
160
|
-
scope: set[str] = set()
|
|
161
|
-
for number, line in enumerate(lines, 1):
|
|
162
|
-
if sys.platform == "win32" or line == "\r":
|
|
163
|
-
line = line.removesuffix("\r")
|
|
164
|
-
elif line.endswith("\r"):
|
|
165
|
-
literal, stripped = carriage_rows[line]
|
|
166
|
-
if stripped and not literal:
|
|
167
|
-
line = line.removesuffix("\r")
|
|
168
|
-
elif stripped and literal:
|
|
169
|
-
if number == len(lines) and not contents.endswith("\n"):
|
|
170
|
-
pass
|
|
171
|
-
elif line.removesuffix("\r") in listed_rows:
|
|
172
|
-
pass
|
|
173
|
-
elif crlf_evidence and not literal_evidence:
|
|
174
|
-
line = line.removesuffix("\r")
|
|
175
|
-
elif literal_evidence and not crlf_evidence:
|
|
176
|
-
pass
|
|
177
|
-
else:
|
|
178
|
-
raise ValueError(f"in-scope file row {number}: ambiguous carriage-return paths")
|
|
179
|
-
elif not literal and crlf_evidence:
|
|
180
|
-
line = line.removesuffix("\r")
|
|
181
|
-
if not line:
|
|
182
|
-
continue
|
|
183
|
-
try:
|
|
184
|
-
relative, _ = relative_file(line, repo_root)
|
|
185
|
-
except (OSError, ValueError) as error:
|
|
186
|
-
if allow_missing and isinstance(error, FileNotFoundError):
|
|
187
|
-
candidate = PurePosixPath(line)
|
|
188
|
-
if candidate.is_absolute() or ".." in candidate.parts or "\0" in line:
|
|
189
|
-
raise ValueError(f"in-scope file row {number}: unsafe deleted path") from error
|
|
190
|
-
resolved = (repo_root / line).resolve(strict=False)
|
|
191
|
-
try:
|
|
192
|
-
relative = resolved.relative_to(repo_root).as_posix()
|
|
193
|
-
except ValueError as escaped:
|
|
194
|
-
raise ValueError(
|
|
195
|
-
f"in-scope file row {number}: path escapes repository"
|
|
196
|
-
) from escaped
|
|
197
|
-
scope.add(relative)
|
|
198
|
-
continue
|
|
199
|
-
raise ValueError(f"in-scope file row {number}: {error}") from error
|
|
200
|
-
scope.add(relative)
|
|
201
|
-
return scope
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
def normalize_candidate(
|
|
205
|
-
row: dict[str, Any], repo_root: Path, scope: set[str], line_counts: dict[Path, int]
|
|
206
|
-
) -> dict[str, Any]:
|
|
207
|
-
unknown = set(row) - FIELDS
|
|
208
|
-
if unknown:
|
|
209
|
-
raise ValueError(f"unsupported fields {', '.join(sorted(unknown))}")
|
|
210
|
-
if "candidate_id" in row:
|
|
211
|
-
text_field(row, "candidate_id")
|
|
212
|
-
candidate_locations = normalize_locations(row, repo_root, line_counts)
|
|
213
|
-
if not any(item["path"] in scope for item in candidate_locations):
|
|
214
|
-
raise ValueError("locations: expected at least one in-scope file")
|
|
215
|
-
result: dict[str, Any] = {
|
|
216
|
-
"cwe_ids": cwe_ids(row),
|
|
217
|
-
"locations": candidate_locations,
|
|
218
|
-
"summary": text_field(row, "summary"),
|
|
219
|
-
"evidence": text_field(row, "evidence"),
|
|
220
|
-
}
|
|
221
|
-
context = text_field(row, "context", required=False)
|
|
222
|
-
if context is not None:
|
|
223
|
-
result["context"] = context
|
|
224
|
-
instance = text_field(row, "instance", required=False)
|
|
225
|
-
if instance is not None:
|
|
226
|
-
result["instance"] = instance
|
|
227
|
-
return result
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
def identity(row: dict[str, Any]) -> str:
|
|
231
|
-
return json.dumps(
|
|
232
|
-
{
|
|
233
|
-
"cwe_ids": row["cwe_ids"],
|
|
234
|
-
"locations": row["locations"],
|
|
235
|
-
"instance": row.get("instance"),
|
|
236
|
-
},
|
|
237
|
-
ensure_ascii=False,
|
|
238
|
-
separators=(",", ":"),
|
|
239
|
-
sort_keys=True,
|
|
240
|
-
)
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
def merged_text(group: list[dict[str, Any]], field: str) -> str:
|
|
244
|
-
return "\n".join(sorted({item[field] for item in group if field in item}))
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
def combine(rows: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
|
248
|
-
groups: dict[str, list[dict[str, Any]]] = {}
|
|
249
|
-
for row in rows:
|
|
250
|
-
groups.setdefault(identity(row), []).append(row)
|
|
251
|
-
combined: list[dict[str, Any]] = []
|
|
252
|
-
for key, group in sorted(groups.items()):
|
|
253
|
-
candidate_id = hashlib.sha256(key.encode()).hexdigest()[:16]
|
|
254
|
-
|
|
255
|
-
result = {
|
|
256
|
-
"candidate_id": f"candidate-{candidate_id}",
|
|
257
|
-
"cwe_ids": group[0]["cwe_ids"],
|
|
258
|
-
"locations": group[0]["locations"],
|
|
259
|
-
"summary": merged_text(group, "summary"),
|
|
260
|
-
"evidence": merged_text(group, "evidence"),
|
|
261
|
-
}
|
|
262
|
-
context = merged_text(group, "context")
|
|
263
|
-
if context:
|
|
264
|
-
result["context"] = context
|
|
265
|
-
if "instance" in group[0]:
|
|
266
|
-
result["instance"] = group[0]["instance"]
|
|
267
|
-
combined.append(result)
|
|
268
|
-
return combined
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
def main() -> None:
|
|
272
|
-
parser = argparse.ArgumentParser(description=__doc__)
|
|
273
|
-
parser.add_argument("--input", nargs="+", required=True, help="Candidate JSONL inputs.")
|
|
274
|
-
parser.add_argument("--out", required=True, help="Combined candidate JSONL output.")
|
|
275
|
-
parser.add_argument("--repo-root", required=True, help="Repository root for candidate paths.")
|
|
276
|
-
parser.add_argument("--in-scope-files", required=True, help="Repository-relative file list.")
|
|
277
|
-
parser.add_argument(
|
|
278
|
-
"--allow-missing-in-scope",
|
|
279
|
-
action="store_true",
|
|
280
|
-
help="Keep deleted Git paths in a diff inventory while validating existing candidate files.",
|
|
281
|
-
)
|
|
282
|
-
args = parser.parse_args()
|
|
283
|
-
try:
|
|
284
|
-
repo_root = Path(args.repo_root).expanduser().resolve(strict=True)
|
|
285
|
-
if not repo_root.is_dir():
|
|
286
|
-
raise ValueError("--repo-root: expected a directory")
|
|
287
|
-
output = Path(args.out).expanduser().resolve(strict=False)
|
|
288
|
-
scope_path = Path(args.in_scope_files).expanduser().resolve(strict=True)
|
|
289
|
-
inputs = sorted({Path(value).expanduser().resolve(strict=True) for value in args.input})
|
|
290
|
-
if output in inputs:
|
|
291
|
-
raise ValueError("--out: must not also be an input")
|
|
292
|
-
if output == scope_path:
|
|
293
|
-
raise ValueError("--out: must not replace --in-scope-files")
|
|
294
|
-
scope = read_scope(scope_path, repo_root, allow_missing=args.allow_missing_in_scope)
|
|
295
|
-
line_counts: dict[Path, int] = {}
|
|
296
|
-
rows: list[dict[str, Any]] = []
|
|
297
|
-
for source in inputs:
|
|
298
|
-
with source.open(encoding="utf-8") as handle:
|
|
299
|
-
for number, line in enumerate(handle, 1):
|
|
300
|
-
if not line.strip():
|
|
301
|
-
continue
|
|
302
|
-
try:
|
|
303
|
-
row = json.loads(line)
|
|
304
|
-
if not isinstance(row, dict):
|
|
305
|
-
raise ValueError("expected a JSON object")
|
|
306
|
-
rows.append(normalize_candidate(row, repo_root, scope, line_counts))
|
|
307
|
-
except (ValueError, TypeError, OSError) as error:
|
|
308
|
-
raise ValueError(f"{source} row {number}: {error}") from error
|
|
309
|
-
combined = combine(rows)
|
|
310
|
-
output.parent.mkdir(parents=True, exist_ok=True)
|
|
311
|
-
temporary: Path | None = None
|
|
312
|
-
try:
|
|
313
|
-
with tempfile.NamedTemporaryFile(
|
|
314
|
-
mode="w",
|
|
315
|
-
encoding="utf-8",
|
|
316
|
-
dir=output.parent,
|
|
317
|
-
prefix=f".{output.name}.",
|
|
318
|
-
suffix=".tmp",
|
|
319
|
-
delete=False,
|
|
320
|
-
) as handle:
|
|
321
|
-
temporary = Path(handle.name)
|
|
322
|
-
for row in combined:
|
|
323
|
-
handle.write(
|
|
324
|
-
json.dumps(row, ensure_ascii=False, separators=(",", ":"), sort_keys=True)
|
|
325
|
-
+ "\n"
|
|
326
|
-
)
|
|
327
|
-
temporary.replace(output)
|
|
328
|
-
finally:
|
|
329
|
-
if temporary is not None:
|
|
330
|
-
temporary.unlink(missing_ok=True)
|
|
331
|
-
print(f"Combined {len(rows)} candidate rows into {len(combined)} rows in {output}")
|
|
332
|
-
except (OSError, ValueError) as error:
|
|
333
|
-
print(f"normalize_candidates: {error}", file=sys.stderr)
|
|
334
|
-
raise SystemExit(2) from error
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
if __name__ == "__main__":
|
|
338
|
-
main()
|