@openai/codex-security 0.9.1 → 0.10.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 +37 -788
- package/_bundled_plugin/.codex-plugin/plugin.json +2 -0
- package/_bundled_plugin/.mcp.json +2 -0
- package/_bundled_plugin/mcp/helpers.mjs.br +0 -0
- 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 +0 -0
- package/_bundled_plugin/references/artifact-storage.md +1 -1
- package/_bundled_plugin/references/baseline-auditor.md +18 -0
- package/_bundled_plugin/references/core-scan.md +5 -42
- package/_bundled_plugin/references/final-report.md +1 -1
- package/_bundled_plugin/references/focused-investigator.md +13 -0
- package/_bundled_plugin/references/scan-prologue.md +2 -2
- package/_bundled_plugin/references/scan-runtime.md +4 -2
- package/_bundled_plugin/references/security-guidance.md +14 -1
- package/_bundled_plugin/references/validate-scan-findings.md +3 -0
- package/_bundled_plugin/scripts/deep_scan_workbench.py +29 -12
- package/_bundled_plugin/scripts/dispatch_inventory_tool +7 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +29 -3
- package/_bundled_plugin/scripts/launch_codex_security_mcp +54 -16
- package/_bundled_plugin/scripts/posix_scan_local_files.py +26 -1
- package/_bundled_plugin/scripts/snapshot_sqlite.py +8 -2
- package/_bundled_plugin/scripts/windows_scan_local_files.py +216 -25
- package/_bundled_plugin/scripts/workbench/handoff.py +55 -25
- package/_bundled_plugin/scripts/workbench/storage.py +25 -5
- package/_bundled_plugin/scripts/workbench_cli.py +24 -2
- package/_bundled_plugin/scripts/workbench_constants.py +2 -0
- package/_bundled_plugin/scripts/workbench_db.py +244 -217
- package/_bundled_plugin/scripts/workbench_feedback.py +49 -4
- package/_bundled_plugin/scripts/workbench_native_indexes.py +226 -29
- package/_bundled_plugin/scripts/workbench_progress.py +159 -3
- package/_bundled_plugin/scripts/workbench_publication.py +2 -3
- package/_bundled_plugin/scripts/workbench_remediation.py +142 -2
- package/_bundled_plugin/scripts/workbench_saved_results.py +48 -8
- package/_bundled_plugin/scripts/workbench_scan_history.py +281 -119
- package/_bundled_plugin/scripts/workbench_scan_start.py +143 -9
- package/_bundled_plugin/scripts/workbench_scan_usage.py +36 -10
- package/_bundled_plugin/scripts/workbench_schema.py +220 -14
- package/_bundled_plugin/scripts/workbench_setup.py +1 -1
- package/_bundled_plugin/scripts/workbench_target.py +471 -84
- package/_bundled_plugin/scripts/workbench_target_state.py +1108 -22
- package/_bundled_plugin/shared/workbench-history-repairs.json +60 -14
- package/_bundled_plugin/shared/workbench-migrations.json +66 -0
- package/_bundled_plugin/skills/fix-finding/SKILL.md +1 -0
- package/_bundled_plugin/skills/publish-findings/SKILL.md +24 -160
- package/_bundled_plugin/skills/publish-findings/agents/openai.yaml +2 -2
- package/_bundled_plugin/skills/publish-findings/references/checkmarx-import.md +2 -2
- package/_bundled_plugin/skills/publish-findings/scripts/collect_checkmarx.py +3 -58
- package/_bundled_plugin/skills/publish-findings/scripts/collect_continuum.py +224 -0
- package/_bundled_plugin/skills/publish-findings/scripts/collector_paths.py +63 -0
- package/_bundled_plugin/skills/security-scan/SKILL.md +9 -46
- package/_bundled_plugin/skills/security-scan/agents/openai.yaml +2 -2
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +3 -21
- package/_bundled_plugin/skills/security-scan/references/managed-scan.md +11 -0
- package/_bundled_plugin/skills/security-scan/references/scan-results.md +15 -0
- package/_bundled_plugin/skills/security-scan/references/scoped-paths.md +23 -0
- package/_bundled_plugin/skills/security-scan/references/sdk-files.md +24 -0
- package/bin/codex-security.mjs +2 -2
- package/dist/api.d.ts +6 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +437 -154
- package/dist/api.js.map +1 -1
- package/dist/armorcode-findings.d.ts +9 -0
- package/dist/armorcode-findings.d.ts.map +1 -0
- package/dist/armorcode-findings.js +145 -0
- package/dist/armorcode-findings.js.map +1 -0
- package/dist/artifact-export.d.ts +2 -0
- package/dist/artifact-export.d.ts.map +1 -1
- package/dist/artifact-export.js +29 -13
- package/dist/artifact-export.js.map +1 -1
- package/dist/auth.d.ts +6 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +33 -12
- package/dist/auth.js.map +1 -1
- package/dist/batch-cost.d.ts +18 -0
- package/dist/batch-cost.d.ts.map +1 -0
- package/dist/batch-cost.js +41 -0
- package/dist/batch-cost.js.map +1 -0
- package/dist/blackduck-findings.d.ts +1 -1
- package/dist/blackduck-findings.d.ts.map +1 -1
- package/dist/blackduck-findings.js +5 -18
- package/dist/blackduck-findings.js.map +1 -1
- package/dist/bundled-plugin.d.ts +4 -0
- package/dist/bundled-plugin.d.ts.map +1 -0
- package/dist/bundled-plugin.js +23 -0
- package/dist/bundled-plugin.js.map +1 -0
- package/dist/classify-scan-severity.d.ts +1 -1
- package/dist/classify-scan-severity.d.ts.map +1 -1
- package/dist/classify-scan-severity.js +11 -3
- package/dist/classify-scan-severity.js.map +1 -1
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +9 -6
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-argument.d.ts +4 -0
- package/dist/cli-argument.d.ts.map +1 -0
- package/dist/cli-argument.js +17 -0
- package/dist/cli-argument.js.map +1 -0
- package/dist/cli-help.d.ts +1 -1
- package/dist/cli-help.d.ts.map +1 -1
- package/dist/cli-help.js +71 -29
- package/dist/cli-help.js.map +1 -1
- package/dist/cli-hook.d.ts +3 -0
- package/dist/cli-hook.d.ts.map +1 -0
- package/dist/cli-hook.js +87 -0
- package/dist/cli-hook.js.map +1 -0
- package/dist/cli-integrations.d.ts +13 -0
- package/dist/cli-integrations.d.ts.map +1 -0
- package/dist/cli-integrations.js +333 -0
- package/dist/cli-integrations.js.map +1 -0
- package/dist/cli-mcp.d.ts +15 -0
- package/dist/cli-mcp.d.ts.map +1 -0
- package/dist/cli-mcp.js +178 -0
- package/dist/cli-mcp.js.map +1 -0
- package/dist/cli-token-view.d.ts +10 -0
- package/dist/cli-token-view.d.ts.map +1 -0
- package/dist/cli-token-view.js +41 -0
- package/dist/cli-token-view.js.map +1 -0
- package/dist/cli.d.ts +5 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1763 -894
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +33 -31
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codex-sdk-environment.d.ts +6 -0
- package/dist/codex-sdk-environment.d.ts.map +1 -1
- package/dist/codex-sdk-environment.js +19 -0
- package/dist/codex-sdk-environment.js.map +1 -1
- package/dist/command-words.d.ts +3 -0
- package/dist/command-words.d.ts.map +1 -0
- package/dist/command-words.js +46 -0
- package/dist/command-words.js.map +1 -0
- package/dist/component-scan.d.ts +3 -1
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +40 -7
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +30 -1
- package/dist/config.js.map +1 -1
- package/dist/continuum-findings.d.ts +1 -1
- package/dist/continuum-findings.d.ts.map +1 -1
- package/dist/continuum-findings.js +93 -31
- package/dist/continuum-findings.js.map +1 -1
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +1 -45
- package/dist/cost.js.map +1 -1
- package/dist/custom-validation-prompt.d.ts +1 -1
- package/dist/custom-validation-prompt.d.ts.map +1 -1
- package/dist/custom-validation-prompt.js +29 -19
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/deduplication/local.d.ts +3 -1
- package/dist/deduplication/local.d.ts.map +1 -1
- package/dist/deduplication/local.js +8 -1
- package/dist/deduplication/local.js.map +1 -1
- package/dist/deduplication/refusal.d.ts.map +1 -1
- package/dist/deduplication/refusal.js +2 -1
- package/dist/deduplication/refusal.js.map +1 -1
- package/dist/deduplication/scan.d.ts +2 -0
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +24 -7
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-scan.d.ts.map +1 -1
- package/dist/deep-scan.js +16 -15
- package/dist/deep-scan.js.map +1 -1
- package/dist/endor-findings.d.ts +2 -2
- package/dist/endor-findings.d.ts.map +1 -1
- package/dist/endor-findings.js +6 -23
- package/dist/endor-findings.js.map +1 -1
- package/dist/errors.d.ts +3 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +7 -3
- package/dist/errors.js.map +1 -1
- package/dist/executable-path.d.ts +3 -0
- package/dist/executable-path.d.ts.map +1 -1
- package/dist/executable-path.js +26 -0
- package/dist/executable-path.js.map +1 -1
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +12 -1
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts +66 -4
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +234 -53
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +6 -1
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +326 -1633
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +1 -0
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +31 -51
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-findings.d.ts +1 -1
- package/dist/external-findings.d.ts.map +1 -1
- package/dist/external-findings.js +12 -1
- package/dist/external-findings.js.map +1 -1
- package/dist/external-import-contract.d.ts +3 -11
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +29 -176
- package/dist/external-import-contract.js.map +1 -1
- package/dist/external-import-models.d.ts +1 -1
- package/dist/external-import-models.d.ts.map +1 -1
- package/dist/external-import-models.js.map +1 -1
- package/dist/finding-prompt.d.ts.map +1 -1
- package/dist/finding-prompt.js +2 -2
- package/dist/finding-prompt.js.map +1 -1
- package/dist/github-dependabot-findings.d.ts.map +1 -1
- package/dist/github-dependabot-findings.js +3 -4
- package/dist/github-dependabot-findings.js.map +1 -1
- package/dist/github-findings.d.ts.map +1 -1
- package/dist/github-findings.js +19 -287
- package/dist/github-findings.js.map +1 -1
- package/dist/hosted-remediation.d.ts +1 -0
- package/dist/hosted-remediation.d.ts.map +1 -1
- package/dist/hosted-remediation.js +23 -3
- package/dist/hosted-remediation.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/inspector-findings.d.ts.map +1 -1
- package/dist/inspector-findings.js +19 -35
- package/dist/inspector-findings.js.map +1 -1
- package/dist/knowledge-base.d.ts +1 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +34 -27
- package/dist/knowledge-base.js.map +1 -1
- package/dist/linear.d.ts +11 -0
- package/dist/linear.d.ts.map +1 -1
- package/dist/linear.js.map +1 -1
- package/dist/local-git-metadata.d.ts +5 -2
- package/dist/local-git-metadata.d.ts.map +1 -1
- package/dist/local-git-metadata.js +8 -4
- package/dist/local-git-metadata.js.map +1 -1
- package/dist/multiscan.d.ts +4 -0
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +79 -37
- package/dist/multiscan.js.map +1 -1
- package/dist/opengrep-findings.d.ts +4 -2
- package/dist/opengrep-findings.d.ts.map +1 -1
- package/dist/opengrep-findings.js +39 -22
- package/dist/opengrep-findings.js.map +1 -1
- package/dist/private-finding-import.d.ts +8 -13
- package/dist/private-finding-import.d.ts.map +1 -1
- package/dist/private-finding-import.js +69 -129
- package/dist/private-finding-import.js.map +1 -1
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +53 -13
- package/dist/project-config.js.map +1 -1
- package/dist/prompt-files.d.ts +7 -2
- package/dist/prompt-files.d.ts.map +1 -1
- package/dist/prompt-files.js +42 -20
- package/dist/prompt-files.js.map +1 -1
- package/dist/provider-profile.d.ts.map +1 -1
- package/dist/provider-profile.js +4 -9
- package/dist/provider-profile.js.map +1 -1
- package/dist/publication.d.ts +1 -1
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js.map +1 -1
- package/dist/record.d.ts +1 -5
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +3 -51
- package/dist/record.js.map +1 -1
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +3 -1
- package/dist/remediation.js.map +1 -1
- package/dist/runtime.d.ts +35 -7
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +778 -153
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan-bootstrap.d.ts +6 -1
- package/dist/saved-scan-bootstrap.d.ts.map +1 -1
- package/dist/saved-scan-bootstrap.js +267 -115
- package/dist/saved-scan-bootstrap.js.map +1 -1
- package/dist/scan-archive-path.d.ts +2 -0
- package/dist/scan-archive-path.d.ts.map +1 -0
- package/dist/scan-archive-path.js +5 -0
- package/dist/scan-archive-path.js.map +1 -0
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +6 -2
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +1 -0
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +18 -2
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-executor.d.ts.map +1 -1
- package/dist/scan-executor.js +4 -2
- package/dist/scan-executor.js.map +1 -1
- package/dist/scan-history-renderer.d.ts +1 -0
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +25 -9
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +28 -4
- package/dist/scan-logs.js.map +1 -1
- package/dist/scanner-import.d.ts +5 -11
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +16 -89
- package/dist/scanner-import.js.map +1 -1
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js +26 -6
- package/dist/security-policy.js.map +1 -1
- package/dist/semgrep-findings.d.ts.map +1 -1
- package/dist/semgrep-findings.js +14 -48
- package/dist/semgrep-findings.js.map +1 -1
- package/dist/semgrep-platform-findings.d.ts +20 -70
- package/dist/semgrep-platform-findings.d.ts.map +1 -1
- package/dist/semgrep-platform-findings.js +116 -333
- package/dist/semgrep-platform-findings.js.map +1 -1
- package/dist/snyk-findings.d.ts +2 -0
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +5 -8
- package/dist/snyk-findings.js.map +1 -1
- package/dist/snyk-rest-findings.d.ts +3 -20
- package/dist/snyk-rest-findings.d.ts.map +1 -1
- package/dist/snyk-rest-findings.js +45 -217
- package/dist/snyk-rest-findings.js.map +1 -1
- package/dist/sonar-findings.d.ts +1 -1
- package/dist/sonar-findings.d.ts.map +1 -1
- package/dist/sonar-findings.js +2 -4
- package/dist/sonar-findings.js.map +1 -1
- package/dist/sonar-import.d.ts +3 -0
- package/dist/sonar-import.d.ts.map +1 -1
- package/dist/sonar-import.js +28 -30
- package/dist/sonar-import.js.map +1 -1
- package/dist/stored-finding-projection.d.ts +6 -0
- package/dist/stored-finding-projection.d.ts.map +1 -0
- package/dist/stored-finding-projection.js +104 -0
- package/dist/stored-finding-projection.js.map +1 -0
- package/dist/stored-findings-publication.d.ts +23 -0
- package/dist/stored-findings-publication.d.ts.map +1 -0
- package/dist/stored-findings-publication.js +169 -0
- package/dist/stored-findings-publication.js.map +1 -0
- package/dist/targets.d.ts +6 -1
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +76 -23
- package/dist/targets.js.map +1 -1
- package/dist/tenable-findings.d.ts +1 -4
- package/dist/tenable-findings.d.ts.map +1 -1
- package/dist/tenable-findings.js.map +1 -1
- package/dist/trivy-findings.d.ts.map +1 -1
- package/dist/trivy-findings.js +0 -11
- package/dist/trivy-findings.js.map +1 -1
- package/dist/trusted-executable.d.ts +6 -0
- package/dist/trusted-executable.d.ts.map +1 -1
- package/dist/trusted-executable.js +140 -37
- package/dist/trusted-executable.js.map +1 -1
- package/dist/veracode-findings.d.ts +1 -3
- package/dist/veracode-findings.d.ts.map +1 -1
- package/dist/veracode-findings.js +13 -38
- package/dist/veracode-findings.js.map +1 -1
- package/dist/version.d.ts +3 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +184 -32
- package/dist/version.js.map +1 -1
- package/dist/wiz-findings.d.ts +2 -2
- package/dist/wiz-findings.d.ts.map +1 -1
- package/dist/wiz-findings.js +14 -92
- package/dist/wiz-findings.js.map +1 -1
- package/docs/cli.md +373 -106
- package/docs/findings-service.md +22 -9
- package/docs/hosted-remediation.md +13 -4
- package/docs/sdk.md +903 -0
- package/package.json +10 -6
- package/schemas/external-findings.schema.json +2 -1
- package/dist/hosted-scanner-v1.d.ts +0 -6
- package/dist/hosted-scanner-v1.d.ts.map +0 -1
- package/dist/hosted-scanner-v1.js +0 -60
- package/dist/hosted-scanner-v1.js.map +0 -1
- package/dist/reader-selection.d.ts +0 -15
- package/dist/reader-selection.d.ts.map +0 -1
- package/dist/reader-selection.js +0 -89
- package/dist/reader-selection.js.map +0 -1
- package/dist/semgrep-platform-v1.d.ts +0 -6
- package/dist/semgrep-platform-v1.d.ts.map +0 -1
- package/dist/semgrep-platform-v1.js +0 -83
- package/dist/semgrep-platform-v1.js.map +0 -1
- package/dist/snyk-rest-v1.d.ts +0 -28
- package/dist/snyk-rest-v1.d.ts.map +0 -1
- package/dist/snyk-rest-v1.js +0 -132
- package/dist/snyk-rest-v1.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type JsonObject } from "./config.js";
|
|
2
|
-
export declare function customDiscoveryPrompt(pluginRoot: string, skillName: string): Promise<string>;
|
|
2
|
+
export declare function customDiscoveryPrompt(pluginRoot: string, skillName: string, standardHandoff: boolean): Promise<string>;
|
|
3
3
|
export declare function customValidationConfig(config: JsonObject, pluginRoot: string): Promise<JsonObject>;
|
|
4
4
|
//# sourceMappingURL=custom-validation-prompt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-validation-prompt.d.ts","sourceRoot":"","sources":["../src/custom-validation-prompt.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"custom-validation-prompt.d.ts","sourceRoot":"","sources":["../src/custom-validation-prompt.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAsFnE,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,OAAO,GACvB,OAAO,CAAC,MAAM,CAAC,CA4BjB;AAED,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,UAAU,EAClB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,UAAU,CAAC,CA+BrB"}
|
|
@@ -8,6 +8,7 @@ import { PLUGIN_NAME } from "./runtime.js";
|
|
|
8
8
|
// the ordinary validation sequence with a custom-validation request.
|
|
9
9
|
const SOURCES = {
|
|
10
10
|
"references/core-scan.md": [
|
|
11
|
+
"07abac7382a66338bfbe3def9a0e89e715a89561332c88ccb4477f97b6e84fe5",
|
|
11
12
|
"0e301a70d9f20acbb797f5eafcac84c09dd0513991714812d5c4f7b1f64a4a89",
|
|
12
13
|
"7690b6c854de07ff15984f6d2c25ddfa1f6ae65f65876cadf2f904054b4f0679",
|
|
13
14
|
"83bafdc4089803e631eaaa86ec57167c7da3f51794514d0dcdb62c5afdced8a7",
|
|
@@ -41,27 +42,36 @@ async function source(pluginRoot, name) {
|
|
|
41
42
|
function step(text, number) {
|
|
42
43
|
return text.match(new RegExp(`^${number}\\. (.+)$`, "m"))[1];
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
+
async function legacyDiscoveryPrompt(pluginRoot) {
|
|
46
|
+
const [skill, core] = await Promise.all([
|
|
47
|
+
source(pluginRoot, "skills/security-scan/SKILL.md"),
|
|
48
|
+
source(pluginRoot, "references/core-scan.md"),
|
|
49
|
+
]);
|
|
50
|
+
const discovery = core
|
|
51
|
+
.replace(/^7\. .+$/m, "7. Retain the combined source-backed candidates and their existing evidence. The SDK will run independent final validation in a separate turn.")
|
|
52
|
+
.replace(/^Keep discovery, validation, and attack-path reasoning.+$/m, "Keep source-evidence and counterevidence checks within discovery. Do not run an independent final validation pass or invoke separate phase skills.")
|
|
53
|
+
.replace("reconcile their evidence and submit the result;", "reconcile their evidence and preserve provisional candidates through the SDK-owned discovery handoff;");
|
|
54
|
+
return [
|
|
55
|
+
skill.slice(skill.indexOf("## Host And Setup"), skill.indexOf("## Workflow")),
|
|
56
|
+
"## Discovery workflow",
|
|
57
|
+
`1. ${step(skill, 1)}`,
|
|
58
|
+
"2. Perform the embedded core discovery workflow below. Do not reload the ordinary core-scan.md or top-level security-scan skill.",
|
|
59
|
+
`3. ${step(skill, 3).slice(step(skill, 3).indexOf("For an SDK-owned scan with a bound semantic draft tool,"))}`,
|
|
60
|
+
`4. ${HANDOFF}`,
|
|
61
|
+
"## Embedded core discovery workflow",
|
|
62
|
+
discovery,
|
|
63
|
+
].join("\n\n");
|
|
64
|
+
}
|
|
65
|
+
export async function customDiscoveryPrompt(pluginRoot, skillName, standardHandoff) {
|
|
45
66
|
let workflow;
|
|
46
67
|
if (skillName === "security-scan") {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
.
|
|
53
|
-
|
|
54
|
-
.replace("reconcile their evidence and submit the result;", "reconcile their evidence and preserve provisional candidates through the SDK-owned discovery handoff;");
|
|
55
|
-
workflow = [
|
|
56
|
-
skill.slice(skill.indexOf("## Host And Setup"), skill.indexOf("## Workflow")),
|
|
57
|
-
"## Discovery workflow",
|
|
58
|
-
`1. ${step(skill, 1)}`,
|
|
59
|
-
"2. Perform the embedded core discovery workflow below. Do not reload the ordinary core-scan.md or top-level security-scan skill.",
|
|
60
|
-
`3. ${step(skill, 3).slice(step(skill, 3).indexOf("For an SDK-owned scan with a bound semantic draft tool,"))}`,
|
|
61
|
-
`4. ${HANDOFF}`,
|
|
62
|
-
"## Embedded core discovery workflow",
|
|
63
|
-
discovery,
|
|
64
|
-
].join("\n\n");
|
|
68
|
+
workflow = standardHandoff
|
|
69
|
+
? [
|
|
70
|
+
"Use <plugin_dir>/references/core-scan.md for source discovery. This caller supplies the validation handoff: the SDK runs independent final validation in a separate turn. Check source evidence and counterevidence now, but do not run the default validation pass.",
|
|
71
|
+
"Keep any supplied investigation time allowance unchanged. Only for an explicit time request with no existing allowance, render <plugin_dir>/references/investigation-time-budget.md once before source review.",
|
|
72
|
+
HANDOFF,
|
|
73
|
+
].join("\n\n")
|
|
74
|
+
: await legacyDiscoveryPrompt(pluginRoot);
|
|
65
75
|
}
|
|
66
76
|
else if (skillName === "security-diff-scan") {
|
|
67
77
|
const skill = await source(pluginRoot, "skills/security-diff-scan/SKILL.md");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-validation-prompt.js","sourceRoot":"","sources":["../src/custom-validation-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAmB,MAAM,aAAa,CAAC;AAC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["import { createHash } from \"node:crypto\";\nimport { readFile } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport { resolveCodexProfile, type JsonObject } from \"./config.js\";\nimport { IncompleteScanError } from \"./errors.js\";\nimport { PLUGIN_NAME } from \"./runtime.js\";\n\n// Review this adapter when the bundled workflows change. Never silently run\n// the ordinary validation sequence with a custom-validation request.\nconst SOURCES = {\n \"references/core-scan.md\": [\n \"0e301a70d9f20acbb797f5eafcac84c09dd0513991714812d5c4f7b1f64a4a89\",\n \"7690b6c854de07ff15984f6d2c25ddfa1f6ae65f65876cadf2f904054b4f0679\",\n \"83bafdc4089803e631eaaa86ec57167c7da3f51794514d0dcdb62c5afdced8a7\",\n \"848eb40d42b0bf9cf21748b9927d031b0461a4443f63e3954139f9801f41c3f6\",\n ],\n \"skills/security-scan/SKILL.md\": [\n \"b6a69658d48fff6979d6690e95d2096da236bb7e51b96ebb4f92102a9863d66c\",\n \"99cfcbbaa9d5b0450881ec752a116888b05b7fe21ea7af28fd22d088882dcd46\",\n ],\n \"skills/security-diff-scan/SKILL.md\": [\n \"09232fd5d96cfed2a5bdccd176c09b7e9ca53ebd7ac136d283bec884fde94b0d\",\n ],\n};\n\nconst DISABLED_TOOLS = [\n \"start_codex_security_standard_scan\",\n \"start_codex_security_prompt_only_scan\",\n \"start_codex_security_deep_scan\",\n \"complete_codex_security_scan\",\n \"record_codex_security_candidate_validations\",\n \"record_candidate_attack_paths\",\n];\n\nconst HANDOFF =\n \"Preserve every surviving source-backed candidate as a provisional finding, including its identity, source locations, evidence, counterevidence, and preliminary assessments. Assemble unsealed scan-manifest.json and findings.json using <plugin_dir>/examples/completed-scan/ and <plugin_dir>/schemas/ as shape references. Put candidate dispositions and pending work in scan.reviewState. Set scan.scope.validationMode to custom_pending and put each finding's matching review-state surface IDs in extensions.customValidationSurfaceIds. Every reported review-state surface must have a candidate. When source discovery finishes and a bound semantic draft tool is available, submit an accepted final source-discovery draft with complete: true, preserving the provisional findings, reviewState, threat model, and custom_pending validation mode. This marks source discovery finished; it does not claim custom validation has occurred or seal the scan. Keep complete: false when requested source review remains unfinished. Verify both files exist, then return control to the SDK without invoking validation or attack-path skills, running application code, sealing files, generating a report, or calling a scan completion tool or helper.\";\n\nasync function source(pluginRoot: string, name: keyof typeof SOURCES) {\n const text = (await readFile(join(pluginRoot, name), \"utf8\")).replaceAll(\n \"\\r\\n\",\n \"\\n\",\n );\n const digest = createHash(\"sha256\").update(text).digest(\"hex\");\n if (!SOURCES[name].includes(digest)) {\n throw new IncompleteScanError(\n `Custom validation is incompatible with the installed plugin workflow (${name}). Update the SDK and plugin together. Default validation was not started.`,\n );\n }\n return text;\n}\n\nfunction step(text: string, number: number): string {\n return text.match(new RegExp(`^${number}\\\\. (.+)$`, \"m\"))![1]!;\n}\n\nexport async function customDiscoveryPrompt(\n pluginRoot: string,\n skillName: string,\n): Promise<string> {\n let workflow: string;\n if (skillName === \"security-scan\") {\n const [skill, core] = await Promise.all([\n source(pluginRoot, \"skills/security-scan/SKILL.md\"),\n source(pluginRoot, \"references/core-scan.md\"),\n ]);\n const discovery = core\n .replace(\n /^7\\. .+$/m,\n \"7. Retain the combined source-backed candidates and their existing evidence. The SDK will run independent final validation in a separate turn.\",\n )\n .replace(\n /^Keep discovery, validation, and attack-path reasoning.+$/m,\n \"Keep source-evidence and counterevidence checks within discovery. Do not run an independent final validation pass or invoke separate phase skills.\",\n )\n .replace(\n \"reconcile their evidence and submit the result;\",\n \"reconcile their evidence and preserve provisional candidates through the SDK-owned discovery handoff;\",\n );\n workflow = [\n skill.slice(\n skill.indexOf(\"## Host And Setup\"),\n skill.indexOf(\"## Workflow\"),\n ),\n \"## Discovery workflow\",\n `1. ${step(skill, 1)}`,\n \"2. Perform the embedded core discovery workflow below. Do not reload the ordinary core-scan.md or top-level security-scan skill.\",\n `3. ${step(skill, 3).slice(step(skill, 3).indexOf(\"For an SDK-owned scan with a bound semantic draft tool,\"))}`,\n `4. ${HANDOFF}`,\n \"## Embedded core discovery workflow\",\n discovery,\n ].join(\"\\n\\n\");\n } else if (skillName === \"security-diff-scan\") {\n const skill = await source(\n pluginRoot,\n \"skills/security-diff-scan/SKILL.md\",\n );\n workflow = [\n skill.slice(skill.indexOf(\"## Setup\"), skill.indexOf(\"\\n4. \")),\n `4. ${HANDOFF} Use diff for scan.mode.`,\n ].join(\"\\n\\n\");\n } else {\n throw new IncompleteScanError(\n \"Custom validation is not supported for this scan workflow.\",\n );\n }\n return [\n \"Follow this SDK-owned discovery workflow, derived from the installed plugin. It replaces the ordinary top-level scan skill for this turn. The SDK owns the separate custom validation pass and all completion. <plugin_dir> is CODEX_SECURITY_PLUGIN_ROOT; other bare reference filenames are relative to its references directory.\",\n workflow.replaceAll(\"../../references/\", \"<plugin_dir>/references/\"),\n ].join(\"\\n\\n\");\n}\n\nexport async function customValidationConfig(\n config: JsonObject,\n pluginRoot: string,\n): Promise<JsonObject> {\n config = resolveCodexProfile(config);\n const manifest = JSON.parse(\n await readFile(join(pluginRoot, \".mcp.json\"), \"utf8\"),\n );\n const server = manifest.mcpServers[PLUGIN_NAME];\n const servers = (config[\"mcp_servers\"] ?? {}) as JsonObject;\n const configured = (servers[PLUGIN_NAME] ?? {}) as JsonObject;\n // The pinned Codex applies this per-invocation server entry ahead of the\n // installed plugin. Plugin-specific command-line policy overrides do not.\n return {\n ...config,\n mcp_servers: {\n ...servers,\n [PLUGIN_NAME]: {\n ...server,\n ...configured,\n cwd: resolve(\n pluginRoot,\n (configured[\"cwd\"] as string | undefined) ?? server.cwd ?? \".\",\n ),\n disabled_tools: [\n ...new Set([\n ...(server.disabled_tools ?? []),\n ...((configured[\"disabled_tools\"] ?? []) as string[]),\n ...DISABLED_TOOLS,\n ]),\n ],\n },\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"custom-validation-prompt.js","sourceRoot":"","sources":["../src/custom-validation-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO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,WAAW,CAAC,EAAE;gBACb,GAAG,MAAM;gBACT,GAAG,UAAU;gBACb,GAAG,EAAE,OAAO,CACV,UAAU,EACT,UAAU,CAAC,KAAK,CAAwB,IAAI,MAAM,CAAC,GAAG,IAAI,GAAG,CAC/D;gBACD,cAAc,EAAE;oBACd,GAAG,IAAI,GAAG,CAAC;wBACT,GAAG,CAAC,MAAM,CAAC,cAAc,IAAI,EAAE,CAAC;wBAChC,GAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAc;wBACrD,GAAG,cAAc;qBAClB,CAAC;iBACH;aACF;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { readFile } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport { resolveCodexProfile, type JsonObject } from \"./config.js\";\nimport { IncompleteScanError } from \"./errors.js\";\nimport { PLUGIN_NAME } from \"./runtime.js\";\n\n// Review this adapter when the bundled workflows change. Never silently run\n// the ordinary validation sequence with a custom-validation request.\nconst SOURCES = {\n \"references/core-scan.md\": [\n \"07abac7382a66338bfbe3def9a0e89e715a89561332c88ccb4477f97b6e84fe5\",\n \"0e301a70d9f20acbb797f5eafcac84c09dd0513991714812d5c4f7b1f64a4a89\",\n \"7690b6c854de07ff15984f6d2c25ddfa1f6ae65f65876cadf2f904054b4f0679\",\n \"83bafdc4089803e631eaaa86ec57167c7da3f51794514d0dcdb62c5afdced8a7\",\n \"848eb40d42b0bf9cf21748b9927d031b0461a4443f63e3954139f9801f41c3f6\",\n ],\n \"skills/security-scan/SKILL.md\": [\n \"b6a69658d48fff6979d6690e95d2096da236bb7e51b96ebb4f92102a9863d66c\",\n \"99cfcbbaa9d5b0450881ec752a116888b05b7fe21ea7af28fd22d088882dcd46\",\n ],\n \"skills/security-diff-scan/SKILL.md\": [\n \"09232fd5d96cfed2a5bdccd176c09b7e9ca53ebd7ac136d283bec884fde94b0d\",\n ],\n};\n\nconst DISABLED_TOOLS = [\n \"start_codex_security_standard_scan\",\n \"start_codex_security_prompt_only_scan\",\n \"start_codex_security_deep_scan\",\n \"complete_codex_security_scan\",\n \"record_codex_security_candidate_validations\",\n \"record_candidate_attack_paths\",\n];\n\nconst HANDOFF =\n \"Preserve every surviving source-backed candidate as a provisional finding, including its identity, source locations, evidence, counterevidence, and preliminary assessments. Assemble unsealed scan-manifest.json and findings.json using <plugin_dir>/examples/completed-scan/ and <plugin_dir>/schemas/ as shape references. Put candidate dispositions and pending work in scan.reviewState. Set scan.scope.validationMode to custom_pending and put each finding's matching review-state surface IDs in extensions.customValidationSurfaceIds. Every reported review-state surface must have a candidate. When source discovery finishes and a bound semantic draft tool is available, submit an accepted final source-discovery draft with complete: true, preserving the provisional findings, reviewState, threat model, and custom_pending validation mode. This marks source discovery finished; it does not claim custom validation has occurred or seal the scan. Keep complete: false when requested source review remains unfinished. Verify both files exist, then return control to the SDK without invoking validation or attack-path skills, running application code, sealing files, generating a report, or calling a scan completion tool or helper.\";\n\nasync function source(pluginRoot: string, name: keyof typeof SOURCES) {\n const text = (await readFile(join(pluginRoot, name), \"utf8\")).replaceAll(\n \"\\r\\n\",\n \"\\n\",\n );\n const digest = createHash(\"sha256\").update(text).digest(\"hex\");\n if (!SOURCES[name].includes(digest)) {\n throw new IncompleteScanError(\n `Custom validation is incompatible with the installed plugin workflow (${name}). Update the SDK and plugin together. Default validation was not started.`,\n );\n }\n return text;\n}\n\nfunction step(text: string, number: number): string {\n return text.match(new RegExp(`^${number}\\\\. (.+)$`, \"m\"))![1]!;\n}\n\nasync function legacyDiscoveryPrompt(pluginRoot: string) {\n const [skill, core] = await Promise.all([\n source(pluginRoot, \"skills/security-scan/SKILL.md\"),\n source(pluginRoot, \"references/core-scan.md\"),\n ]);\n const discovery = core\n .replace(\n /^7\\. .+$/m,\n \"7. Retain the combined source-backed candidates and their existing evidence. The SDK will run independent final validation in a separate turn.\",\n )\n .replace(\n /^Keep discovery, validation, and attack-path reasoning.+$/m,\n \"Keep source-evidence and counterevidence checks within discovery. Do not run an independent final validation pass or invoke separate phase skills.\",\n )\n .replace(\n \"reconcile their evidence and submit the result;\",\n \"reconcile their evidence and preserve provisional candidates through the SDK-owned discovery handoff;\",\n );\n return [\n skill.slice(\n skill.indexOf(\"## Host And Setup\"),\n skill.indexOf(\"## Workflow\"),\n ),\n \"## Discovery workflow\",\n `1. ${step(skill, 1)}`,\n \"2. Perform the embedded core discovery workflow below. Do not reload the ordinary core-scan.md or top-level security-scan skill.\",\n `3. ${step(skill, 3).slice(step(skill, 3).indexOf(\"For an SDK-owned scan with a bound semantic draft tool,\"))}`,\n `4. ${HANDOFF}`,\n \"## Embedded core discovery workflow\",\n discovery,\n ].join(\"\\n\\n\");\n}\n\nexport async function customDiscoveryPrompt(\n pluginRoot: string,\n skillName: string,\n standardHandoff: boolean,\n): Promise<string> {\n let workflow: string;\n if (skillName === \"security-scan\") {\n workflow = standardHandoff\n ? [\n \"Use <plugin_dir>/references/core-scan.md for source discovery. This caller supplies the validation handoff: the SDK runs independent final validation in a separate turn. Check source evidence and counterevidence now, but do not run the default validation pass.\",\n \"Keep any supplied investigation time allowance unchanged. Only for an explicit time request with no existing allowance, render <plugin_dir>/references/investigation-time-budget.md once before source review.\",\n HANDOFF,\n ].join(\"\\n\\n\")\n : await legacyDiscoveryPrompt(pluginRoot);\n } else if (skillName === \"security-diff-scan\") {\n const skill = await source(\n pluginRoot,\n \"skills/security-diff-scan/SKILL.md\",\n );\n workflow = [\n skill.slice(skill.indexOf(\"## Setup\"), skill.indexOf(\"\\n4. \")),\n `4. ${HANDOFF} Use diff for scan.mode.`,\n ].join(\"\\n\\n\");\n } else {\n throw new IncompleteScanError(\n \"Custom validation is not supported for this scan workflow.\",\n );\n }\n return [\n \"Follow this SDK-owned discovery workflow, derived from the installed plugin. It replaces the ordinary top-level scan skill for this turn. The SDK owns the separate custom validation pass and all completion. <plugin_dir> is CODEX_SECURITY_PLUGIN_ROOT; other bare reference filenames are relative to its references directory.\",\n workflow.replaceAll(\"../../references/\", \"<plugin_dir>/references/\"),\n ].join(\"\\n\\n\");\n}\n\nexport async function customValidationConfig(\n config: JsonObject,\n pluginRoot: string,\n): Promise<JsonObject> {\n config = resolveCodexProfile(config);\n const manifest = JSON.parse(\n await readFile(join(pluginRoot, \".mcp.json\"), \"utf8\"),\n );\n const server = manifest.mcpServers[PLUGIN_NAME];\n const servers = (config[\"mcp_servers\"] ?? {}) as JsonObject;\n const configured = (servers[PLUGIN_NAME] ?? {}) as JsonObject;\n // The pinned Codex applies this per-invocation server entry ahead of the\n // installed plugin. Plugin-specific command-line policy overrides do not.\n return {\n ...config,\n mcp_servers: {\n ...servers,\n [PLUGIN_NAME]: {\n ...server,\n ...configured,\n cwd: resolve(\n pluginRoot,\n (configured[\"cwd\"] as string | undefined) ?? server.cwd ?? \".\",\n ),\n disabled_tools: [\n ...new Set([\n ...(server.disabled_tools ?? []),\n ...((configured[\"disabled_tools\"] ?? []) as string[]),\n ...DISABLED_TOOLS,\n ]),\n ],\n },\n },\n };\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Finding } from "../models.js";
|
|
2
2
|
import type { FindingNeighborhood, FindingSearchScope } from "../finding-retrieval.js";
|
|
3
|
+
import type { SavedToolDiscovery } from "../saved-scan-bootstrap.js";
|
|
3
4
|
import { runWorkbench } from "../runtime.js";
|
|
4
5
|
import { type FindingEmbedder, type EmbeddingUsageObserver } from "../server/embeddings.js";
|
|
5
6
|
/** One vector space and the adapter that produces its embeddings. */
|
|
@@ -17,11 +18,12 @@ export declare class LocalDeduplication {
|
|
|
17
18
|
private readonly repositoryPath;
|
|
18
19
|
private readonly signal?;
|
|
19
20
|
private readonly workbench;
|
|
21
|
+
private readonly nodeDiscovery?;
|
|
20
22
|
private options?;
|
|
21
23
|
private cacheKeys;
|
|
22
24
|
private readonly space;
|
|
23
25
|
private readonly embedding;
|
|
24
|
-
constructor(environment: NodeJS.ProcessEnv, scope: FindingSearchScope, repositoryPath: string, signal?: AbortSignal | undefined, workbench?: typeof runWorkbench, embedding?: FindingEmbeddingBinding, onEmbeddingUsage?: EmbeddingUsageObserver);
|
|
26
|
+
constructor(environment: NodeJS.ProcessEnv, scope: FindingSearchScope, repositoryPath: string, signal?: AbortSignal | undefined, workbench?: typeof runWorkbench, embedding?: FindingEmbeddingBinding, onEmbeddingUsage?: EmbeddingUsageObserver, nodeDiscovery?: SavedToolDiscovery | undefined);
|
|
25
27
|
get inputDigest(): string;
|
|
26
28
|
prepare(findings: readonly Finding[], repositoryId: string): Promise<void>;
|
|
27
29
|
potentialDuplicates(findingId: string): Promise<FindingNeighborhood>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../src/deduplication/local.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../src/deduplication/local.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE,OAAO,EAGL,YAAY,EAEb,MAAM,eAAe,CAAC;AACvB,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC5B,MAAM,yBAAyB,CAAC;AAMjC,qEAAqE;AACrE,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,2FAA2F;IAC3F,QAAQ,CAAC,cAAc,EAA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{};
|
|
19
20
|
space;
|
|
20
21
|
embedding;
|
|
21
|
-
constructor(environment, scope, repositoryPath, signal, workbench = runWorkbench, embedding, onEmbeddingUsage) {
|
|
22
|
+
constructor(environment, scope, repositoryPath, signal, workbench = runWorkbench, embedding, onEmbeddingUsage, nodeDiscovery) {
|
|
22
23
|
this.environment = environment;
|
|
23
24
|
this.scope = scope;
|
|
24
25
|
this.repositoryPath = repositoryPath;
|
|
25
26
|
this.signal = signal;
|
|
26
27
|
this.workbench = workbench;
|
|
28
|
+
this.nodeDiscovery = nodeDiscovery;
|
|
27
29
|
const endpoint = environmentEntry(environment, "CODEX_SECURITY_EMBEDDINGS_URL") ||
|
|
28
30
|
EMBEDDINGS_URL;
|
|
29
31
|
this.embedding = embedding ?? {
|
|
@@ -88,6 +90,10 @@ export class LocalDeduplication {
|
|
|
88
90
|
async command(payload) {
|
|
89
91
|
this.signal?.throwIfAborted();
|
|
90
92
|
this.options ??= (async () => {
|
|
93
|
+
// Bun finds Node on PATH. Native Node helpers use the running process executable.
|
|
94
|
+
if (process.versions["bun"] &&
|
|
95
|
+
this.nodeDiscovery?.allowPathLookup === false)
|
|
96
|
+
throw new CodexSecurityError("Could not establish the saved checkout boundary for Node.js discovery. Run local deduplication with Node.js.");
|
|
91
97
|
const environment = workbenchEnvironment(this.environment);
|
|
92
98
|
return {
|
|
93
99
|
pluginRoot: await bundledPluginRoot(),
|
|
@@ -95,6 +101,7 @@ export class LocalDeduplication {
|
|
|
95
101
|
environment,
|
|
96
102
|
signal: this.signal,
|
|
97
103
|
protectedRoot: [
|
|
104
|
+
...(this.nodeDiscovery?.protectedRoots ?? []),
|
|
98
105
|
this.repositoryPath,
|
|
99
106
|
...(await gitProtectionRoots(this.repositoryPath, this.signal)),
|
|
100
107
|
...(await gitProtectionRoots(process.cwd(), this.signal)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/deduplication/local.ts"],"names":[],"mappings":"AAAA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C,OAAO,CAAC;oBAAE,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACjE,CAAC;YACD,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;YAC9B,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,YAAY,SAAS,CAAC;gBAAE,MAAM,KAAK,CAAC;QAClE,CAAC;QACD,MAAM,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,IAAI,SAAS,CAAC,CAAC;IACtD,CAAC;AACH,CAAC","sourcesContent":["import { environmentEntry } from \"../auth.js\";\nimport { abortable, gitProtectionRoots } from \"../targets.js\";\nimport type { Finding } from \"../models.js\";\nimport type {\n FindingNeighborhood,\n FindingSearchScope,\n} from \"../finding-retrieval.js\";\nimport { CodexSecurityError } from \"../errors.js\";\nimport { workflowDigest } from \"../finding-workflow.js\";\nimport {\n bundledPluginRoot,\n workbenchEnvironment,\n runWorkbench,\n type WorkbenchCommandOptions,\n} from \"../runtime.js\";\nimport {\n OpenAiFindingEmbedder,\n EMBEDDING_MODEL,\n EMBEDDING_DIMENSIONS,\n EMBEDDINGS_URL,\n type FindingEmbedder,\n type EmbeddingUsageObserver,\n} from \"../server/embeddings.js\";\nimport { retryDelay, waitForRetry } from \"./retry.js\";\n\n// Checkpoint bounded batches so a retry keeps completed work without one process per finding.\nconst EMBEDDING_BATCH_SIZE = 64;\n\n/** One vector space and the adapter that produces its embeddings. */\nexport interface FindingEmbeddingBinding {\n readonly embedder: FindingEmbedder;\n readonly model: string;\n readonly dimensions: number;\n /** Identifies the provider/vector space and preprocessing version; exclude credentials. */\n readonly cacheNamespace: string;\n}\n\n/** Direct workbench adapter. Importing it starts no HTTP or MCP server. */\nexport class LocalDeduplication {\n private options?: Promise<Omit<WorkbenchCommandOptions, \"python\">>;\n private cacheKeys: Record<string, string> = {};\n private readonly space: string;\n private readonly embedding: FindingEmbeddingBinding;\n\n constructor(\n private readonly environment: NodeJS.ProcessEnv,\n private readonly scope: FindingSearchScope,\n private readonly repositoryPath: string,\n private readonly signal?: AbortSignal,\n private readonly workbench: typeof runWorkbench = runWorkbench,\n embedding?: FindingEmbeddingBinding,\n onEmbeddingUsage?: EmbeddingUsageObserver,\n ) {\n const endpoint =\n environmentEntry(environment, \"CODEX_SECURITY_EMBEDDINGS_URL\") ||\n EMBEDDINGS_URL;\n this.embedding = embedding ?? {\n model: EMBEDDING_MODEL,\n dimensions: EMBEDDING_DIMENSIONS,\n cacheNamespace: endpoint,\n embedder: new OpenAiFindingEmbedder(\n [\n environmentEntry(environment, \"OPENAI_API_KEY\"),\n environmentEntry(environment, \"CODEX_API_KEY\"),\n ].find((value) => value?.trim()),\n embeddingRequest,\n endpoint,\n signal,\n onEmbeddingUsage,\n ),\n };\n // The digest keeps endpoint/namespace details out of persisted cache keys.\n this.space = workflowDigest({\n version: 1,\n model: this.embedding.model,\n dimensions: this.embedding.dimensions,\n namespace: this.embedding.cacheNamespace,\n });\n }\n\n get inputDigest(): string {\n return workflowDigest(this.cacheKeys);\n }\n\n async prepare(\n findings: readonly Finding[],\n repositoryId: string,\n ): Promise<void> {\n const result = await this.command({\n action: \"prepare\",\n findings,\n anchorRepositoryId: repositoryId,\n repositoryPath: this.repositoryPath,\n });\n this.cacheKeys = result[\"cacheKeys\"] as Record<string, string>;\n const findingsToEmbed = result[\"findingsToEmbed\"] as unknown as Finding[];\n for (\n let offset = 0;\n offset < findingsToEmbed.length;\n offset += EMBEDDING_BATCH_SIZE\n ) {\n this.signal?.throwIfAborted();\n const batch = findingsToEmbed.slice(\n offset,\n offset + EMBEDDING_BATCH_SIZE,\n );\n const embeddings = await abortable(() => {\n this.signal?.throwIfAborted();\n return this.embedding.embedder.embed(batch);\n }, this.signal);\n this.signal?.throwIfAborted();\n if (embeddings.length !== batch.length)\n throw new CodexSecurityError(\n \"Embedding provider returned an invalid number of vectors.\",\n );\n await this.command({\n action: \"embed\",\n entries: batch.map((finding, index) => ({\n findingId: finding.findingId,\n cacheKey: this.cacheKeys[finding.findingId],\n embedding: embeddings[index],\n })),\n });\n }\n }\n\n async potentialDuplicates(findingId: string): Promise<FindingNeighborhood> {\n return (await this.command({\n action: \"neighbors\",\n findingId,\n cacheKeys: this.cacheKeys,\n })) as unknown as FindingNeighborhood;\n }\n\n async storeDedupeGroups(groups: readonly string[][]): Promise<void> {\n await this.command({ action: \"commit\", groups, cacheKeys: this.cacheKeys });\n }\n\n private async command(payload: { action: string; [key: string]: unknown }) {\n this.signal?.throwIfAborted();\n this.options ??= (async () => {\n const environment = workbenchEnvironment(this.environment);\n return {\n pluginRoot: await bundledPluginRoot(),\n stateDirectory: environment.CODEX_SECURITY_STATE_DIR,\n environment,\n signal: this.signal,\n protectedRoot: [\n this.repositoryPath,\n ...(await gitProtectionRoots(this.repositoryPath, this.signal)),\n ...(await gitProtectionRoots(process.cwd(), this.signal)),\n ],\n failureMessage: \"Could not access local deduplication state\",\n };\n })();\n const result = await this.workbench(\n await this.options,\n [\n payload.action === \"neighbors\"\n ? \"find-potential-duplicates\"\n : payload.action === \"commit\"\n ? \"store-dedupe-groups\"\n : \"local-dedupe\",\n ],\n JSON.stringify({\n ...payload,\n scope: this.scope,\n space: this.space,\n model: this.embedding.model,\n dimensions: this.embedding.dimensions,\n ...(this.scope.allRepositories\n ? {}\n : { repositoryId: this.scope.repositoryId }),\n }),\n );\n this.signal?.throwIfAborted();\n const code = result[\"error\"];\n if (code !== undefined) {\n const message =\n code === \"finding_changed\"\n ? \"Findings changed during local deduplication. Retry with a new workflow ID if resuming.\"\n : code === \"target_mismatch\"\n ? \"The scan target does not match the approved local checkout. Use its original checkout or an explicitly configured findings service.\"\n : code === \"finding_not_indexed\"\n ? \"A local finding has no complete document. Reimport its scan before deduplicating.\"\n : `Local deduplication failed: ${String(code)}.`;\n throw new CodexSecurityError(message);\n }\n return result;\n }\n}\n\nasync function embeddingRequest(\n url: string,\n init: RequestInit,\n): Promise<Response> {\n for (let attempt = 1; ; attempt++) {\n init.signal?.throwIfAborted();\n let delay = retryDelay(attempt);\n try {\n const response = await fetch(url, init);\n if (\n attempt === 3 ||\n ![408, 429, 500, 502, 503, 504].includes(response.status)\n )\n return response;\n const retryAfter = response.headers.get(\"Retry-After\");\n if (retryAfter !== null) {\n const seconds = Number(retryAfter);\n const retryAt = Number.isFinite(seconds)\n ? seconds * 1000\n : Date.parse(retryAfter) - Date.now();\n if (Number.isFinite(retryAt)) delay = Math.max(delay, retryAt);\n }\n await response.body?.cancel().catch(() => undefined);\n } catch (error) {\n init.signal?.throwIfAborted();\n if (attempt === 3 || !(error instanceof TypeError)) throw error;\n }\n await waitForRetry(delay, init.signal ?? undefined);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/deduplication/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAM9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,GAEb,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,cAAc,GAGf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEtD,8FAA8F;AAC9F,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAWhC,2EAA2E;AAC3E,MAAM,OAAO,kBAAkB;IAOV,WAAW;IACX,KAAK;IACL,cAAc;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YAC9B,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,YAAY,SAAS,CAAC;gBAAE,MAAM,KAAK,CAAC;QAClE,CAAC;QACD,MAAM,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,IAAI,SAAS,CAAC,CAAC;IACtD,CAAC;AACH,CAAC","sourcesContent":["import { environmentEntry } from \"../auth.js\";\nimport { abortable, gitProtectionRoots } from \"../targets.js\";\nimport type { Finding } from \"../models.js\";\nimport type {\n FindingNeighborhood,\n FindingSearchScope,\n} from \"../finding-retrieval.js\";\nimport { CodexSecurityError } from \"../errors.js\";\nimport type { SavedToolDiscovery } from \"../saved-scan-bootstrap.js\";\nimport { workflowDigest } from \"../finding-workflow.js\";\nimport {\n bundledPluginRoot,\n workbenchEnvironment,\n runWorkbench,\n type WorkbenchCommandOptions,\n} from \"../runtime.js\";\nimport {\n OpenAiFindingEmbedder,\n EMBEDDING_MODEL,\n EMBEDDING_DIMENSIONS,\n EMBEDDINGS_URL,\n type FindingEmbedder,\n type EmbeddingUsageObserver,\n} from \"../server/embeddings.js\";\nimport { retryDelay, waitForRetry } from \"./retry.js\";\n\n// Checkpoint bounded batches so a retry keeps completed work without one process per finding.\nconst EMBEDDING_BATCH_SIZE = 64;\n\n/** One vector space and the adapter that produces its embeddings. */\nexport interface FindingEmbeddingBinding {\n readonly embedder: FindingEmbedder;\n readonly model: string;\n readonly dimensions: number;\n /** Identifies the provider/vector space and preprocessing version; exclude credentials. */\n readonly cacheNamespace: string;\n}\n\n/** Direct workbench adapter. Importing it starts no HTTP or MCP server. */\nexport class LocalDeduplication {\n private options?: Promise<Omit<WorkbenchCommandOptions, \"python\">>;\n private cacheKeys: Record<string, string> = {};\n private readonly space: string;\n private readonly embedding: FindingEmbeddingBinding;\n\n constructor(\n private readonly environment: NodeJS.ProcessEnv,\n private readonly scope: FindingSearchScope,\n private readonly repositoryPath: string,\n private readonly signal?: AbortSignal,\n private readonly workbench: typeof runWorkbench = runWorkbench,\n embedding?: FindingEmbeddingBinding,\n onEmbeddingUsage?: EmbeddingUsageObserver,\n private readonly nodeDiscovery?: SavedToolDiscovery,\n ) {\n const endpoint =\n environmentEntry(environment, \"CODEX_SECURITY_EMBEDDINGS_URL\") ||\n EMBEDDINGS_URL;\n this.embedding = embedding ?? {\n model: EMBEDDING_MODEL,\n dimensions: EMBEDDING_DIMENSIONS,\n cacheNamespace: endpoint,\n embedder: new OpenAiFindingEmbedder(\n [\n environmentEntry(environment, \"OPENAI_API_KEY\"),\n environmentEntry(environment, \"CODEX_API_KEY\"),\n ].find((value) => value?.trim()),\n embeddingRequest,\n endpoint,\n signal,\n onEmbeddingUsage,\n ),\n };\n // The digest keeps endpoint/namespace details out of persisted cache keys.\n this.space = workflowDigest({\n version: 1,\n model: this.embedding.model,\n dimensions: this.embedding.dimensions,\n namespace: this.embedding.cacheNamespace,\n });\n }\n\n get inputDigest(): string {\n return workflowDigest(this.cacheKeys);\n }\n\n async prepare(\n findings: readonly Finding[],\n repositoryId: string,\n ): Promise<void> {\n const result = await this.command({\n action: \"prepare\",\n findings,\n anchorRepositoryId: repositoryId,\n repositoryPath: this.repositoryPath,\n });\n this.cacheKeys = result[\"cacheKeys\"] as Record<string, string>;\n const findingsToEmbed = result[\"findingsToEmbed\"] as unknown as Finding[];\n for (\n let offset = 0;\n offset < findingsToEmbed.length;\n offset += EMBEDDING_BATCH_SIZE\n ) {\n this.signal?.throwIfAborted();\n const batch = findingsToEmbed.slice(\n offset,\n offset + EMBEDDING_BATCH_SIZE,\n );\n const embeddings = await abortable(() => {\n this.signal?.throwIfAborted();\n return this.embedding.embedder.embed(batch);\n }, this.signal);\n this.signal?.throwIfAborted();\n if (embeddings.length !== batch.length)\n throw new CodexSecurityError(\n \"Embedding provider returned an invalid number of vectors.\",\n );\n await this.command({\n action: \"embed\",\n entries: batch.map((finding, index) => ({\n findingId: finding.findingId,\n cacheKey: this.cacheKeys[finding.findingId],\n embedding: embeddings[index],\n })),\n });\n }\n }\n\n async potentialDuplicates(findingId: string): Promise<FindingNeighborhood> {\n return (await this.command({\n action: \"neighbors\",\n findingId,\n cacheKeys: this.cacheKeys,\n })) as unknown as FindingNeighborhood;\n }\n\n async storeDedupeGroups(groups: readonly string[][]): Promise<void> {\n await this.command({ action: \"commit\", groups, cacheKeys: this.cacheKeys });\n }\n\n private async command(payload: { action: string; [key: string]: unknown }) {\n this.signal?.throwIfAborted();\n this.options ??= (async () => {\n // Bun finds Node on PATH. Native Node helpers use the running process executable.\n if (\n process.versions[\"bun\"] &&\n this.nodeDiscovery?.allowPathLookup === false\n )\n throw new CodexSecurityError(\n \"Could not establish the saved checkout boundary for Node.js discovery. Run local deduplication with Node.js.\",\n );\n const environment = workbenchEnvironment(this.environment);\n return {\n pluginRoot: await bundledPluginRoot(),\n stateDirectory: environment.CODEX_SECURITY_STATE_DIR,\n environment,\n signal: this.signal,\n protectedRoot: [\n ...(this.nodeDiscovery?.protectedRoots ?? []),\n this.repositoryPath,\n ...(await gitProtectionRoots(this.repositoryPath, this.signal)),\n ...(await gitProtectionRoots(process.cwd(), this.signal)),\n ],\n failureMessage: \"Could not access local deduplication state\",\n };\n })();\n const result = await this.workbench(\n await this.options,\n [\n payload.action === \"neighbors\"\n ? \"find-potential-duplicates\"\n : payload.action === \"commit\"\n ? \"store-dedupe-groups\"\n : \"local-dedupe\",\n ],\n JSON.stringify({\n ...payload,\n scope: this.scope,\n space: this.space,\n model: this.embedding.model,\n dimensions: this.embedding.dimensions,\n ...(this.scope.allRepositories\n ? {}\n : { repositoryId: this.scope.repositoryId }),\n }),\n );\n this.signal?.throwIfAborted();\n const code = result[\"error\"];\n if (code !== undefined) {\n const message =\n code === \"finding_changed\"\n ? \"Findings changed during local deduplication. Retry with a new workflow ID if resuming.\"\n : code === \"target_mismatch\"\n ? \"The scan target does not match the approved local checkout. Use its original checkout or an explicitly configured findings service.\"\n : code === \"finding_not_indexed\"\n ? \"A local finding has no complete document. Reimport its scan before deduplicating.\"\n : `Local deduplication failed: ${String(code)}.`;\n throw new CodexSecurityError(message);\n }\n return result;\n }\n}\n\nasync function embeddingRequest(\n url: string,\n init: RequestInit,\n): Promise<Response> {\n for (let attempt = 1; ; attempt++) {\n init.signal?.throwIfAborted();\n let delay = retryDelay(attempt);\n try {\n const response = await fetch(url, init);\n if (\n attempt === 3 ||\n ![408, 429, 500, 502, 503, 504].includes(response.status)\n )\n return response;\n const retryAfter = response.headers.get(\"Retry-After\");\n if (retryAfter !== null) {\n const seconds = Number(retryAfter);\n const retryAt = Number.isFinite(seconds)\n ? seconds * 1000\n : Date.parse(retryAfter) - Date.now();\n if (Number.isFinite(retryAt)) delay = Math.max(delay, retryAt);\n }\n await response.body?.cancel().catch(() => undefined);\n } catch (error) {\n init.signal?.throwIfAborted();\n if (attempt === 3 || !(error instanceof TypeError)) throw error;\n }\n await waitForRetry(delay, init.signal ?? undefined);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../../src/deduplication/refusal.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,OAAO,GACvB,OAAO,
|
|
1
|
+
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../../src/deduplication/refusal.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,OAAO,GACvB,OAAO,CA2CT"}
|
|
@@ -25,10 +25,11 @@ export function isReviewRefusal(message, codexErrorInfo) {
|
|
|
25
25
|
/\bflagged for potentially high-risk cyber activity\b/iu,
|
|
26
26
|
/\bcyber[_\s-]?policy\b/iu,
|
|
27
27
|
/\b(?:cybersecurity|cyber)[ _-]*policy[ _-]*(?:violation|refusal|refused)\b/iu,
|
|
28
|
+
/^(?:content|safety) policy (?:violation|refusal)[.!]?$/iu,
|
|
28
29
|
/(?:^(?:refusal|refused)|\b(?:request|review)\s+(?:refusal|(?:(?:is|was|has been)\s+)?(?:refused|blocked)))\s+(?:under|by|due to|because of|because (?:it|this request) violates|for violating|in accordance with)\s+(?:(?:the|a)\s+)?(?:cybersecurity|cyber|content|safety)[ _-]*policy\b/iu,
|
|
29
30
|
/^(?:(?:this|the|your)\s+)?(?:request|review)(?:\s+(?:is|was|has been))?\s+(?:refusal|refused|blocked)\s*:\s*(?:(?:the|a)\s+)?(?:cybersecurity|cyber|content|safety)[ _-]*policy(?:[.!](?:\s+(?:I can offer|Please ask)\b[^\n]*)?)?$/iu,
|
|
30
|
-
/^(?:cybersecurity|cyber|content|safety)[ _-]*policy\s*:\s*(?:(?:(?:this|the|your)\s+)?request\s+)?(?:(?:is|was|has been)\s+)?(?:violation|refusal|refused|blocked)[.!]?$/iu,
|
|
31
31
|
/\b(?:cybersecurity|cyber|content|safety)[ _-]*policy\s+requires\s+(?:a\s+)?refusal\s+of\s+(?:(?:this|the|your)\s+)?(?:request|review)\b/iu,
|
|
32
|
+
/^(?:cybersecurity|cyber|content|safety)[ _-]*policy\s*:\s*(?:(?:(?:this|the|your)\s+)?(?:request|review)\s+)?(?:(?:is|was|has been)\s+)?(?:violation|refusal|refused|blocked)(?:[.!](?:\s+(?:I can offer|Please ask)\b[^\n]*)?)?$/iu,
|
|
32
33
|
/\bunder\s+(?:(?:the|a)\s+)?(?:cybersecurity|cyber|content|safety)[ _-]*policy[, :]\s*(?:this|the|your) request (?:is|was|has been) (?:refused|blocked)\b/iu,
|
|
33
34
|
/^(?:I(?:['’]m| am) sorry[,.:]?\s*(?:but\s+)?|Sorry[,.:]?\s*)?I(?:\s+(?:cannot|can['’]t|won['’]t|am (?:unable|not able) to)|['’]m (?:unable|not able) to)\s+(?:help|assist|comply)\b/iu,
|
|
34
35
|
].some((pattern) => pattern.test(text));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refusal.js","sourceRoot":"","sources":["../../src/deduplication/refusal.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,MAAM,UAAU,eAAe,CAC7B,OAAe,EACf,cAAwB;IAExB,IACE,cAAc,KAAK,aAAa;QAChC,cAAc,KAAK,6BAA6B;QAEhD,OAAO,IAAI,CAAC;IACd,+EAA+E;IAC/E,IACE,cAAc,KAAK,IAAI;QACvB,OAAO,cAAc,KAAK,QAAQ;QAClC;YACE,sBAAsB;YACtB,gCAAgC;YAChC,4BAA4B;YAC5B,+BAA+B;SAChC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAE3D,OAAO,KAAK,CAAC;IACf,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC5B,MAAM,aAAa,GACjB,uKAAuK,CAAC,IAAI,CAC1K,IAAI,CACL,CAAC;IACJ,IAAI,aAAa,EAAE,CAAC;QAClB,wFAAwF;QACxF,yEAAyE;QACzE,OAAO,CAAC,+QAA+Q,CAAC,IAAI,CAC1R,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,CACvB,CAAC;IACJ,CAAC;IACD,OAAO;QACL,+CAA+C;QAC/C,wDAAwD;QACxD,0BAA0B;QAC1B,8EAA8E;QAC9E,6RAA6R;QAC7R,uOAAuO;QACvO,
|
|
1
|
+
{"version":3,"file":"refusal.js","sourceRoot":"","sources":["../../src/deduplication/refusal.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,MAAM,UAAU,eAAe,CAC7B,OAAe,EACf,cAAwB;IAExB,IACE,cAAc,KAAK,aAAa;QAChC,cAAc,KAAK,6BAA6B;QAEhD,OAAO,IAAI,CAAC;IACd,+EAA+E;IAC/E,IACE,cAAc,KAAK,IAAI;QACvB,OAAO,cAAc,KAAK,QAAQ;QAClC;YACE,sBAAsB;YACtB,gCAAgC;YAChC,4BAA4B;YAC5B,+BAA+B;SAChC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAE3D,OAAO,KAAK,CAAC;IACf,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC5B,MAAM,aAAa,GACjB,uKAAuK,CAAC,IAAI,CAC1K,IAAI,CACL,CAAC;IACJ,IAAI,aAAa,EAAE,CAAC;QAClB,wFAAwF;QACxF,yEAAyE;QACzE,OAAO,CAAC,+QAA+Q,CAAC,IAAI,CAC1R,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,CACvB,CAAC;IACJ,CAAC;IACD,OAAO;QACL,+CAA+C;QAC/C,wDAAwD;QACxD,0BAA0B;QAC1B,8EAA8E;QAC9E,0DAA0D;QAC1D,6RAA6R;QAC7R,uOAAuO;QACvO,2IAA2I;QAC3I,qOAAqO;QACrO,4JAA4J;QAC5J,uLAAuL;KACxL,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["/** Recognize policy blocks and explicit refusal responses, not ordinary review failures. */\nexport function isReviewRefusal(\n message: string,\n codexErrorInfo?: unknown,\n): boolean {\n if (\n codexErrorInfo === \"cyberPolicy\" ||\n codexErrorInfo === \"misalignmentPolicyViolation\"\n )\n return true;\n // Structured transport failures take precedence over fallback refusal wording.\n if (\n codexErrorInfo !== null &&\n typeof codexErrorInfo === \"object\" &&\n [\n \"httpConnectionFailed\",\n \"responseStreamConnectionFailed\",\n \"responseStreamDisconnected\",\n \"responseTooManyFailedAttempts\",\n ].some((variant) => Object.hasOwn(codexErrorInfo, variant))\n )\n return false;\n const text = message.trim();\n const policyRefusal =\n /\\b(?:cybersecurity|cyber|content|safety)[ _-]*policy\\s*:\\s*(?:(?:this|the|your)\\s+)?(?:request|review)\\s+(?:(?:is|was|has been)\\s+)?(?:refused|blocked)\\b([\\s\\S]*)$/iu.exec(\n text,\n );\n if (policyRefusal) {\n // The explicit refusal predicate decides; its explanation has no controlled vocabulary.\n // A leading service-outage cause still describes an operational failure.\n return !/^\\s*(?:(?:(?:because|as|due to)\\s+|[.!:]\\s*)(?:the\\s+)?(?:upstream\\s+)?service\\s+(?:is\\s+)?(?:unavailable|unavailability|timed? out|timeout)\\b|by\\s+upstream\\s+with\\s+[45]\\d{2}\\b|(?:because|as)\\s+(?:the\\s+)?upstream(?:\\s+service)?\\s+returned\\s+(?:HTTP\\s+)?[45]\\d{2}\\b)/iu.test(\n policyRefusal[1] ?? \"\",\n );\n }\n return [\n /\\bflagged for possible cybersecurity risk\\b/iu,\n /\\bflagged for potentially high-risk cyber activity\\b/iu,\n /\\bcyber[_\\s-]?policy\\b/iu,\n /\\b(?:cybersecurity|cyber)[ _-]*policy[ _-]*(?:violation|refusal|refused)\\b/iu,\n /^(?:content|safety) policy (?:violation|refusal)[.!]?$/iu,\n /(?:^(?:refusal|refused)|\\b(?:request|review)\\s+(?:refusal|(?:(?:is|was|has been)\\s+)?(?:refused|blocked)))\\s+(?:under|by|due to|because of|because (?:it|this request) violates|for violating|in accordance with)\\s+(?:(?:the|a)\\s+)?(?:cybersecurity|cyber|content|safety)[ _-]*policy\\b/iu,\n /^(?:(?:this|the|your)\\s+)?(?:request|review)(?:\\s+(?:is|was|has been))?\\s+(?:refusal|refused|blocked)\\s*:\\s*(?:(?:the|a)\\s+)?(?:cybersecurity|cyber|content|safety)[ _-]*policy(?:[.!](?:\\s+(?:I can offer|Please ask)\\b[^\\n]*)?)?$/iu,\n /\\b(?:cybersecurity|cyber|content|safety)[ _-]*policy\\s+requires\\s+(?:a\\s+)?refusal\\s+of\\s+(?:(?:this|the|your)\\s+)?(?:request|review)\\b/iu,\n /^(?:cybersecurity|cyber|content|safety)[ _-]*policy\\s*:\\s*(?:(?:(?:this|the|your)\\s+)?(?:request|review)\\s+)?(?:(?:is|was|has been)\\s+)?(?:violation|refusal|refused|blocked)(?:[.!](?:\\s+(?:I can offer|Please ask)\\b[^\\n]*)?)?$/iu,\n /\\bunder\\s+(?:(?:the|a)\\s+)?(?:cybersecurity|cyber|content|safety)[ _-]*policy[, :]\\s*(?:this|the|your) request (?:is|was|has been) (?:refused|blocked)\\b/iu,\n /^(?:I(?:['’]m| am) sorry[,.:]?\\s*(?:but\\s+)?|Sorry[,.:]?\\s*)?I(?:\\s+(?:cannot|can['’]t|won['’]t|am (?:unable|not able) to)|['’]m (?:unable|not able) to)\\s+(?:help|assist|comply)\\b/iu,\n ].some((pattern) => pattern.test(text));\n}\n"]}
|
|
@@ -27,6 +27,8 @@ export interface DeduplicateScanDirectoryOptions extends DeduplicateScanOptions
|
|
|
27
27
|
}
|
|
28
28
|
export interface DeduplicateScanResult extends DeduplicationResult {
|
|
29
29
|
scanId: string;
|
|
30
|
+
/** One finding from this scan for each entry in uniqueFindingIds, in the same order. */
|
|
31
|
+
scanRepresentativeFindingIds: string[];
|
|
30
32
|
}
|
|
31
33
|
/** Review a saved scan against embedding candidates and persist accepted duplicate groups. */
|
|
32
34
|
export declare function deduplicateScan(scanId: string, options: DeduplicateScanOptions): Promise<DeduplicateScanResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../src/deduplication/scan.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../src/deduplication/scan.ts"],"names":[],"mappings":"AAqBA,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAC;AAuB5B,OAAO,EAAsB,KAAK,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAQtE,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,sBAAsB;IACrC,mFAAmF;IACnF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uFAAuF;IACvF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wFAAwF;IACxF,SAAS,CAAC,EAAE,uBAAuB,CAAC;IACpC,iFAAiF;IACjF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yFAAyF;IACzF,YAAY,CAAC,EAAE,+BAA+B,CAAC;IAC/C,mFAAmF;IACnF,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IAC1C,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,+BAAgC,SAAQ,sBAAsB;IAC7E,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,wFAAwF;IACxF,4BAA4B,EAAE,MAAM,EAAE,CAAC;CACxC;AAED,8FAA8F;AAC9F,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CAEhC;AAED,qFAAqF;AACrF,wBAAsB,wBAAwB,CAC5C,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,qBAAqB,CAAC,CAEhC"}
|
|
@@ -2,7 +2,7 @@ import { loadContractWithScanDirectory } from "../contract.js";
|
|
|
2
2
|
import { environmentEntry } from "../auth.js";
|
|
3
3
|
import { bundledPluginRoot, codexSecurityStateDirectory, canonicalizeModelSafePath, } from "../runtime.js";
|
|
4
4
|
import { resolveCompletedScan, } from "../saved-scan.js";
|
|
5
|
-
import { savedScanWorkbench } from "../saved-scan-bootstrap.js";
|
|
5
|
+
import { savedScanWorkbench, } from "../saved-scan-bootstrap.js";
|
|
6
6
|
import { CodexReviewRunner, reviewSqliteHome } from "./codex-review.js";
|
|
7
7
|
import { mkdir } from "node:fs/promises";
|
|
8
8
|
import { isWithin } from "../trusted-executable.js";
|
|
@@ -57,9 +57,9 @@ export async function deduplicateScanInternal(scanId, options, dependencies = {}
|
|
|
57
57
|
});
|
|
58
58
|
return await deduplicateResolvedScan(scan.scanDir, scan["targetPath"], scan.scanId, options, bootstrap
|
|
59
59
|
? { ...dependencies, environment: bootstrap.environment }
|
|
60
|
-
: dependencies, pluginRoot, false);
|
|
60
|
+
: dependencies, pluginRoot, false, bootstrap?.nodeDiscovery);
|
|
61
61
|
}
|
|
62
|
-
async function deduplicateResolvedScan(selectedDirectory, repositoryPath, expectedScanId, options, dependencies, pluginRoot, bindRepository) {
|
|
62
|
+
async function deduplicateResolvedScan(selectedDirectory, repositoryPath, expectedScanId, options, dependencies, pluginRoot, bindRepository, nodeDiscovery) {
|
|
63
63
|
const environment = dependencies.environment ?? process.env;
|
|
64
64
|
if (options.embedding !== undefined && options.findingsUrl !== undefined)
|
|
65
65
|
throw new CodexSecurityError("Custom embeddings are only supported for local deduplication.");
|
|
@@ -76,7 +76,7 @@ async function deduplicateResolvedScan(selectedDirectory, repositoryPath, expect
|
|
|
76
76
|
const workbench = injectedWorkbench &&
|
|
77
77
|
(({ signal }, args, input) => injectedWorkbench(args, input, signal ?? options.signal));
|
|
78
78
|
const local = options.findingsUrl === undefined
|
|
79
|
-
? new LocalDeduplication(environment, scope, repositoryPath, options.signal, workbench, options.embedding, options.onEmbeddingUsage)
|
|
79
|
+
? new LocalDeduplication(environment, scope, repositoryPath, options.signal, workbench, options.embedding, options.onEmbeddingUsage, nodeDiscovery)
|
|
80
80
|
: undefined;
|
|
81
81
|
const client = local ??
|
|
82
82
|
new FindingsClient(options.findingsUrl, options.signal, dependencies.fetch, { wait: dependencies.waitForRetry });
|
|
@@ -108,6 +108,21 @@ async function deduplicateResolvedScan(selectedDirectory, repositoryPath, expect
|
|
|
108
108
|
runWorkbench: workbench,
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
+
const selectedFindingIds = new Set(contract.findings.findings.map((finding) => finding.findingId));
|
|
112
|
+
function scanResult(result) {
|
|
113
|
+
// Groups are already ranked by severity and then by finding ID.
|
|
114
|
+
const representatives = new Map();
|
|
115
|
+
for (const group of result.duplicateGroups) {
|
|
116
|
+
const representative = group.find((id) => selectedFindingIds.has(id));
|
|
117
|
+
if (representative !== undefined)
|
|
118
|
+
representatives.set(group[0], representative);
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
...result,
|
|
122
|
+
scanId,
|
|
123
|
+
scanRepresentativeFindingIds: result.uniqueFindingIds.map((id) => representatives.get(id) ?? id),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
111
126
|
const dedupe = async () => {
|
|
112
127
|
if (local) {
|
|
113
128
|
await (workflow ?? new FindingWorkflow(scanId, environment)).protectArtifacts(scanDirectory);
|
|
@@ -155,7 +170,6 @@ async function deduplicateResolvedScan(selectedDirectory, repositoryPath, expect
|
|
|
155
170
|
const checkpoints = workflow
|
|
156
171
|
? new CheckpointedReviewRunner(workflow, runner, source, scope, await reviewSettingsDigest(reviewEnvironment, reviewConfiguration), options.onDiagnostic)
|
|
157
172
|
: undefined;
|
|
158
|
-
const selectedFindingIds = new Set(contract.findings.findings.map((finding) => finding.findingId));
|
|
159
173
|
const sourceRepositories = new Map();
|
|
160
174
|
const sourceSnapshots = new Map();
|
|
161
175
|
const deduplicator = new FindingDeduplicator({
|
|
@@ -188,7 +202,7 @@ async function deduplicateResolvedScan(selectedDirectory, repositoryPath, expect
|
|
|
188
202
|
const reviewed = await deduplicator.run([...selectedFindingIds]);
|
|
189
203
|
await checkpoints?.assertSourceUnchanged();
|
|
190
204
|
options.signal?.throwIfAborted();
|
|
191
|
-
const result =
|
|
205
|
+
const result = scanResult(reviewed);
|
|
192
206
|
await workflow?.prepareDedupe(result, {
|
|
193
207
|
groups: result.duplicateGroups,
|
|
194
208
|
...(local
|
|
@@ -208,7 +222,10 @@ async function deduplicateResolvedScan(selectedDirectory, repositoryPath, expect
|
|
|
208
222
|
? await workflow.run("dedupe", dedupe)
|
|
209
223
|
: await dedupe();
|
|
210
224
|
options.signal?.throwIfAborted();
|
|
211
|
-
|
|
225
|
+
// Completed workflows and pending receipts from older releases omit this field.
|
|
226
|
+
return result.scanRepresentativeFindingIds === undefined
|
|
227
|
+
? scanResult(result)
|
|
228
|
+
: result;
|
|
212
229
|
}
|
|
213
230
|
async function modelConfigurationForReview(source, effective, signal) {
|
|
214
231
|
const selected = resolveCodexProfile(await readCodexHomeConfig(effective, signal));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../src/deduplication/scan.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,iBAAiB,EAEjB,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,oBAAoB,GAErB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EACL,mBAAmB,EACnB,wBAAwB,GAEzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,qBAAqB,GAEtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAwB,MAAM,uBAAuB,CAAC;AAM7E,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE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AM,CAAC,iBAAiB,CAAC,CAAC;QAC9C,MAAM,UAAU,GACd,OAAO,QAAQ,KAAK,QAAQ;YAC5B,QAAQ,CAAC,WAAW,CAAC;YACrB,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC;YACvB,CAAC,CAAC,SAAS,CAAC;QAChB,OAAO;YACL,QAAQ;YACR,OAAO,EAAE,UAAU,EAAE,CAAC,UAAU,CAAC;YACjC,OAAO,EAAE,UAAU,EAAE,CAAC,UAAU,CAAC,IAAI,WAAW;YAChD,aAAa,EACX,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS;SAChE,CAAC;IACJ,CAAC,CAAC;IACF,2EAA2E;IAC3E,6EAA6E;IAC7E,IACE,iBAAiB,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,EACxE,CAAC;QACD,KAAK,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,wBAAwB,CAAC;YACnD,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS;gBAC3D,QAAQ,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import type { Finding } from \"../models.js\";\nimport { loadContractWithScanDirectory } from \"../contract.js\";\nimport type { CodexSecuritySurface } from \"../api.js\";\nimport { environmentEntry } from \"../auth.js\";\nimport {\n bundledPluginRoot,\n runWorkbench,\n codexSecurityStateDirectory,\n canonicalizeModelSafePath,\n} from \"../runtime.js\";\nimport {\n resolveCompletedScan,\n type SavedScanDependencies,\n} from \"../saved-scan.js\";\nimport { savedScanWorkbench } from \"../saved-scan-bootstrap.js\";\nimport { CodexReviewRunner, reviewSqliteHome } from \"./codex-review.js\";\nimport { mkdir } from \"node:fs/promises\";\nimport { isWithin } from \"../trusted-executable.js\";\nimport {\n FindingDeduplicator,\n deduplicationConcurrency,\n type DeduplicationResult,\n} from \"./deduplication.js\";\nimport {\n CodexGroupingReviewer,\n type DeduplicationReviewer,\n} from \"./deduplication-reviewer.js\";\nimport { FindingsClient, type FindingsRequest } from \"../findings-client.js\";\nimport type { waitForRetry } from \"./retry.js\";\nimport type {\n FindingSearchScope,\n FindingSourceSnapshot,\n} from \"../finding-retrieval.js\";\nimport {\n FindingWorkflow,\n scanArtifactDigest,\n workflowDestination,\n workflowDigest,\n} from \"../finding-workflow.js\";\nimport { publishScanToCustomInternal } from \"../custom-publish.js\";\nimport {\n CheckpointedReviewRunner,\n reviewSettingsDigest,\n} from \"./checkpointed-review.js\";\nimport { normalizeRepository } from \"../targets.js\";\nimport { LocalDeduplication, type FindingEmbeddingBinding } from \"./local.js\";\nimport type { EmbeddingUsageObserver } from \"../server/embeddings.js\";\nimport { configuredCodexHome, readCodexHomeConfig } from \"../auth.js\";\nimport { CodexSecurityError } from \"../errors.js\";\nimport { comparisonEnvironment } from \"../scan-comparison.js\";\nimport { isDeepStrictEqual } from \"node:util\";\nimport { isRecord } from \"../record.js\";\nimport { resolveCodexProfile, type JsonObject } from \"../config.js\";\nimport { savedSourceContext } from \"./deduplication-prompts.js\";\nimport {\n emitDiagnostic,\n type DeduplicationDiagnosticObserver,\n} from \"./diagnostics.js\";\n\nexport interface DeduplicateScanOptions {\n /** Resume the named findings workflow; remote mode includes custom publication. */\n workflowId?: string;\n /** Optional Findings API. Omit to prepare and deduplicate findings in local SQLite. */\n findingsUrl?: string;\n /** Custom vector space for local deduplication; cannot be combined with findingsUrl. */\n embedding?: FindingEmbeddingBinding;\n /** Search all repositories instead of the scan's targetId. Defaults to false. */\n allRepositories?: boolean;\n /** Shared concurrency limit for deduplication jobs. Defaults to 8. */\n concurrency?: number;\n /** Best-effort progress and native review diagnostics; observer failures are ignored. */\n onDiagnostic?: DeduplicationDiagnosticObserver;\n /** Built-in local embedding batch usage; excluded from scan model-token totals. */\n onEmbeddingUsage?: EmbeddingUsageObserver;\n signal?: AbortSignal;\n}\n\nexport interface DeduplicateScanDirectoryOptions extends DeduplicateScanOptions {\n /** Local repository checkout used to review duplicate candidates. */\n repository: string;\n /** Require the sealed artifacts to belong to this scan. */\n expectedScanId?: string;\n}\n\nexport interface DeduplicateScanResult extends DeduplicationResult {\n scanId: string;\n}\n\n/** Review a saved scan against embedding candidates and persist accepted duplicate groups. */\nexport async function deduplicateScan(\n scanId: string,\n options: DeduplicateScanOptions,\n): Promise<DeduplicateScanResult> {\n return await deduplicateScanInternal(scanId, options);\n}\n\n/** Review a complete, sealed scan directory without resolving local scan history. */\nexport async function deduplicateScanDirectory(\n scanDirectory: string,\n options: DeduplicateScanDirectoryOptions,\n): Promise<DeduplicateScanResult> {\n return await deduplicateScanDirectoryInternal(scanDirectory, options);\n}\n\ntype DeduplicateScanDependencies = Partial<SavedScanDependencies> & {\n surface?: CodexSecuritySurface;\n environment?: NodeJS.ProcessEnv;\n reviewer?: DeduplicationReviewer;\n reviewRunner?: Pick<CodexReviewRunner, \"run\">;\n resolveReviewEnvironment?: typeof comparisonEnvironment;\n fetch?: FindingsRequest;\n waitForRetry?: typeof waitForRetry;\n};\n\n/** @internal */\nexport async function deduplicateScanDirectoryInternal(\n scanDirectory: string,\n options: DeduplicateScanDirectoryOptions,\n dependencies: DeduplicateScanDependencies = {},\n): Promise<DeduplicateScanResult> {\n options.signal?.throwIfAborted();\n deduplicationConcurrency(options.concurrency);\n return await deduplicateResolvedScan(\n scanDirectory,\n await normalizeRepository(options.repository, options.signal),\n options.expectedScanId,\n options,\n dependencies,\n await bundledPluginRoot(),\n true,\n );\n}\n\n/** @internal */\nexport async function deduplicateScanInternal(\n scanId: string,\n options: DeduplicateScanOptions,\n dependencies: DeduplicateScanDependencies = {},\n): Promise<DeduplicateScanResult> {\n options.signal?.throwIfAborted();\n deduplicationConcurrency(options.concurrency);\n const environment = dependencies.environment ?? process.env;\n const pluginRoot = await bundledPluginRoot();\n const bootstrap = dependencies.runWorkbench\n ? undefined\n : await savedScanWorkbench(scanId, {\n environment,\n pluginRoot,\n currentDirectory: dependencies.currentDirectory?.() ?? process.cwd(),\n signal: options.signal,\n });\n const scan = await resolveCompletedScan(scanId, {\n currentDirectory: dependencies.currentDirectory ?? (() => process.cwd()),\n runWorkbench:\n bootstrap ??\n ((args, input) =>\n dependencies.runWorkbench!(args, input, options.signal)),\n });\n return await deduplicateResolvedScan(\n scan.scanDir,\n scan[\"targetPath\"] as string,\n scan.scanId,\n options,\n bootstrap\n ? { ...dependencies, environment: bootstrap.environment }\n : dependencies,\n pluginRoot,\n false,\n );\n}\n\nasync function deduplicateResolvedScan(\n selectedDirectory: string,\n repositoryPath: string,\n expectedScanId: string | undefined,\n options: DeduplicateScanOptions,\n dependencies: DeduplicateScanDependencies,\n pluginRoot: string,\n bindRepository: boolean,\n): Promise<DeduplicateScanResult> {\n const environment = dependencies.environment ?? process.env;\n if (options.embedding !== undefined && options.findingsUrl !== undefined)\n throw new CodexSecurityError(\n \"Custom embeddings are only supported for local deduplication.\",\n );\n const { contract, scanDirectory } = await loadContractWithScanDirectory(\n selectedDirectory,\n {\n pluginRoot,\n expectedScanId,\n signal: options.signal,\n },\n );\n const scanId = contract.manifest.scan.id;\n const scope: FindingSearchScope =\n options.allRepositories === true\n ? { allRepositories: true }\n : { repositoryId: contract.manifest.scan.target.targetId };\n const injectedWorkbench = dependencies.runWorkbench;\n const workbench: typeof runWorkbench | undefined =\n injectedWorkbench &&\n (({ signal }, args, input) =>\n injectedWorkbench(args, input, signal ?? options.signal));\n const local =\n options.findingsUrl === undefined\n ? new LocalDeduplication(\n environment,\n scope,\n repositoryPath,\n options.signal,\n workbench,\n options.embedding,\n options.onEmbeddingUsage,\n )\n : undefined;\n const client =\n local ??\n new FindingsClient(\n options.findingsUrl!,\n options.signal,\n dependencies.fetch,\n { wait: dependencies.waitForRetry },\n );\n const workflow =\n options.workflowId === undefined\n ? undefined\n : new FindingWorkflow(\n options.workflowId,\n environment,\n workbench,\n undefined,\n { protectedRoot: repositoryPath },\n );\n if (workflow) {\n await workflow.protectArtifacts(scanDirectory);\n await workflow.bind({\n ...(bindRepository ? { repositoryPath } : {}),\n scanId,\n scanDir: scanDirectory,\n artifactDigest: scanArtifactDigest(contract),\n destination: local\n ? `sqlite:${codexSecurityStateDirectory(environment)}`\n : workflowDestination(options.findingsUrl!),\n scope,\n });\n await workflow.complete(\"scan\", null);\n if (!local)\n await publishScanToCustomInternal(\n scanDirectory,\n {\n findingsUrl: options.findingsUrl!,\n workflowId: options.workflowId,\n expectedScanId: scanId,\n signal: options.signal,\n },\n {\n environment,\n fetch: dependencies.fetch,\n runWorkbench: workbench,\n },\n );\n }\n const dedupe = async (): Promise<DeduplicateScanResult> => {\n if (local) {\n await (\n workflow ?? new FindingWorkflow(scanId, environment)\n ).protectArtifacts(scanDirectory);\n emitDiagnostic(options.onDiagnostic, { event: \"preparation.started\" });\n await local.prepare(\n contract.findings.findings,\n contract.manifest.scan.target.targetId,\n );\n emitDiagnostic(options.onDiagnostic, { event: \"preparation.completed\" });\n }\n const saved = (await workflow?.get())?.stages.dedupe;\n if (saved?.pendingWrite) {\n if (\n local &&\n (saved.pendingWrite.local?.inputDigest !== local.inputDigest ||\n workflowDigest(saved.pendingWrite.local.source) !==\n workflowDigest(\n await workflow!.sourceSnapshot(repositoryPath, {\n gitDisabled: saved.pendingWrite.local.gitDisabled,\n privateStatePaths: (saved.pendingWrite.local.source[\n \"privateStatePaths\"\n ] ?? []) as string[],\n }),\n ))\n ) {\n throw new CodexSecurityError(\n \"Local deduplication inputs changed. Use a new workflow ID to review them.\",\n );\n }\n await client.storeDedupeGroups(saved.pendingWrite.groups);\n return saved.result as DeduplicateScanResult;\n }\n const reviewEnvironment = dependencies.reviewer\n ? environment\n : await (dependencies.resolveReviewEnvironment ?? comparisonEnvironment)(\n environment,\n undefined,\n options.signal,\n );\n const reviewConfiguration = dependencies.reviewer\n ? {}\n : await modelConfigurationForReview(\n environment,\n reviewEnvironment,\n options.signal,\n );\n const runner =\n dependencies.reviewRunner ??\n new CodexReviewRunner(\n reviewEnvironment,\n undefined,\n options.signal,\n repositoryPath,\n undefined,\n options.onDiagnostic,\n dependencies.surface ?? \"sdk\",\n );\n const privateStatePaths: string[] = [];\n if (workflow && !dependencies.reviewer) {\n const root = await canonicalizeModelSafePath(repositoryPath);\n const sqliteHome = await canonicalizeModelSafePath(\n reviewSqliteHome(reviewEnvironment, reviewConfiguration),\n );\n if (isWithin(root, sqliteHome)) {\n if (isWithin(sqliteHome, root))\n throw new CodexSecurityError(\n \"Native SQLite storage must not be the reviewed repository root when checkpointing deduplication.\",\n );\n // Create missing private parents before capturing source; native startup owns the database files.\n await mkdir(sqliteHome, { recursive: true, mode: 0o700 });\n privateStatePaths.push(sqliteHome);\n }\n }\n const source = workflow\n ? await workflow.sourceSnapshot(repositoryPath, { privateStatePaths })\n : undefined;\n const checkpoints = workflow\n ? new CheckpointedReviewRunner(\n workflow,\n runner,\n source!,\n scope,\n await reviewSettingsDigest(reviewEnvironment, reviewConfiguration),\n options.onDiagnostic,\n )\n : undefined;\n const selectedFindingIds = new Set(\n contract.findings.findings.map((finding) => finding.findingId),\n );\n const sourceRepositories = new Map<Finding, readonly string[]>();\n const sourceSnapshots = new Map<Finding, FindingSourceSnapshot>();\n const deduplicator = new FindingDeduplicator(\n {\n potentialDuplicates: async (findingId) => {\n const neighborhood = await client.potentialDuplicates(\n findingId,\n scope,\n );\n for (const finding of [\n neighborhood.finding,\n ...neighborhood.potentialDuplicates,\n ]) {\n const repositories = Object.hasOwn(\n neighborhood.repositoryIds ?? {},\n finding.findingId,\n )\n ? neighborhood.repositoryIds![finding.findingId]\n : undefined;\n if (repositories !== undefined)\n sourceRepositories.set(finding, repositories);\n else if (\n scope.repositoryId !== undefined ||\n selectedFindingIds.has(finding.findingId)\n )\n sourceRepositories.set(finding, [\n scope.repositoryId ?? contract.manifest.scan.target.targetId,\n ]);\n const snapshot = Object.hasOwn(\n neighborhood.sourceSnapshots ?? {},\n finding.findingId,\n )\n ? neighborhood.sourceSnapshots![finding.findingId]\n : undefined;\n if (snapshot !== undefined) sourceSnapshots.set(finding, snapshot);\n }\n return neighborhood;\n },\n },\n dependencies.reviewer ??\n new CodexGroupingReviewer(\n checkpoints ?? runner,\n reviewConfiguration,\n (findings) =>\n savedSourceContext(\n contract.manifest.scan.target.targetId,\n findings,\n sourceRepositories,\n sourceSnapshots,\n ),\n ),\n options.signal,\n options.concurrency,\n );\n const reviewed = await deduplicator.run([...selectedFindingIds]);\n await checkpoints?.assertSourceUnchanged();\n options.signal?.throwIfAborted();\n const result: DeduplicateScanResult = { scanId, ...reviewed };\n await workflow?.prepareDedupe(result, {\n groups: result.duplicateGroups,\n ...(local\n ? {\n local: {\n inputDigest: local.inputDigest,\n source: source!,\n gitDisabled:\n environmentEntry(environment, \"CODEX_SECURITY_GIT\") === \"\",\n },\n }\n : {}),\n });\n await client.storeDedupeGroups(result.duplicateGroups);\n return result;\n };\n const result = workflow\n ? await workflow.run(\"dedupe\", dedupe)\n : await dedupe();\n options.signal?.throwIfAborted();\n return result;\n}\n\nasync function modelConfigurationForReview(\n source: NodeJS.ProcessEnv,\n effective: NodeJS.ProcessEnv,\n signal?: AbortSignal,\n): Promise<JsonObject> {\n const selected = resolveCodexProfile(\n await readCodexHomeConfig(effective, signal),\n );\n if (configuredCodexHome(source) === configuredCodexHome(effective))\n return selected;\n const ambient = resolveCodexProfile(\n await readCodexHomeConfig(source, signal),\n );\n const providerIdentity = (config: JsonObject) => {\n const provider = config[\"model_provider\"] ?? \"openai\";\n const definitions = config[\"model_providers\"];\n const definition =\n typeof provider === \"string\" &&\n isRecord(definitions) &&\n isRecord(definitions[provider])\n ? definitions[provider]\n : undefined;\n return {\n provider,\n baseUrl: definition?.[\"base_url\"],\n wireApi: definition?.[\"wire_api\"] ?? \"responses\",\n openaiBaseUrl:\n provider === \"openai\" ? config[\"openai_base_url\"] : undefined,\n };\n };\n // A managed sign-in home can contain only authentication/runtime settings.\n // Keep compatible caller model choices without crossing provider namespaces.\n if (\n isDeepStrictEqual(providerIdentity(ambient), providerIdentity(selected))\n ) {\n for (const key of [\"model\", \"model_reasoning_effort\"])\n if (selected[key] === undefined && ambient[key] !== undefined)\n selected[key] = ambient[key];\n }\n return selected;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../src/deduplication/scan.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,iBAAiB,EAEjB,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,oBAAoB,GAErB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,kBAAkB,GAEnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EACL,mBAAmB,EACnB,wBAAwB,GAEzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,qBAAqB,GAEtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAwB,MAAM,uBAAuB,CAAC;AAM7E,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EACL,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,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AAO,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,EACxE,CAAC;QACD,KAAK,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,wBAAwB,CAAC;YACnD,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS;gBAC3D,QAAQ,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import type { Finding } from \"../models.js\";\nimport { loadContractWithScanDirectory } from \"../contract.js\";\nimport type { CodexSecuritySurface } from \"../api.js\";\nimport { environmentEntry } from \"../auth.js\";\nimport {\n bundledPluginRoot,\n runWorkbench,\n codexSecurityStateDirectory,\n canonicalizeModelSafePath,\n} from \"../runtime.js\";\nimport {\n resolveCompletedScan,\n type SavedScanDependencies,\n} from \"../saved-scan.js\";\nimport {\n savedScanWorkbench,\n type SavedToolDiscovery,\n} from \"../saved-scan-bootstrap.js\";\nimport { CodexReviewRunner, reviewSqliteHome } from \"./codex-review.js\";\nimport { mkdir } from \"node:fs/promises\";\nimport { isWithin } from \"../trusted-executable.js\";\nimport {\n FindingDeduplicator,\n deduplicationConcurrency,\n type DeduplicationResult,\n} from \"./deduplication.js\";\nimport {\n CodexGroupingReviewer,\n type DeduplicationReviewer,\n} from \"./deduplication-reviewer.js\";\nimport { FindingsClient, type FindingsRequest } from \"../findings-client.js\";\nimport type { waitForRetry } from \"./retry.js\";\nimport type {\n FindingSearchScope,\n FindingSourceSnapshot,\n} from \"../finding-retrieval.js\";\nimport {\n FindingWorkflow,\n scanArtifactDigest,\n workflowDestination,\n workflowDigest,\n} from \"../finding-workflow.js\";\nimport { publishScanToCustomInternal } from \"../custom-publish.js\";\nimport {\n CheckpointedReviewRunner,\n reviewSettingsDigest,\n} from \"./checkpointed-review.js\";\nimport { normalizeRepository } from \"../targets.js\";\nimport { LocalDeduplication, type FindingEmbeddingBinding } from \"./local.js\";\nimport type { EmbeddingUsageObserver } from \"../server/embeddings.js\";\nimport { configuredCodexHome, readCodexHomeConfig } from \"../auth.js\";\nimport { CodexSecurityError } from \"../errors.js\";\nimport { comparisonEnvironment } from \"../scan-comparison.js\";\nimport { isDeepStrictEqual } from \"node:util\";\nimport { isRecord } from \"../record.js\";\nimport { resolveCodexProfile, type JsonObject } from \"../config.js\";\nimport { savedSourceContext } from \"./deduplication-prompts.js\";\nimport {\n emitDiagnostic,\n type DeduplicationDiagnosticObserver,\n} from \"./diagnostics.js\";\n\nexport interface DeduplicateScanOptions {\n /** Resume the named findings workflow; remote mode includes custom publication. */\n workflowId?: string;\n /** Optional Findings API. Omit to prepare and deduplicate findings in local SQLite. */\n findingsUrl?: string;\n /** Custom vector space for local deduplication; cannot be combined with findingsUrl. */\n embedding?: FindingEmbeddingBinding;\n /** Search all repositories instead of the scan's targetId. Defaults to false. */\n allRepositories?: boolean;\n /** Shared concurrency limit for deduplication jobs. Defaults to 8. */\n concurrency?: number;\n /** Best-effort progress and native review diagnostics; observer failures are ignored. */\n onDiagnostic?: DeduplicationDiagnosticObserver;\n /** Built-in local embedding batch usage; excluded from scan model-token totals. */\n onEmbeddingUsage?: EmbeddingUsageObserver;\n signal?: AbortSignal;\n}\n\nexport interface DeduplicateScanDirectoryOptions extends DeduplicateScanOptions {\n /** Local repository checkout used to review duplicate candidates. */\n repository: string;\n /** Require the sealed artifacts to belong to this scan. */\n expectedScanId?: string;\n}\n\nexport interface DeduplicateScanResult extends DeduplicationResult {\n scanId: string;\n /** One finding from this scan for each entry in uniqueFindingIds, in the same order. */\n scanRepresentativeFindingIds: string[];\n}\n\n/** Review a saved scan against embedding candidates and persist accepted duplicate groups. */\nexport async function deduplicateScan(\n scanId: string,\n options: DeduplicateScanOptions,\n): Promise<DeduplicateScanResult> {\n return await deduplicateScanInternal(scanId, options);\n}\n\n/** Review a complete, sealed scan directory without resolving local scan history. */\nexport async function deduplicateScanDirectory(\n scanDirectory: string,\n options: DeduplicateScanDirectoryOptions,\n): Promise<DeduplicateScanResult> {\n return await deduplicateScanDirectoryInternal(scanDirectory, options);\n}\n\ntype DeduplicateScanDependencies = Partial<SavedScanDependencies> & {\n surface?: CodexSecuritySurface;\n environment?: NodeJS.ProcessEnv;\n reviewer?: DeduplicationReviewer;\n reviewRunner?: Pick<CodexReviewRunner, \"run\">;\n resolveReviewEnvironment?: typeof comparisonEnvironment;\n fetch?: FindingsRequest;\n waitForRetry?: typeof waitForRetry;\n};\n\n/** @internal */\nexport async function deduplicateScanDirectoryInternal(\n scanDirectory: string,\n options: DeduplicateScanDirectoryOptions,\n dependencies: DeduplicateScanDependencies = {},\n): Promise<DeduplicateScanResult> {\n options.signal?.throwIfAborted();\n deduplicationConcurrency(options.concurrency);\n return await deduplicateResolvedScan(\n scanDirectory,\n await normalizeRepository(options.repository, options.signal),\n options.expectedScanId,\n options,\n dependencies,\n await bundledPluginRoot(),\n true,\n );\n}\n\n/** @internal */\nexport async function deduplicateScanInternal(\n scanId: string,\n options: DeduplicateScanOptions,\n dependencies: DeduplicateScanDependencies = {},\n): Promise<DeduplicateScanResult> {\n options.signal?.throwIfAborted();\n deduplicationConcurrency(options.concurrency);\n const environment = dependencies.environment ?? process.env;\n const pluginRoot = await bundledPluginRoot();\n const bootstrap = dependencies.runWorkbench\n ? undefined\n : await savedScanWorkbench(scanId, {\n environment,\n pluginRoot,\n currentDirectory: dependencies.currentDirectory?.() ?? process.cwd(),\n signal: options.signal,\n });\n const scan = await resolveCompletedScan(scanId, {\n currentDirectory: dependencies.currentDirectory ?? (() => process.cwd()),\n runWorkbench:\n bootstrap ??\n ((args, input) =>\n dependencies.runWorkbench!(args, input, options.signal)),\n });\n return await deduplicateResolvedScan(\n scan.scanDir,\n scan[\"targetPath\"] as string,\n scan.scanId,\n options,\n bootstrap\n ? { ...dependencies, environment: bootstrap.environment }\n : dependencies,\n pluginRoot,\n false,\n bootstrap?.nodeDiscovery,\n );\n}\n\nasync function deduplicateResolvedScan(\n selectedDirectory: string,\n repositoryPath: string,\n expectedScanId: string | undefined,\n options: DeduplicateScanOptions,\n dependencies: DeduplicateScanDependencies,\n pluginRoot: string,\n bindRepository: boolean,\n nodeDiscovery?: SavedToolDiscovery,\n): Promise<DeduplicateScanResult> {\n const environment = dependencies.environment ?? process.env;\n if (options.embedding !== undefined && options.findingsUrl !== undefined)\n throw new CodexSecurityError(\n \"Custom embeddings are only supported for local deduplication.\",\n );\n const { contract, scanDirectory } = await loadContractWithScanDirectory(\n selectedDirectory,\n {\n pluginRoot,\n expectedScanId,\n signal: options.signal,\n },\n );\n const scanId = contract.manifest.scan.id;\n const scope: FindingSearchScope =\n options.allRepositories === true\n ? { allRepositories: true }\n : { repositoryId: contract.manifest.scan.target.targetId };\n const injectedWorkbench = dependencies.runWorkbench;\n const workbench: typeof runWorkbench | undefined =\n injectedWorkbench &&\n (({ signal }, args, input) =>\n injectedWorkbench(args, input, signal ?? options.signal));\n const local =\n options.findingsUrl === undefined\n ? new LocalDeduplication(\n environment,\n scope,\n repositoryPath,\n options.signal,\n workbench,\n options.embedding,\n options.onEmbeddingUsage,\n nodeDiscovery,\n )\n : undefined;\n const client =\n local ??\n new FindingsClient(\n options.findingsUrl!,\n options.signal,\n dependencies.fetch,\n { wait: dependencies.waitForRetry },\n );\n const workflow =\n options.workflowId === undefined\n ? undefined\n : new FindingWorkflow(\n options.workflowId,\n environment,\n workbench,\n undefined,\n { protectedRoot: repositoryPath },\n );\n if (workflow) {\n await workflow.protectArtifacts(scanDirectory);\n await workflow.bind({\n ...(bindRepository ? { repositoryPath } : {}),\n scanId,\n scanDir: scanDirectory,\n artifactDigest: scanArtifactDigest(contract),\n destination: local\n ? `sqlite:${codexSecurityStateDirectory(environment)}`\n : workflowDestination(options.findingsUrl!),\n scope,\n });\n await workflow.complete(\"scan\", null);\n if (!local)\n await publishScanToCustomInternal(\n scanDirectory,\n {\n findingsUrl: options.findingsUrl!,\n workflowId: options.workflowId,\n expectedScanId: scanId,\n signal: options.signal,\n },\n {\n environment,\n fetch: dependencies.fetch,\n runWorkbench: workbench,\n },\n );\n }\n const selectedFindingIds = new Set(\n contract.findings.findings.map((finding) => finding.findingId),\n );\n function scanResult(result: DeduplicationResult): DeduplicateScanResult {\n // Groups are already ranked by severity and then by finding ID.\n const representatives = new Map<string, string>();\n for (const group of result.duplicateGroups) {\n const representative = group.find((id) => selectedFindingIds.has(id));\n if (representative !== undefined)\n representatives.set(group[0]!, representative);\n }\n return {\n ...result,\n scanId,\n scanRepresentativeFindingIds: result.uniqueFindingIds.map(\n (id) => representatives.get(id) ?? id,\n ),\n };\n }\n const dedupe = async (): Promise<DeduplicateScanResult> => {\n if (local) {\n await (\n workflow ?? new FindingWorkflow(scanId, environment)\n ).protectArtifacts(scanDirectory);\n emitDiagnostic(options.onDiagnostic, { event: \"preparation.started\" });\n await local.prepare(\n contract.findings.findings,\n contract.manifest.scan.target.targetId,\n );\n emitDiagnostic(options.onDiagnostic, { event: \"preparation.completed\" });\n }\n const saved = (await workflow?.get())?.stages.dedupe;\n if (saved?.pendingWrite) {\n if (\n local &&\n (saved.pendingWrite.local?.inputDigest !== local.inputDigest ||\n workflowDigest(saved.pendingWrite.local.source) !==\n workflowDigest(\n await workflow!.sourceSnapshot(repositoryPath, {\n gitDisabled: saved.pendingWrite.local.gitDisabled,\n privateStatePaths: (saved.pendingWrite.local.source[\n \"privateStatePaths\"\n ] ?? []) as string[],\n }),\n ))\n ) {\n throw new CodexSecurityError(\n \"Local deduplication inputs changed. Use a new workflow ID to review them.\",\n );\n }\n await client.storeDedupeGroups(saved.pendingWrite.groups);\n return saved.result as DeduplicateScanResult;\n }\n const reviewEnvironment = dependencies.reviewer\n ? environment\n : await (dependencies.resolveReviewEnvironment ?? comparisonEnvironment)(\n environment,\n undefined,\n options.signal,\n );\n const reviewConfiguration = dependencies.reviewer\n ? {}\n : await modelConfigurationForReview(\n environment,\n reviewEnvironment,\n options.signal,\n );\n const runner =\n dependencies.reviewRunner ??\n new CodexReviewRunner(\n reviewEnvironment,\n undefined,\n options.signal,\n repositoryPath,\n undefined,\n options.onDiagnostic,\n dependencies.surface ?? \"sdk\",\n );\n const privateStatePaths: string[] = [];\n if (workflow && !dependencies.reviewer) {\n const root = await canonicalizeModelSafePath(repositoryPath);\n const sqliteHome = await canonicalizeModelSafePath(\n reviewSqliteHome(reviewEnvironment, reviewConfiguration),\n );\n if (isWithin(root, sqliteHome)) {\n if (isWithin(sqliteHome, root))\n throw new CodexSecurityError(\n \"Native SQLite storage must not be the reviewed repository root when checkpointing deduplication.\",\n );\n // Create missing private parents before capturing source; native startup owns the database files.\n await mkdir(sqliteHome, { recursive: true, mode: 0o700 });\n privateStatePaths.push(sqliteHome);\n }\n }\n const source = workflow\n ? await workflow.sourceSnapshot(repositoryPath, { privateStatePaths })\n : undefined;\n const checkpoints = workflow\n ? new CheckpointedReviewRunner(\n workflow,\n runner,\n source!,\n scope,\n await reviewSettingsDigest(reviewEnvironment, reviewConfiguration),\n options.onDiagnostic,\n )\n : undefined;\n const sourceRepositories = new Map<Finding, readonly string[]>();\n const sourceSnapshots = new Map<Finding, FindingSourceSnapshot>();\n const deduplicator = new FindingDeduplicator(\n {\n potentialDuplicates: async (findingId) => {\n const neighborhood = await client.potentialDuplicates(\n findingId,\n scope,\n );\n for (const finding of [\n neighborhood.finding,\n ...neighborhood.potentialDuplicates,\n ]) {\n const repositories = Object.hasOwn(\n neighborhood.repositoryIds ?? {},\n finding.findingId,\n )\n ? neighborhood.repositoryIds![finding.findingId]\n : undefined;\n if (repositories !== undefined)\n sourceRepositories.set(finding, repositories);\n else if (\n scope.repositoryId !== undefined ||\n selectedFindingIds.has(finding.findingId)\n )\n sourceRepositories.set(finding, [\n scope.repositoryId ?? contract.manifest.scan.target.targetId,\n ]);\n const snapshot = Object.hasOwn(\n neighborhood.sourceSnapshots ?? {},\n finding.findingId,\n )\n ? neighborhood.sourceSnapshots![finding.findingId]\n : undefined;\n if (snapshot !== undefined) sourceSnapshots.set(finding, snapshot);\n }\n return neighborhood;\n },\n },\n dependencies.reviewer ??\n new CodexGroupingReviewer(\n checkpoints ?? runner,\n reviewConfiguration,\n (findings) =>\n savedSourceContext(\n contract.manifest.scan.target.targetId,\n findings,\n sourceRepositories,\n sourceSnapshots,\n ),\n ),\n options.signal,\n options.concurrency,\n );\n const reviewed = await deduplicator.run([...selectedFindingIds]);\n await checkpoints?.assertSourceUnchanged();\n options.signal?.throwIfAborted();\n const result = scanResult(reviewed);\n await workflow?.prepareDedupe(result, {\n groups: result.duplicateGroups,\n ...(local\n ? {\n local: {\n inputDigest: local.inputDigest,\n source: source!,\n gitDisabled:\n environmentEntry(environment, \"CODEX_SECURITY_GIT\") === \"\",\n },\n }\n : {}),\n });\n await client.storeDedupeGroups(result.duplicateGroups);\n return result;\n };\n const result = workflow\n ? await workflow.run(\"dedupe\", dedupe)\n : await dedupe();\n options.signal?.throwIfAborted();\n // Completed workflows and pending receipts from older releases omit this field.\n return result.scanRepresentativeFindingIds === undefined\n ? scanResult(result)\n : result;\n}\n\nasync function modelConfigurationForReview(\n source: NodeJS.ProcessEnv,\n effective: NodeJS.ProcessEnv,\n signal?: AbortSignal,\n): Promise<JsonObject> {\n const selected = resolveCodexProfile(\n await readCodexHomeConfig(effective, signal),\n );\n if (configuredCodexHome(source) === configuredCodexHome(effective))\n return selected;\n const ambient = resolveCodexProfile(\n await readCodexHomeConfig(source, signal),\n );\n const providerIdentity = (config: JsonObject) => {\n const provider = config[\"model_provider\"] ?? \"openai\";\n const definitions = config[\"model_providers\"];\n const definition =\n typeof provider === \"string\" &&\n isRecord(definitions) &&\n isRecord(definitions[provider])\n ? definitions[provider]\n : undefined;\n return {\n provider,\n baseUrl: definition?.[\"base_url\"],\n wireApi: definition?.[\"wire_api\"] ?? \"responses\",\n openaiBaseUrl:\n provider === \"openai\" ? config[\"openai_base_url\"] : undefined,\n };\n };\n // A managed sign-in home can contain only authentication/runtime settings.\n // Keep compatible caller model choices without crossing provider namespaces.\n if (\n isDeepStrictEqual(providerIdentity(ambient), providerIdentity(selected))\n ) {\n for (const key of [\"model\", \"model_reasoning_effort\"])\n if (selected[key] === undefined && ambient[key] !== undefined)\n selected[key] = ambient[key];\n }\n return selected;\n}\n"]}
|
package/dist/deep-scan.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-scan.d.ts","sourceRoot":"","sources":["../src/deep-scan.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAOtD,OAAO,EAGL,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AAErB,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAQtB,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;AAE3E,MAAM,WAAW,qBAAqB;IACpC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACnD,YAAY,EAAE,YAAY,GAAG;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACxD,gBAAgB,EAAE,YAAY,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,WAAW,CAAC;CACrB;AA+
|
|
1
|
+
{"version":3,"file":"deep-scan.d.ts","sourceRoot":"","sources":["../src/deep-scan.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAOtD,OAAO,EAGL,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AAErB,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAQtB,MAAM,M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