@openai/codex-security 0.8.2 → 0.9.1
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 +201 -178
- package/_bundled_plugin/.app.json +4 -0
- package/_bundled_plugin/.mcp.json +6 -1
- package/_bundled_plugin/examples/completed-scan/findings.json +16 -4
- package/_bundled_plugin/examples/completed-scan/report.md +11 -8
- package/_bundled_plugin/examples/completed-scan/scan-manifest.json +4 -2
- package/_bundled_plugin/mcp/fzstd-LICENSE.txt +21 -0
- package/_bundled_plugin/mcp/helpers.mjs +2 -11
- package/_bundled_plugin/mcp/helpers.mjs.br +0 -0
- package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +3 -210
- 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/package.json +1 -0
- package/_bundled_plugin/mcp/permission-profile-preflight.mjs +51 -14
- package/_bundled_plugin/mcp/server.mjs +2 -11
- package/_bundled_plugin/mcp/server.mjs.br +0 -0
- package/_bundled_plugin/mcp/session-decompression.mjs +712 -0
- package/_bundled_plugin/references/artifact-storage.md +1 -1
- package/_bundled_plugin/references/core-scan.md +14 -5
- package/_bundled_plugin/references/default-severity-rubric.md +33 -0
- package/_bundled_plugin/references/final-report.md +5 -3
- package/_bundled_plugin/references/finding-detail-fields.md +19 -18
- package/_bundled_plugin/references/sarif-adapter.md +8 -2
- package/_bundled_plugin/references/scan-artifacts.md +21 -12
- package/_bundled_plugin/references/scan-contract.md +27 -33
- package/_bundled_plugin/references/threat-model.md +1 -0
- package/_bundled_plugin/schemas/tools/scan-draft.schema.json +2 -2
- package/_bundled_plugin/scripts/check_deep_scan_target.py +97 -0
- package/_bundled_plugin/scripts/codex_profile.mjs +7 -1
- package/_bundled_plugin/scripts/deep_scan_config.py +20 -1
- package/_bundled_plugin/scripts/deep_scan_workbench.py +188 -454
- package/_bundled_plugin/scripts/filesystem_identity.py +1 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +317 -377
- package/_bundled_plugin/scripts/finding_preview.py +25 -29
- package/_bundled_plugin/scripts/launch_codex_security_mcp +1 -0
- package/_bundled_plugin/scripts/legacy_findings.py +148 -0
- package/_bundled_plugin/scripts/posix_scan_local_files.py +198 -0
- package/_bundled_plugin/scripts/read_codex_session.mjs +21 -0
- package/_bundled_plugin/scripts/report_projection.py +167 -178
- package/_bundled_plugin/scripts/review_state.py +8 -2
- package/_bundled_plugin/scripts/servicenow_avit.py +20 -0
- package/_bundled_plugin/scripts/snapshot_sqlite.py +1 -0
- package/_bundled_plugin/scripts/threat_model_projection.py +22 -26
- package/_bundled_plugin/scripts/validate_scan_contract.py +9 -7
- package/_bundled_plugin/scripts/windows_scan_local_files.py +600 -72
- package/_bundled_plugin/scripts/workbench/__init__.py +1 -1
- package/_bundled_plugin/scripts/workbench/handoff.py +47 -0
- package/_bundled_plugin/scripts/workbench/retained_coverage.py +38 -75
- package/_bundled_plugin/scripts/workbench/retained_records.py +18 -30
- package/_bundled_plugin/scripts/workbench/runtime_toml.py +4 -1
- package/_bundled_plugin/scripts/workbench/saved_coverage.py +152 -248
- package/_bundled_plugin/scripts/workbench/saved_outputs.py +9 -0
- package/_bundled_plugin/scripts/workbench/saved_sources.py +47 -40
- package/_bundled_plugin/scripts/workbench/storage.py +71 -7
- package/_bundled_plugin/scripts/workbench_cli.py +121 -14
- package/_bundled_plugin/scripts/workbench_constants.py +19 -0
- package/_bundled_plugin/scripts/workbench_coverage_receipts.py +3 -3
- package/_bundled_plugin/scripts/workbench_db.py +550 -492
- package/_bundled_plugin/scripts/workbench_feedback.py +8 -7
- package/_bundled_plugin/scripts/workbench_finding_index.py +1 -0
- package/_bundled_plugin/scripts/workbench_finding_workflows.py +90 -4
- package/_bundled_plugin/scripts/workbench_native_indexes.py +29 -33
- package/_bundled_plugin/scripts/workbench_progress.py +10 -1
- package/_bundled_plugin/scripts/workbench_publication.py +14 -10
- package/_bundled_plugin/scripts/workbench_remediation.py +508 -11
- package/_bundled_plugin/scripts/workbench_saved_results.py +132 -77
- package/_bundled_plugin/scripts/workbench_scan_history.py +139 -80
- package/_bundled_plugin/scripts/workbench_scan_start.py +84 -25
- package/_bundled_plugin/scripts/workbench_scan_usage.py +666 -117
- package/_bundled_plugin/scripts/workbench_schema.py +44 -55
- package/_bundled_plugin/scripts/workbench_setup.py +251 -0
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +13 -0
- package/_bundled_plugin/scripts/workbench_source_scopes.py +33 -23
- package/_bundled_plugin/scripts/workbench_target.py +330 -66
- package/_bundled_plugin/scripts/workbench_target_state.py +3 -0
- package/_bundled_plugin/scripts/workbench_validation.py +44 -12
- package/_bundled_plugin/shared/workbench-history-repairs.json +19 -16
- package/_bundled_plugin/shared/workbench-migrations.json +53 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +1 -1
- package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +4 -68
- package/_bundled_plugin/skills/check-skills/SKILL.md +43 -0
- package/_bundled_plugin/skills/check-skills/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/cloud-findings/SKILL.md +6 -4
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +7 -50
- package/_bundled_plugin/skills/fix-finding/SKILL.md +19 -2
- package/_bundled_plugin/skills/publish-findings/SKILL.md +81 -45
- package/_bundled_plugin/skills/publish-findings/references/checkmarx-import.md +37 -0
- package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +5 -24
- package/_bundled_plugin/skills/publish-findings/scripts/collect_checkmarx.py +464 -0
- package/_bundled_plugin/skills/threat-model-visualize/scripts/build_explorer.py +36 -9
- package/_bundled_plugin/skills/track-findings/SKILL.md +5 -3
- package/_bundled_plugin/skills/triage-finding/references/github-rest-intake.md +22 -68
- package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +12 -6
- package/dist/api.d.ts +45 -5
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +1144 -411
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +10 -7
- package/dist/auth.js.map +1 -1
- package/dist/bedrock-oss-pricing.d.ts +6 -0
- package/dist/bedrock-oss-pricing.d.ts.map +1 -0
- package/dist/bedrock-oss-pricing.js +58 -0
- package/dist/bedrock-oss-pricing.js.map +1 -0
- package/dist/bedrock-pricing.d.ts +15 -0
- package/dist/bedrock-pricing.d.ts.map +1 -0
- package/dist/bedrock-pricing.js +117 -0
- package/dist/bedrock-pricing.js.map +1 -0
- package/dist/blackduck-findings.d.ts +8 -0
- package/dist/blackduck-findings.d.ts.map +1 -0
- package/dist/blackduck-findings.js +320 -0
- package/dist/blackduck-findings.js.map +1 -0
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +51 -36
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/checkmarx-evidence.d.ts +19 -0
- package/dist/checkmarx-evidence.d.ts.map +1 -0
- package/dist/checkmarx-evidence.js +36 -0
- package/dist/checkmarx-evidence.js.map +1 -0
- package/dist/checkmarx-findings.d.ts +4 -0
- package/dist/checkmarx-findings.d.ts.map +1 -0
- package/dist/checkmarx-findings.js +27 -0
- package/dist/checkmarx-findings.js.map +1 -0
- package/dist/checkmarx-one.d.ts +4 -0
- package/dist/checkmarx-one.d.ts.map +1 -0
- package/dist/checkmarx-one.js +53 -0
- package/dist/checkmarx-one.js.map +1 -0
- package/dist/checkmarx-repository.d.ts +12 -0
- package/dist/checkmarx-repository.d.ts.map +1 -0
- package/dist/checkmarx-repository.js +181 -0
- package/dist/checkmarx-repository.js.map +1 -0
- package/dist/checkmarx-xml.d.ts +12 -0
- package/dist/checkmarx-xml.d.ts.map +1 -0
- package/dist/checkmarx-xml.js +196 -0
- package/dist/checkmarx-xml.js.map +1 -0
- package/dist/classify-severity-records.d.ts +6 -9
- package/dist/classify-severity-records.d.ts.map +1 -1
- package/dist/classify-severity-records.js +9 -21
- package/dist/classify-severity-records.js.map +1 -1
- package/dist/classify-severity.d.ts +4 -1
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +30 -13
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli.d.ts +14 -5
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2112 -1266
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.js +2 -2
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codex-prompt.d.ts +2 -0
- package/dist/codex-prompt.d.ts.map +1 -1
- package/dist/codex-prompt.js +6 -0
- package/dist/codex-prompt.js.map +1 -1
- package/dist/component-scan.d.ts +16 -3
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +32 -6
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +221 -65
- package/dist/config.js.map +1 -1
- package/dist/continuum-findings.d.ts +7 -0
- package/dist/continuum-findings.d.ts.map +1 -0
- package/dist/continuum-findings.js +225 -0
- package/dist/continuum-findings.js.map +1 -0
- package/dist/contract-values.d.ts +30 -0
- package/dist/contract-values.d.ts.map +1 -0
- package/dist/contract-values.js +78 -0
- package/dist/contract-values.js.map +1 -0
- package/dist/contract.d.ts +2 -20
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +58 -669
- package/dist/contract.js.map +1 -1
- package/dist/cost-model.d.ts +13 -1
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +66 -115
- package/dist/cost-model.js.map +1 -1
- package/dist/cost.d.ts +61 -4
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +2560 -100
- package/dist/cost.js.map +1 -1
- package/dist/custom-publish.d.ts +4 -0
- package/dist/custom-publish.d.ts.map +1 -1
- package/dist/custom-publish.js +40 -3
- package/dist/custom-publish.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 +5 -0
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/custom-validation.d.ts +2 -0
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +4 -0
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts +4 -4
- package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
- package/dist/deduplication/deduplication-prompts.js +2 -2
- package/dist/deduplication/deduplication-prompts.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts +14 -11
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
- package/dist/deduplication/deduplication-reviewer.js +11 -4
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/deduplication.js.map +1 -1
- package/dist/deduplication/finding-schema.d.ts +19 -1
- package/dist/deduplication/finding-schema.d.ts.map +1 -1
- package/dist/deduplication/finding-schema.js +25 -0
- package/dist/deduplication/finding-schema.js.map +1 -1
- package/dist/deduplication/local.d.ts +2 -2
- package/dist/deduplication/local.d.ts.map +1 -1
- package/dist/deduplication/local.js +5 -10
- package/dist/deduplication/local.js.map +1 -1
- package/dist/deduplication/records.d.ts +8 -2
- package/dist/deduplication/records.d.ts.map +1 -1
- package/dist/deduplication/records.js +36 -8
- package/dist/deduplication/records.js.map +1 -1
- package/dist/deduplication/refusal.d.ts.map +1 -1
- package/dist/deduplication/refusal.js +25 -5
- package/dist/deduplication/refusal.js.map +1 -1
- package/dist/deduplication/scan.d.ts +3 -0
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +1 -1
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-config.d.ts +0 -1
- package/dist/deep-config.d.ts.map +1 -1
- package/dist/deep-config.js +22 -33
- package/dist/deep-config.js.map +1 -1
- package/dist/deep-scan-defaults.d.ts +2 -0
- package/dist/deep-scan-defaults.d.ts.map +1 -1
- package/dist/deep-scan-defaults.js +28 -1
- package/dist/deep-scan-defaults.js.map +1 -1
- package/dist/deep-scan.d.ts +13 -0
- package/dist/deep-scan.d.ts.map +1 -1
- package/dist/deep-scan.js +262 -7
- package/dist/deep-scan.js.map +1 -1
- package/dist/default-severity-rubric.d.ts +1 -2
- package/dist/default-severity-rubric.d.ts.map +1 -1
- package/dist/default-severity-rubric.js +2 -66
- package/dist/default-severity-rubric.js.map +1 -1
- package/dist/endor-findings.d.ts +3 -1
- package/dist/endor-findings.d.ts.map +1 -1
- package/dist/endor-findings.js +108 -80
- package/dist/endor-findings.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +9 -2
- package/dist/errors.js.map +1 -1
- package/dist/external-findings-import.d.ts +5 -3
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +11 -16
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts +15 -4
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +619 -225
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +20 -6
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +2356 -308
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +28 -2
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +174 -81
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-findings.d.ts +17 -3
- package/dist/external-findings.d.ts.map +1 -1
- package/dist/external-findings.js +153 -1
- package/dist/external-findings.js.map +1 -1
- package/dist/external-import-contract.d.ts +33 -1
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +335 -51
- 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/feedback.d.ts.map +1 -1
- package/dist/feedback.js +5 -4
- package/dist/feedback.js.map +1 -1
- package/dist/finding-prompt.d.ts +5 -0
- package/dist/finding-prompt.d.ts.map +1 -0
- package/dist/finding-prompt.js +32 -0
- package/dist/finding-prompt.js.map +1 -0
- package/dist/finding-retrieval.d.ts +3 -3
- package/dist/finding-retrieval.d.ts.map +1 -1
- package/dist/finding-retrieval.js.map +1 -1
- package/dist/finding-workflow.d.ts +6 -1
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js +2 -2
- package/dist/finding-workflow.js.map +1 -1
- package/dist/findings-client.d.ts +1 -0
- package/dist/findings-client.d.ts.map +1 -1
- package/dist/findings-client.js +27 -3
- package/dist/findings-client.js.map +1 -1
- package/dist/git-remote.d.ts +4 -0
- package/dist/git-remote.d.ts.map +1 -1
- package/dist/git-remote.js +20 -0
- package/dist/git-remote.js.map +1 -1
- package/dist/github-advisories.d.ts +3 -12
- package/dist/github-advisories.d.ts.map +1 -1
- package/dist/github-advisories.js +9 -31
- package/dist/github-advisories.js.map +1 -1
- package/dist/github-dependabot-findings.d.ts.map +1 -1
- package/dist/github-dependabot-findings.js +22 -20
- package/dist/github-dependabot-findings.js.map +1 -1
- package/dist/github-findings.d.ts +4 -1
- package/dist/github-findings.d.ts.map +1 -1
- package/dist/github-findings.js +392 -79
- package/dist/github-findings.js.map +1 -1
- package/dist/github.d.ts +17 -7
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +43 -30
- package/dist/github.js.map +1 -1
- package/dist/host-protocol.d.ts +2 -2
- package/dist/host-protocol.d.ts.map +1 -1
- package/dist/host-protocol.js.map +1 -1
- package/dist/host-records-protocol.d.ts +10 -11
- package/dist/host-records-protocol.d.ts.map +1 -1
- package/dist/host-records-protocol.js +69 -9
- package/dist/host-records-protocol.js.map +1 -1
- package/dist/hosted-git-remotes.d.ts +5 -0
- package/dist/hosted-git-remotes.d.ts.map +1 -0
- package/dist/hosted-git-remotes.js +285 -0
- package/dist/hosted-git-remotes.js.map +1 -0
- package/dist/hosted-git-repository.d.ts +28 -0
- package/dist/hosted-git-repository.d.ts.map +1 -0
- package/dist/hosted-git-repository.js +222 -0
- package/dist/hosted-git-repository.js.map +1 -0
- package/dist/hosted-scan-protocol.js +2 -2
- package/dist/hosted-scan-protocol.js.map +1 -1
- package/dist/hosted-scan.d.ts +15 -0
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +71 -44
- package/dist/hosted-scan.js.map +1 -1
- package/dist/hosted-scanner-http.d.ts +21 -0
- package/dist/hosted-scanner-http.d.ts.map +1 -0
- package/dist/hosted-scanner-http.js +204 -0
- package/dist/hosted-scanner-http.js.map +1 -0
- package/dist/hosted-scanner-v1.d.ts +6 -0
- package/dist/hosted-scanner-v1.d.ts.map +1 -0
- package/dist/hosted-scanner-v1.js +60 -0
- package/dist/hosted-scanner-v1.js.map +1 -0
- package/dist/import-scan.d.ts.map +1 -1
- package/dist/import-scan.js +3 -0
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +24 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/inspector-findings.d.ts.map +1 -1
- package/dist/inspector-findings.js +58 -81
- package/dist/inspector-findings.js.map +1 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +86 -10
- package/dist/knowledge-base.js.map +1 -1
- package/dist/local-git-metadata.d.ts +5 -0
- package/dist/local-git-metadata.d.ts.map +1 -0
- package/dist/local-git-metadata.js +130 -0
- package/dist/local-git-metadata.js.map +1 -0
- package/dist/multiscan.d.ts +6 -4
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +160 -77
- package/dist/multiscan.js.map +1 -1
- package/dist/native-json-findings.d.ts +2 -1
- package/dist/native-json-findings.d.ts.map +1 -1
- package/dist/native-json-findings.js +12 -2
- package/dist/native-json-findings.js.map +1 -1
- package/dist/opengrep-findings.d.ts +1 -0
- package/dist/opengrep-findings.d.ts.map +1 -1
- package/dist/opengrep-findings.js +49 -31
- package/dist/opengrep-findings.js.map +1 -1
- package/dist/operation-telemetry.d.ts +104 -0
- package/dist/operation-telemetry.d.ts.map +1 -0
- package/dist/operation-telemetry.js +293 -0
- package/dist/operation-telemetry.js.map +1 -0
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +90 -35
- package/dist/patch-tui.js.map +1 -1
- package/dist/plugin-python-probe.d.ts +4 -0
- package/dist/plugin-python-probe.d.ts.map +1 -0
- package/dist/plugin-python-probe.js +10 -0
- package/dist/plugin-python-probe.js.map +1 -0
- package/dist/private-finding-import.d.ts +341 -0
- package/dist/private-finding-import.d.ts.map +1 -0
- package/dist/private-finding-import.js +411 -0
- package/dist/private-finding-import.js.map +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +2 -2
- package/dist/project-config.js.map +1 -1
- package/dist/provider-profile.d.ts +11 -3
- package/dist/provider-profile.d.ts.map +1 -1
- package/dist/provider-profile.js +80 -11
- package/dist/provider-profile.js.map +1 -1
- package/dist/publication-telemetry.d.ts +45 -0
- package/dist/publication-telemetry.d.ts.map +1 -0
- package/dist/publication-telemetry.js +50 -0
- package/dist/publication-telemetry.js.map +1 -0
- package/dist/publication.js +7 -1
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts +4 -0
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +42 -2
- package/dist/publish.js.map +1 -1
- package/dist/reader-selection.d.ts +15 -0
- package/dist/reader-selection.d.ts.map +1 -0
- package/dist/reader-selection.js +89 -0
- package/dist/reader-selection.js.map +1 -0
- package/dist/record.d.ts +6 -1
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +53 -2
- package/dist/record.js.map +1 -1
- package/dist/remediation.d.ts +3 -1
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +28 -2
- package/dist/remediation.js.map +1 -1
- package/dist/request-metadata.d.ts +3 -0
- package/dist/request-metadata.d.ts.map +1 -1
- package/dist/request-metadata.js +9 -0
- package/dist/request-metadata.js.map +1 -1
- package/dist/result.d.ts +6 -0
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +3 -1
- package/dist/result.js.map +1 -1
- package/dist/retry-windows-rename.d.ts +8 -0
- package/dist/retry-windows-rename.d.ts.map +1 -0
- package/dist/retry-windows-rename.js +24 -0
- package/dist/retry-windows-rename.js.map +1 -0
- package/dist/runtime.d.ts +22 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +408 -162
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan-bootstrap.d.ts +1 -0
- package/dist/saved-scan-bootstrap.d.ts.map +1 -1
- package/dist/saved-scan-bootstrap.js +18 -15
- package/dist/saved-scan-bootstrap.js.map +1 -1
- package/dist/scan-activity.d.ts.map +1 -1
- package/dist/scan-activity.js +172 -64
- package/dist/scan-activity.js.map +1 -1
- package/dist/scan-comparison.d.ts +10 -5
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +68 -25
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +7 -6
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +91 -79
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-executor.d.ts +12 -1
- package/dist/scan-executor.d.ts.map +1 -1
- package/dist/scan-executor.js +22 -2
- package/dist/scan-executor.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +31 -28
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts +12 -0
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +106 -77
- package/dist/scan-logs.js.map +1 -1
- package/dist/scan-measurement.d.ts +26 -0
- package/dist/scan-measurement.d.ts.map +1 -0
- package/dist/scan-measurement.js +77 -0
- package/dist/scan-measurement.js.map +1 -0
- package/dist/scan-progress.d.ts +1 -0
- package/dist/scan-progress.d.ts.map +1 -1
- package/dist/scan-progress.js +3 -0
- package/dist/scan-progress.js.map +1 -1
- package/dist/scan-sessions.d.ts.map +1 -1
- package/dist/scan-sessions.js +4 -1
- package/dist/scan-sessions.js.map +1 -1
- package/dist/scan-settings.d.ts +1 -1
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +1 -24
- package/dist/scan-settings.js.map +1 -1
- package/dist/scanner-import.d.ts +64 -6
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +406 -48
- package/dist/scanner-import.js.map +1 -1
- package/dist/scanner-repository-url.d.ts +17 -0
- package/dist/scanner-repository-url.d.ts.map +1 -0
- package/dist/scanner-repository-url.js +71 -0
- package/dist/scanner-repository-url.js.map +1 -0
- package/dist/security-policy.d.ts +1 -1
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js.map +1 -1
- package/dist/semgrep-findings.d.ts +6 -3
- package/dist/semgrep-findings.d.ts.map +1 -1
- package/dist/semgrep-findings.js +124 -88
- package/dist/semgrep-findings.js.map +1 -1
- package/dist/semgrep-guardian-findings.d.ts +38 -0
- package/dist/semgrep-guardian-findings.d.ts.map +1 -0
- package/dist/semgrep-guardian-findings.js +165 -0
- package/dist/semgrep-guardian-findings.js.map +1 -0
- package/dist/semgrep-platform-collector.d.ts +26 -0
- package/dist/semgrep-platform-collector.d.ts.map +1 -0
- package/dist/semgrep-platform-collector.js +108 -0
- package/dist/semgrep-platform-collector.js.map +1 -0
- package/dist/semgrep-platform-findings.d.ts +213 -0
- package/dist/semgrep-platform-findings.d.ts.map +1 -0
- package/dist/semgrep-platform-findings.js +1078 -0
- package/dist/semgrep-platform-findings.js.map +1 -0
- package/dist/semgrep-platform-v1.d.ts +6 -0
- package/dist/semgrep-platform-v1.d.ts.map +1 -0
- package/dist/semgrep-platform-v1.js +83 -0
- package/dist/semgrep-platform-v1.js.map +1 -0
- package/dist/server/api.d.ts +1 -1
- package/dist/server/api.d.ts.map +1 -1
- package/dist/server/api.js.map +1 -1
- package/dist/server/embedding-tokenizer.cdx.json +33 -0
- package/dist/server/embedding-tokenizer.d.ts +2 -0
- package/dist/server/embedding-tokenizer.d.ts.map +1 -0
- package/dist/server/embedding-tokenizer.js +322 -0
- package/dist/server/embedding-tokenizer.js.map +6 -0
- package/dist/server/embeddings.d.ts +16 -2
- package/dist/server/embeddings.d.ts.map +1 -1
- package/dist/server/embeddings.js +35 -5
- package/dist/server/embeddings.js.map +1 -1
- package/dist/session-lines.d.ts +5 -0
- package/dist/session-lines.d.ts.map +1 -0
- package/dist/session-lines.js +60 -0
- package/dist/session-lines.js.map +1 -0
- package/dist/severity-review.d.ts +3 -1
- package/dist/severity-review.d.ts.map +1 -1
- package/dist/severity-review.js +3 -2
- package/dist/severity-review.js.map +1 -1
- package/dist/severity-rubric.d.ts +20 -0
- package/dist/severity-rubric.d.ts.map +1 -0
- package/dist/severity-rubric.js +73 -0
- package/dist/severity-rubric.js.map +1 -0
- package/dist/severity-store.js +15 -5
- package/dist/severity-store.js.map +1 -1
- package/dist/skill-authentication.d.ts +1 -0
- package/dist/skill-authentication.d.ts.map +1 -1
- package/dist/skill-authentication.js +1 -0
- package/dist/skill-authentication.js.map +1 -1
- package/dist/snyk-findings.d.ts +7 -2
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +108 -84
- package/dist/snyk-findings.js.map +1 -1
- package/dist/snyk-rest-findings.d.ts +76 -0
- package/dist/snyk-rest-findings.d.ts.map +1 -0
- package/dist/snyk-rest-findings.js +1051 -0
- package/dist/snyk-rest-findings.js.map +1 -0
- package/dist/snyk-rest-v1.d.ts +28 -0
- package/dist/snyk-rest-v1.d.ts.map +1 -0
- package/dist/snyk-rest-v1.js +132 -0
- package/dist/snyk-rest-v1.js.map +1 -0
- package/dist/snyk-token-origin.d.ts +4 -0
- package/dist/snyk-token-origin.d.ts.map +1 -0
- package/dist/snyk-token-origin.js +82 -0
- package/dist/snyk-token-origin.js.map +1 -0
- package/dist/sonar-collector.d.ts +16 -0
- package/dist/sonar-collector.d.ts.map +1 -0
- package/dist/sonar-collector.js +380 -0
- package/dist/sonar-collector.js.map +1 -0
- package/dist/sonar-findings.d.ts +49 -0
- package/dist/sonar-findings.d.ts.map +1 -0
- package/dist/sonar-findings.js +288 -0
- package/dist/sonar-findings.js.map +1 -0
- package/dist/sonar-import.d.ts +111 -0
- package/dist/sonar-import.d.ts.map +1 -0
- package/dist/sonar-import.js +277 -0
- package/dist/sonar-import.js.map +1 -0
- package/dist/suggest-owners.d.ts.map +1 -1
- package/dist/suggest-owners.js +2 -1
- package/dist/suggest-owners.js.map +1 -1
- package/dist/target-drift.d.ts +9 -0
- package/dist/target-drift.d.ts.map +1 -0
- package/dist/target-drift.js +27 -0
- package/dist/target-drift.js.map +1 -0
- package/dist/targets.d.ts +5 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +73 -31
- package/dist/targets.js.map +1 -1
- package/dist/tenable-findings.d.ts +9 -0
- package/dist/tenable-findings.d.ts.map +1 -0
- package/dist/tenable-findings.js +122 -0
- package/dist/tenable-findings.js.map +1 -0
- package/dist/terminal-columns.d.ts +4 -0
- package/dist/terminal-columns.d.ts.map +1 -0
- package/dist/terminal-columns.js +19 -0
- package/dist/terminal-columns.js.map +1 -0
- package/dist/terminal-stream.d.ts +13 -0
- package/dist/terminal-stream.d.ts.map +1 -0
- package/dist/terminal-stream.js +35 -0
- package/dist/terminal-stream.js.map +1 -0
- package/dist/trivy-findings.d.ts +19 -0
- package/dist/trivy-findings.d.ts.map +1 -0
- package/dist/trivy-findings.js +435 -0
- package/dist/trivy-findings.js.map +1 -0
- package/dist/trivy-import.d.ts +19 -0
- package/dist/trivy-import.d.ts.map +1 -0
- package/dist/trivy-import.js +151 -0
- package/dist/trivy-import.js.map +1 -0
- package/dist/validation-records.d.ts +0 -3
- package/dist/validation-records.d.ts.map +1 -1
- package/dist/validation-records.js +1 -17
- package/dist/validation-records.js.map +1 -1
- package/dist/veracode-findings.d.ts +9 -0
- package/dist/veracode-findings.d.ts.map +1 -0
- package/dist/veracode-findings.js +409 -0
- package/dist/veracode-findings.js.map +1 -0
- package/dist/vertex-pricing.d.ts +8 -0
- package/dist/vertex-pricing.d.ts.map +1 -0
- package/dist/vertex-pricing.js +20 -0
- package/dist/vertex-pricing.js.map +1 -0
- package/dist/windows-path.d.ts +1 -0
- package/dist/windows-path.d.ts.map +1 -1
- package/dist/windows-path.js +27 -1
- package/dist/windows-path.js.map +1 -1
- package/dist/wiz-csv.d.ts +2 -2
- package/dist/wiz-csv.d.ts.map +1 -1
- package/dist/wiz-csv.js +1 -3
- package/dist/wiz-csv.js.map +1 -1
- package/dist/wiz-findings.d.ts +14 -2
- package/dist/wiz-findings.d.ts.map +1 -1
- package/dist/wiz-findings.js +143 -50
- package/dist/wiz-findings.js.map +1 -1
- package/docs/classify-severity-records.md +28 -13
- package/docs/cli.md +623 -843
- package/docs/dedupe-records.md +54 -24
- package/docs/findings-service.md +87 -47
- package/docs/hosted-remediation.md +14 -7
- package/docs/hosted-scans.md +64 -41
- package/docs/telemetry.md +236 -0
- package/docs/validate-records.md +78 -44
- package/package.json +19 -17
- package/schemas/external-findings.schema.json +14 -1
- package/schemas/hosted-scan-v2.fixture.json +16 -1
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
- package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +0 -96
- package/_bundled_plugin/scripts/validate_tracking_source.py +0 -82
- package/_bundled_plugin/scripts/workbench_local_dedupe.py +0 -136
- package/dist/deduplication/records-protocol.d.ts +0 -4
- package/dist/deduplication/records-protocol.d.ts.map +0 -1
- package/dist/deduplication/records-protocol.js +0 -49
- package/dist/deduplication/records-protocol.js.map +0 -1
- package/dist/external-imports-feature.d.ts +0 -6
- package/dist/external-imports-feature.d.ts.map +0 -1
- package/dist/external-imports-feature.js +0 -51
- package/dist/external-imports-feature.js.map +0 -1
- package/dist/finding-normalization.d.ts +0 -5
- package/dist/finding-normalization.d.ts.map +0 -1
- package/dist/finding-normalization.js +0 -120
- package/dist/finding-normalization.js.map +0 -1
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "codex-security://schemas/tools/deep-reducer.schema.json",
|
|
4
|
-
"title": "Codex Security Deep Scan semantic reducer operations",
|
|
5
|
-
"$ref": "#/$defs/reductionSubmission",
|
|
6
|
-
"$defs": {
|
|
7
|
-
"reducerInputs": {
|
|
8
|
-
"type": "object",
|
|
9
|
-
"properties": {
|
|
10
|
-
"cursor": {
|
|
11
|
-
"type": "string",
|
|
12
|
-
"pattern": "^(0|[1-9][0-9]*)$",
|
|
13
|
-
"description": "Continue the same document from its returned nextCursor."
|
|
14
|
-
},
|
|
15
|
-
"maxBytes": {
|
|
16
|
-
"type": "integer",
|
|
17
|
-
"minimum": 1,
|
|
18
|
-
"maximum": 9007199254740991,
|
|
19
|
-
"description": "Caller-selected byte budget for the serialized MCP response. Choose below the transport and output budgets; reduce it if transport reports an oversized response."
|
|
20
|
-
},
|
|
21
|
-
"findingRef": {
|
|
22
|
-
"type": "string",
|
|
23
|
-
"description": "Omit to page assigned findings and the previous aggregate without retained provenance bodies. Use source:<sourceFindingId> to fetch a complete original, or previous:<zero-based index> to fetch a complete previous aggregate finding, including its retained history."
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"required": ["maxBytes"],
|
|
27
|
-
"additionalProperties": false
|
|
28
|
-
},
|
|
29
|
-
"reductionInput": {
|
|
30
|
-
"type": "object",
|
|
31
|
-
"properties": {
|
|
32
|
-
"complete": {
|
|
33
|
-
"type": "boolean",
|
|
34
|
-
"description": "Omit or set true when submitting the finished aggregate."
|
|
35
|
-
},
|
|
36
|
-
"scanId": {
|
|
37
|
-
"$ref": "codex-security://schemas/definitions/artifact-common.schema.json#/$defs/scanId"
|
|
38
|
-
},
|
|
39
|
-
"handoffClaimToken": {
|
|
40
|
-
"$ref": "codex-security://schemas/tools/scan-draft.schema.json#/$defs/handoffClaimToken"
|
|
41
|
-
},
|
|
42
|
-
"scope": {
|
|
43
|
-
"$ref": "codex-security://schemas/tools/scan-draft.schema.json#/$defs/scope"
|
|
44
|
-
},
|
|
45
|
-
"threatModel": {
|
|
46
|
-
"$ref": "codex-security://schemas/tools/scan-draft.schema.json#/$defs/threatModel"
|
|
47
|
-
},
|
|
48
|
-
"findings": {
|
|
49
|
-
"type": "array",
|
|
50
|
-
"items": {
|
|
51
|
-
"$ref": "codex-security://schemas/tools/scan-draft.schema.json#/$defs/finding"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
"required": ["scanId", "findings"],
|
|
56
|
-
"additionalProperties": false
|
|
57
|
-
},
|
|
58
|
-
"reductionSubmission": {
|
|
59
|
-
"type": "object",
|
|
60
|
-
"properties": {
|
|
61
|
-
"complete": {
|
|
62
|
-
"type": "boolean",
|
|
63
|
-
"description": "Omit or set true when submitting the finished aggregate."
|
|
64
|
-
},
|
|
65
|
-
"scanId": {
|
|
66
|
-
"$ref": "codex-security://schemas/definitions/artifact-common.schema.json#/$defs/scanId"
|
|
67
|
-
},
|
|
68
|
-
"handoffClaimToken": {
|
|
69
|
-
"$ref": "codex-security://schemas/tools/scan-draft.schema.json#/$defs/handoffClaimToken"
|
|
70
|
-
},
|
|
71
|
-
"scope": {
|
|
72
|
-
"$ref": "codex-security://schemas/tools/scan-draft.schema.json#/$defs/scope"
|
|
73
|
-
},
|
|
74
|
-
"threatModel": {
|
|
75
|
-
"$ref": "codex-security://schemas/tools/scan-draft.schema.json#/$defs/threatModel"
|
|
76
|
-
},
|
|
77
|
-
"findings": {
|
|
78
|
-
"type": "array",
|
|
79
|
-
"items": {
|
|
80
|
-
"$ref": "codex-security://schemas/tools/scan-draft.schema.json#/$defs/finding"
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
"retainedFindingRefs": {
|
|
84
|
-
"type": "array",
|
|
85
|
-
"items": {
|
|
86
|
-
"type": "string",
|
|
87
|
-
"pattern": "^previous:(0|[1-9][0-9]*)$"
|
|
88
|
-
},
|
|
89
|
-
"description": "Copy unchanged previous aggregate findings by previous:<zero-based index>. The host preserves their complete bodies, identities, and source references; do not also submit them in findings."
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
"required": ["scanId", "findings"],
|
|
93
|
-
"additionalProperties": false
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Validate a sealed scan and list or select findings for tracking."""
|
|
3
|
-
|
|
4
|
-
from __future__ import annotations
|
|
5
|
-
|
|
6
|
-
import argparse
|
|
7
|
-
import sys
|
|
8
|
-
from pathlib import Path
|
|
9
|
-
from typing import Any
|
|
10
|
-
|
|
11
|
-
# Keep sibling helpers importable when Python starts in isolated mode.
|
|
12
|
-
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
13
|
-
import validate_scan_contract as SCAN_CONTRACT
|
|
14
|
-
|
|
15
|
-
FINALIZER = SCAN_CONTRACT.FINALIZER
|
|
16
|
-
validate_contract = SCAN_CONTRACT.validate_contract
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def _select_findings(
|
|
20
|
-
findings: list[dict[str, Any]],
|
|
21
|
-
finding_id: str | None,
|
|
22
|
-
fingerprint: str | None,
|
|
23
|
-
) -> list[dict[str, Any]]:
|
|
24
|
-
if finding_id is not None:
|
|
25
|
-
matches = [finding for finding in findings if finding["findingId"] == finding_id]
|
|
26
|
-
elif fingerprint is not None:
|
|
27
|
-
matches = [
|
|
28
|
-
finding for finding in findings if finding["fingerprints"]["primary"] == fingerprint
|
|
29
|
-
]
|
|
30
|
-
else:
|
|
31
|
-
return findings
|
|
32
|
-
|
|
33
|
-
if len(matches) != 1:
|
|
34
|
-
raise ValueError("the selector did not resolve exactly one finding")
|
|
35
|
-
return matches
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def validate_source(
|
|
39
|
-
scan_dir: Path,
|
|
40
|
-
*,
|
|
41
|
-
finding_id: str | None = None,
|
|
42
|
-
fingerprint: str | None = None,
|
|
43
|
-
) -> list[dict[str, Any]]:
|
|
44
|
-
if finding_id is not None and fingerprint is not None:
|
|
45
|
-
raise ValueError("use only one of --finding-id or --fingerprint")
|
|
46
|
-
|
|
47
|
-
validated = validate_contract(scan_dir)
|
|
48
|
-
findings_document = validated["findings"]
|
|
49
|
-
return _select_findings(
|
|
50
|
-
findings_document["findings"],
|
|
51
|
-
finding_id,
|
|
52
|
-
fingerprint,
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
def _parse_args(argv: list[str]) -> argparse.Namespace:
|
|
57
|
-
parser = argparse.ArgumentParser(description=__doc__)
|
|
58
|
-
parser.add_argument("scan_dir", type=Path)
|
|
59
|
-
selector = parser.add_mutually_exclusive_group()
|
|
60
|
-
selector.add_argument("--finding-id")
|
|
61
|
-
selector.add_argument("--fingerprint")
|
|
62
|
-
return parser.parse_args(argv)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
def main(argv: list[str] | None = None) -> int:
|
|
66
|
-
args = _parse_args(sys.argv[1:] if argv is None else argv)
|
|
67
|
-
try:
|
|
68
|
-
findings = validate_source(
|
|
69
|
-
args.scan_dir,
|
|
70
|
-
finding_id=args.finding_id,
|
|
71
|
-
fingerprint=args.fingerprint,
|
|
72
|
-
)
|
|
73
|
-
except (OSError, ValueError, RecursionError) as exc:
|
|
74
|
-
print(f"tracking source preflight failed: {exc}", file=sys.stderr)
|
|
75
|
-
return 2
|
|
76
|
-
for finding in findings:
|
|
77
|
-
print(finding["findingId"])
|
|
78
|
-
return 0
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if __name__ == "__main__":
|
|
82
|
-
raise SystemExit(main())
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"""Prepare and cache embeddings without publishing findings to an HTTP service."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
import argparse
|
|
6
|
-
import hashlib
|
|
7
|
-
import json
|
|
8
|
-
import math
|
|
9
|
-
import sqlite3
|
|
10
|
-
import sys
|
|
11
|
-
from pathlib import Path
|
|
12
|
-
from typing import Any
|
|
13
|
-
|
|
14
|
-
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
15
|
-
from workbench_finding_index import upsert_finding
|
|
16
|
-
from workbench_target_state import stable_target_id
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def cache_key(space: str, document: str) -> str:
|
|
20
|
-
return hashlib.sha256(f"{space}\0{document}".encode()).hexdigest()
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def local_dedupe(
|
|
24
|
-
connection: sqlite3.Connection, payload: dict[str, Any], timestamp: str
|
|
25
|
-
) -> dict[str, Any]:
|
|
26
|
-
action = payload["action"]
|
|
27
|
-
try:
|
|
28
|
-
with connection:
|
|
29
|
-
connection.execute("BEGIN IMMEDIATE")
|
|
30
|
-
if action == "prepare":
|
|
31
|
-
return prepare(connection, payload, timestamp)
|
|
32
|
-
if action == "embed":
|
|
33
|
-
for entry in payload["entries"]:
|
|
34
|
-
row = connection.execute(
|
|
35
|
-
"SELECT details_json FROM findings WHERE id = ?", (entry["findingId"],)
|
|
36
|
-
).fetchone()
|
|
37
|
-
if (
|
|
38
|
-
row is None
|
|
39
|
-
or cache_key(payload["space"], row["details_json"]) != entry["cacheKey"]
|
|
40
|
-
):
|
|
41
|
-
raise ValueError("finding_changed")
|
|
42
|
-
embedding = entry["embedding"]
|
|
43
|
-
vector = embedding["vector"]
|
|
44
|
-
if (
|
|
45
|
-
embedding["model"] != payload["model"]
|
|
46
|
-
or len(vector) != payload["dimensions"]
|
|
47
|
-
or not all(isinstance(v, (int, float)) and math.isfinite(v) for v in vector)
|
|
48
|
-
or not math.isfinite(math.hypot(*vector))
|
|
49
|
-
or math.hypot(*vector) == 0
|
|
50
|
-
):
|
|
51
|
-
raise ValueError("embedding_failed")
|
|
52
|
-
connection.execute(
|
|
53
|
-
"INSERT INTO local_finding_embeddings (finding_id, model, vector_json, cache_key) "
|
|
54
|
-
"VALUES (?, ?, ?, ?) ON CONFLICT(finding_id) DO UPDATE SET "
|
|
55
|
-
"model = excluded.model, vector_json = excluded.vector_json, "
|
|
56
|
-
"cache_key = excluded.cache_key",
|
|
57
|
-
(
|
|
58
|
-
entry["findingId"],
|
|
59
|
-
embedding["model"],
|
|
60
|
-
json.dumps(vector, allow_nan=False),
|
|
61
|
-
entry["cacheKey"],
|
|
62
|
-
),
|
|
63
|
-
)
|
|
64
|
-
return {}
|
|
65
|
-
raise ValueError("invalid_request")
|
|
66
|
-
except sqlite3.IntegrityError:
|
|
67
|
-
return {"error": "finding_conflict"}
|
|
68
|
-
except ValueError as exc:
|
|
69
|
-
return {"error": str(exc)}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
def prepare(
|
|
73
|
-
connection: sqlite3.Connection, payload: dict[str, Any], timestamp: str
|
|
74
|
-
) -> dict[str, Any]:
|
|
75
|
-
# Artifact seals establish consistency, not permission to select another local corpus.
|
|
76
|
-
target = Path(payload["repositoryPath"]).resolve()
|
|
77
|
-
registered = connection.execute(
|
|
78
|
-
"SELECT id FROM security_targets WHERE current_path = ?", (str(target),)
|
|
79
|
-
).fetchone()
|
|
80
|
-
target_id = registered["id"] if registered is not None else stable_target_id(target)
|
|
81
|
-
if (
|
|
82
|
-
payload["anchorRepositoryId"] != target_id
|
|
83
|
-
or payload.get("repositoryId", target_id) != target_id
|
|
84
|
-
):
|
|
85
|
-
raise ValueError("target_mismatch")
|
|
86
|
-
if not payload["findings"]:
|
|
87
|
-
return {"cacheKeys": {}, "findingsToEmbed": []}
|
|
88
|
-
# A sealed historical scan selects logical IDs; never overwrite their current bodies.
|
|
89
|
-
for finding in payload["findings"]:
|
|
90
|
-
existing = connection.execute(
|
|
91
|
-
"SELECT fingerprint, rule_id, identity_anchor, identity_instance, details_json "
|
|
92
|
-
"FROM findings WHERE id = ?",
|
|
93
|
-
(finding["findingId"],),
|
|
94
|
-
).fetchone()
|
|
95
|
-
identity = (
|
|
96
|
-
finding["fingerprints"]["primary"],
|
|
97
|
-
finding["ruleId"],
|
|
98
|
-
finding["identity"]["anchor"],
|
|
99
|
-
finding["identity"].get("instance"),
|
|
100
|
-
)
|
|
101
|
-
if existing is not None and tuple(existing)[:4] != identity:
|
|
102
|
-
raise sqlite3.IntegrityError("Conflicting finding identity")
|
|
103
|
-
if existing is None or existing["details_json"] is None:
|
|
104
|
-
upsert_finding(connection, finding, timestamp, payload["anchorRepositoryId"])
|
|
105
|
-
else:
|
|
106
|
-
connection.execute(
|
|
107
|
-
"INSERT OR IGNORE INTO finding_repositories (repository_id, finding_id) VALUES (?, ?)",
|
|
108
|
-
(payload["anchorRepositoryId"], finding["findingId"]),
|
|
109
|
-
)
|
|
110
|
-
repository_id = payload.get("repositoryId")
|
|
111
|
-
rows = connection.execute(
|
|
112
|
-
"SELECT findings.id, findings.details_json, embeddings.cache_key FROM findings "
|
|
113
|
-
"LEFT JOIN local_finding_embeddings AS embeddings ON findings.id = embeddings.finding_id "
|
|
114
|
-
+ (
|
|
115
|
-
"WHERE EXISTS (SELECT 1 FROM finding_repositories WHERE finding_id = findings.id "
|
|
116
|
-
"AND repository_id = ?) "
|
|
117
|
-
if repository_id is not None
|
|
118
|
-
else ""
|
|
119
|
-
)
|
|
120
|
-
+ "ORDER BY findings.created_at, findings.id",
|
|
121
|
-
(repository_id,) if repository_id is not None else (),
|
|
122
|
-
)
|
|
123
|
-
cache_keys = {}
|
|
124
|
-
findings_to_embed = []
|
|
125
|
-
for row in rows:
|
|
126
|
-
if row["details_json"] is None:
|
|
127
|
-
raise ValueError("finding_not_indexed")
|
|
128
|
-
key = cache_key(payload["space"], row["details_json"])
|
|
129
|
-
cache_keys[row["id"]] = key
|
|
130
|
-
if key != row["cache_key"]:
|
|
131
|
-
findings_to_embed.append(json.loads(row["details_json"]))
|
|
132
|
-
return {"cacheKeys": cache_keys, "findingsToEmbed": findings_to_embed}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if __name__ == "__main__":
|
|
136
|
-
argparse.ArgumentParser(description=__doc__).parse_args()
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Readable } from "node:stream";
|
|
2
|
-
import { runHostProtocol } from "../host-protocol.js";
|
|
3
|
-
export declare function runRecordsProtocol(input: Readable, output: Parameters<typeof runHostProtocol>[1], signal?: AbortSignal): Promise<number>;
|
|
4
|
-
//# sourceMappingURL=records-protocol.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"records-protocol.d.ts","sourceRoot":"","sources":["../../src/deduplication/records-protocol.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EAA2B,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAQ/E,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,EAC7C,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,CA0DjB"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { missingSubmissionPrompt } from "./deduplication-prompts.js";
|
|
4
|
-
import { PendingReviewSubmission, runHostProtocol } from "../host-protocol.js";
|
|
5
|
-
import { runRecords } from "./records.js";
|
|
6
|
-
const missingSubmission = z.strictObject({
|
|
7
|
-
status: z.literal("missing_submission"),
|
|
8
|
-
});
|
|
9
|
-
const released = z.strictObject({ status: z.literal("released") });
|
|
10
|
-
export async function runRecordsProtocol(input, output, signal) {
|
|
11
|
-
return await runHostProtocol(input, output, {
|
|
12
|
-
label: "Deduplication",
|
|
13
|
-
requestMethod: "review.run",
|
|
14
|
-
run: (params, execute, signal) => runRecords(params, async (request, validateSubmission) => {
|
|
15
|
-
const first = await execute(request.requestId, {
|
|
16
|
-
...request,
|
|
17
|
-
supportsContinuation: true,
|
|
18
|
-
supportsSubmissionValidation: true,
|
|
19
|
-
});
|
|
20
|
-
let rejection;
|
|
21
|
-
if (first instanceof PendingReviewSubmission) {
|
|
22
|
-
try {
|
|
23
|
-
validateSubmission(first.submission);
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
rejection =
|
|
27
|
-
error instanceof Error
|
|
28
|
-
? error.message
|
|
29
|
-
: "Invalid submission.";
|
|
30
|
-
}
|
|
31
|
-
if (rejection === undefined) {
|
|
32
|
-
const receipt = await execute(randomUUID(), { requestId: request.requestId }, undefined, "review.release");
|
|
33
|
-
released.parse(receipt);
|
|
34
|
-
return first.submission;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
else if (!missingSubmission.safeParse(first).success)
|
|
38
|
-
return first;
|
|
39
|
-
const result = await execute(randomUUID(), {
|
|
40
|
-
requestId: request.requestId,
|
|
41
|
-
prompt: missingSubmissionPrompt(rejection),
|
|
42
|
-
}, undefined, "review.continue");
|
|
43
|
-
if (missingSubmission.safeParse(result).success)
|
|
44
|
-
throw new Error("Review ended without a terminal submission after correction.");
|
|
45
|
-
return result;
|
|
46
|
-
}, signal),
|
|
47
|
-
}, signal);
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=records-protocol.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"records-protocol.js","sourceRoot":"","sources":["../../src/deduplication/records-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAgC,MAAM,cAAc,CAAC;AAExE,MAAM,iBAAiB,GAAG,CAAC,CAAC,YAAY,CAAC;IACvC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC;CACxC,CAAC,CAAC;AACH,MAAM,QAAQ,GAAG,CAAC,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;AAEnE,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAAe,EACf,MAA6C,EAC7C,MAAoB;IAEpB,OAAO,MAAM,eAAe,CAC1B,KAAK,EACL,MAAM,EACN;QACE,KAAK,EAAE,eAAe;QACtB,aAAa,EAAE,YAAY;QAC3B,GAAG,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAC/B,UAAU,CACR,MAAiC,EACjC,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,EAAE;YACpC,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE;gBAC7C,GAAG,OAAO;gBACV,oBAAoB,EAAE,IAAI;gBAC1B,4BAA4B,EAAE,IAAI;aACnC,CAAC,CAAC;YACH,IAAI,SAA6B,CAAC;YAClC,IAAI,KAAK,YAAY,uBAAuB,EAAE,CAAC;gBAC7C,IAAI,CAAC;oBACH,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBACvC,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,SAAS;wBACP,KAAK,YAAY,KAAK;4BACpB,CAAC,CAAC,KAAK,CAAC,OAAO;4BACf,CAAC,CAAC,qBAAqB,CAAC;gBAC9B,CAAC;gBACD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;oBAC5B,MAAM,OAAO,GAAG,MAAM,OAAO,CAC3B,UAAU,EAAE,EACZ,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,EAChC,SAAS,EACT,gBAAgB,CACjB,CAAC;oBACF,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;oBACxB,OAAO,KAAK,CAAC,UAAU,CAAC;gBAC1B,CAAC;YACH,CAAC;iBAAM,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO;gBACpD,OAAO,KAAK,CAAC;YACf,MAAM,MAAM,GAAG,MAAM,OAAO,CAC1B,UAAU,EAAE,EACZ;gBACE,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,MAAM,EAAE,uBAAuB,CAAC,SAAS,CAAC;aAC3C,EACD,SAAS,EACT,iBAAiB,CAClB,CAAC;YACF,IAAI,iBAAiB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO;gBAC7C,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAC;YACJ,OAAO,MAAM,CAAC;QAChB,CAAC,EACD,MAAM,CACP;KACJ,EACD,MAAM,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { Readable } from \"node:stream\";\nimport { z } from \"zod\";\nimport { missingSubmissionPrompt } from \"./deduplication-prompts.js\";\nimport { PendingReviewSubmission, runHostProtocol } from \"../host-protocol.js\";\nimport { runRecords, type DeduplicateRecordsInput } from \"./records.js\";\n\nconst missingSubmission = z.strictObject({\n status: z.literal(\"missing_submission\"),\n});\nconst released = z.strictObject({ status: z.literal(\"released\") });\n\nexport async function runRecordsProtocol(\n input: Readable,\n output: Parameters<typeof runHostProtocol>[1],\n signal?: AbortSignal,\n): Promise<number> {\n return await runHostProtocol(\n input,\n output,\n {\n label: \"Deduplication\",\n requestMethod: \"review.run\",\n run: (params, execute, signal) =>\n runRecords(\n params as DeduplicateRecordsInput,\n async (request, validateSubmission) => {\n const first = await execute(request.requestId, {\n ...request,\n supportsContinuation: true,\n supportsSubmissionValidation: true,\n });\n let rejection: string | undefined;\n if (first instanceof PendingReviewSubmission) {\n try {\n validateSubmission(first.submission);\n } catch (error) {\n rejection =\n error instanceof Error\n ? error.message\n : \"Invalid submission.\";\n }\n if (rejection === undefined) {\n const receipt = await execute(\n randomUUID(),\n { requestId: request.requestId },\n undefined,\n \"review.release\",\n );\n released.parse(receipt);\n return first.submission;\n }\n } else if (!missingSubmission.safeParse(first).success)\n return first;\n const result = await execute(\n randomUUID(),\n {\n requestId: request.requestId,\n prompt: missingSubmissionPrompt(rejection),\n },\n undefined,\n \"review.continue\",\n );\n if (missingSubmission.safeParse(result).success)\n throw new Error(\n \"Review ended without a terminal submission after correction.\",\n );\n return result;\n },\n signal,\n ),\n },\n signal,\n );\n}\n"]}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const externalImportsDisabledMessage = "External findings imports are disabled. Set CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS=1 to enable them.";
|
|
2
|
-
export declare function externalImportsEnabled(environment?: NodeJS.ProcessEnv): boolean;
|
|
3
|
-
/** Preserve the selected flag while copying a caller's environment for a child. */
|
|
4
|
-
export declare function forwardExternalImportSetting<Value>(source: Record<string, Value | undefined>, child: Record<string, Value>): void;
|
|
5
|
-
export declare function requireExternalImports(environment?: NodeJS.ProcessEnv): void;
|
|
6
|
-
//# sourceMappingURL=external-imports-feature.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"external-imports-feature.d.ts","sourceRoot":"","sources":["../src/external-imports-feature.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,8BAA8B,yGAA0E,CAAC;AA6BtH,wBAAgB,sBAAsB,CACpC,WAAW,GAAE,MAAM,CAAC,UAAwB,GAC3C,OAAO,CAET;AAED,mFAAmF;AACnF,wBAAgB,4BAA4B,CAAC,KAAK,EAChD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,GAAG,SAAS,CAAC,EACzC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAC3B,IAAI,CAUN;AAED,wBAAgB,sBAAsB,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,UAAU,GAAG,IAAI,CAI5E"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { CodexSecurityError } from "./errors.js";
|
|
2
|
-
const flag = "CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS";
|
|
3
|
-
export const externalImportsDisabledMessage = `External findings imports are disabled. Set ${flag}=1 to enable them.`;
|
|
4
|
-
function externalImportSetting(environment) {
|
|
5
|
-
const exact = environment[flag];
|
|
6
|
-
if (process.platform !== "win32")
|
|
7
|
-
return { key: flag, value: exact };
|
|
8
|
-
// A scan can override a case-insensitive process.env with its own spelling.
|
|
9
|
-
function callerDeclares(key) {
|
|
10
|
-
for (let owner = environment; owner && owner !== process.env; owner = Object.getPrototypeOf(owner)) {
|
|
11
|
-
if (Object.hasOwn(owner, key))
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
if (exact !== undefined && callerDeclares(flag))
|
|
17
|
-
return { key: flag, value: exact };
|
|
18
|
-
// Node includes enumerable prototype keys and sorts competing spellings.
|
|
19
|
-
const keys = [];
|
|
20
|
-
for (const name in environment) {
|
|
21
|
-
if (name.toUpperCase() === flag)
|
|
22
|
-
keys.push(name);
|
|
23
|
-
}
|
|
24
|
-
keys.sort();
|
|
25
|
-
const key = keys.find(callerDeclares) ?? keys[0];
|
|
26
|
-
if (key !== undefined)
|
|
27
|
-
return { key, value: key === flag ? exact : environment[key] };
|
|
28
|
-
}
|
|
29
|
-
export function externalImportsEnabled(environment = process.env) {
|
|
30
|
-
return externalImportSetting(environment)?.value === "1";
|
|
31
|
-
}
|
|
32
|
-
/** Preserve the selected flag while copying a caller's environment for a child. */
|
|
33
|
-
export function forwardExternalImportSetting(source, child) {
|
|
34
|
-
const selected = externalImportSetting(source);
|
|
35
|
-
if (selected === undefined)
|
|
36
|
-
return;
|
|
37
|
-
if (process.platform === "win32") {
|
|
38
|
-
for (const name of Object.keys(child)) {
|
|
39
|
-
if (name !== selected.key && name.toUpperCase() === flag)
|
|
40
|
-
delete child[name];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (selected.value !== undefined)
|
|
44
|
-
child[selected.key] = selected.value;
|
|
45
|
-
}
|
|
46
|
-
export function requireExternalImports(environment) {
|
|
47
|
-
if (!externalImportsEnabled(environment)) {
|
|
48
|
-
throw new CodexSecurityError(externalImportsDisabledMessage);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=external-imports-feature.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"external-imports-feature.js","sourceRoot":"","sources":["../src/external-imports-feature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,IAAI,GAAG,wCAAwC,CAAC;AACtD,MAAM,CAAC,MAAM,8BAA8B,GAAG,+CAA+C,IAAI,oBAAoB,CAAC;AAEtH,SAAS,qBAAqB,CAAQ,WAAkC;IACtE,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IACrE,4EAA4E;IAC5E,SAAS,cAAc,CAAC,GAAW;QACjC,KACE,IAAI,KAAK,GAAkB,WAAW,EACtC,KAAK,IAAI,KAAK,KAAK,OAAO,CAAC,GAAG,EAC9B,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,EACpC,CAAC;YACD,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC;gBAAE,OAAO,IAAI,CAAC;QAC7C,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,IAAI,cAAc,CAAC,IAAI,CAAC;QAC7C,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IACrC,yEAAyE;IACzE,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;QAC/B,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI;YAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IACD,IAAI,CAAC,IAAI,EAAE,CAAC;IACZ,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;IACjD,IAAI,GAAG,KAAK,SAAS;QACnB,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,WAAW,GAAsB,OAAO,CAAC,GAAG;IAE5C,OAAO,qBAAqB,CAAC,WAAW,CAAC,EAAE,KAAK,KAAK,GAAG,CAAC;AAC3D,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,4BAA4B,CAC1C,MAAyC,EACzC,KAA4B;IAE5B,MAAM,QAAQ,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC/C,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO;IACnC,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACtC,IAAI,IAAI,KAAK,QAAQ,CAAC,GAAG,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI;gBACtD,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IACD,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS;QAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,WAA+B;IACpE,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,kBAAkB,CAAC,8BAA8B,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC","sourcesContent":["import { CodexSecurityError } from \"./errors.js\";\n\nconst flag = \"CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS\";\nexport const externalImportsDisabledMessage = `External findings imports are disabled. Set ${flag}=1 to enable them.`;\n\nfunction externalImportSetting<Value>(environment: Record<string, Value>) {\n const exact = environment[flag];\n if (process.platform !== \"win32\") return { key: flag, value: exact };\n // A scan can override a case-insensitive process.env with its own spelling.\n function callerDeclares(key: string): boolean {\n for (\n let owner: object | null = environment;\n owner && owner !== process.env;\n owner = Object.getPrototypeOf(owner)\n ) {\n if (Object.hasOwn(owner, key)) return true;\n }\n return false;\n }\n if (exact !== undefined && callerDeclares(flag))\n return { key: flag, value: exact };\n // Node includes enumerable prototype keys and sorts competing spellings.\n const keys: string[] = [];\n for (const name in environment) {\n if (name.toUpperCase() === flag) keys.push(name);\n }\n keys.sort();\n const key = keys.find(callerDeclares) ?? keys[0];\n if (key !== undefined)\n return { key, value: key === flag ? exact : environment[key] };\n}\n\nexport function externalImportsEnabled(\n environment: NodeJS.ProcessEnv = process.env,\n): boolean {\n return externalImportSetting(environment)?.value === \"1\";\n}\n\n/** Preserve the selected flag while copying a caller's environment for a child. */\nexport function forwardExternalImportSetting<Value>(\n source: Record<string, Value | undefined>,\n child: Record<string, Value>,\n): void {\n const selected = externalImportSetting(source);\n if (selected === undefined) return;\n if (process.platform === \"win32\") {\n for (const name of Object.keys(child)) {\n if (name !== selected.key && name.toUpperCase() === flag)\n delete child[name];\n }\n }\n if (selected.value !== undefined) child[selected.key] = selected.value;\n}\n\nexport function requireExternalImports(environment?: NodeJS.ProcessEnv): void {\n if (!externalImportsEnabled(environment)) {\n throw new CodexSecurityError(externalImportsDisabledMessage);\n }\n}\n"]}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
type JsonObject = Record<string, unknown>;
|
|
2
|
-
/** Compatibility for historical report reads; never use this to admit new writes. */
|
|
3
|
-
export declare function normalizePersistedFindingDetails(finding: JsonObject): void;
|
|
4
|
-
export {};
|
|
5
|
-
//# sourceMappingURL=finding-normalization.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"finding-normalization.d.ts","sourceRoot":"","sources":["../src/finding-normalization.ts"],"names":[],"mappings":"AAEA,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C,qFAAqF;AACrF,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAkI1E"}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { isRecord as isObject } from "./record.js";
|
|
2
|
-
/** Compatibility for historical report reads; never use this to admit new writes. */
|
|
3
|
-
export function normalizePersistedFindingDetails(finding) {
|
|
4
|
-
if (Array.isArray(finding["code_evidence"])) {
|
|
5
|
-
finding["code_evidence"] = finding["code_evidence"].filter((evidence) => isObject(evidence) &&
|
|
6
|
-
isNonEmptyString(evidence["id"]) &&
|
|
7
|
-
isNonEmptyString(evidence["code"]));
|
|
8
|
-
}
|
|
9
|
-
else if (finding["code_evidence"] !== null) {
|
|
10
|
-
delete finding["code_evidence"];
|
|
11
|
-
}
|
|
12
|
-
for (const [sectionName, listFields] of [
|
|
13
|
-
["rootCause", ["evidenceRefs", "evidence_refs"]],
|
|
14
|
-
["root_cause", ["evidenceRefs", "evidence_refs"]],
|
|
15
|
-
[
|
|
16
|
-
"validation",
|
|
17
|
-
[
|
|
18
|
-
"assertions",
|
|
19
|
-
"counterEvidence",
|
|
20
|
-
"evidence",
|
|
21
|
-
"evidenceRefs",
|
|
22
|
-
"evidence_refs",
|
|
23
|
-
"limitations",
|
|
24
|
-
],
|
|
25
|
-
],
|
|
26
|
-
[
|
|
27
|
-
"attackPath",
|
|
28
|
-
[
|
|
29
|
-
"assumptions",
|
|
30
|
-
"blindspots",
|
|
31
|
-
"controls",
|
|
32
|
-
"evidenceRefs",
|
|
33
|
-
"evidence_refs",
|
|
34
|
-
"limitations",
|
|
35
|
-
"preconditions",
|
|
36
|
-
"steps",
|
|
37
|
-
],
|
|
38
|
-
],
|
|
39
|
-
]) {
|
|
40
|
-
const section = finding[sectionName];
|
|
41
|
-
if (!isObject(section))
|
|
42
|
-
continue;
|
|
43
|
-
normalizePersistedStringLists(section, listFields);
|
|
44
|
-
}
|
|
45
|
-
const legacyRootCause = finding["root_cause"];
|
|
46
|
-
if (isObject(legacyRootCause)) {
|
|
47
|
-
removeUnsupportedPersistedStrings(legacyRootCause, [
|
|
48
|
-
"summary",
|
|
49
|
-
"code",
|
|
50
|
-
"language",
|
|
51
|
-
]);
|
|
52
|
-
}
|
|
53
|
-
else if (legacyRootCause !== null && typeof legacyRootCause !== "string") {
|
|
54
|
-
delete finding["root_cause"];
|
|
55
|
-
}
|
|
56
|
-
const validation = finding["validation"];
|
|
57
|
-
if (isObject(validation)) {
|
|
58
|
-
removeUnsupportedPersistedStrings(validation, ["method", "status", "summary", "disposition", "result"].filter((field) => !["status", "disposition", "result"].includes(field) ||
|
|
59
|
-
validation[field] !== null));
|
|
60
|
-
}
|
|
61
|
-
const attackPath = finding["attackPath"];
|
|
62
|
-
if (!isObject(attackPath))
|
|
63
|
-
return;
|
|
64
|
-
removeUnsupportedPersistedStrings(attackPath, ["summary"]);
|
|
65
|
-
for (const field of ["dataFlow", "data_flow", "dataflow", "reachability"]) {
|
|
66
|
-
const detail = attackPath[field];
|
|
67
|
-
if (!isObject(detail)) {
|
|
68
|
-
if (!isNonEmptyString(detail))
|
|
69
|
-
delete attackPath[field];
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
removeUnsupportedPersistedStrings(detail, [
|
|
73
|
-
"summary",
|
|
74
|
-
"source",
|
|
75
|
-
"sink",
|
|
76
|
-
"outcome",
|
|
77
|
-
...(field === "reachability" ? ["attacker", "entrypoint"] : []),
|
|
78
|
-
]);
|
|
79
|
-
normalizePersistedStringLists(detail, [
|
|
80
|
-
"evidenceRefs",
|
|
81
|
-
"evidence_refs",
|
|
82
|
-
"transformations",
|
|
83
|
-
...(field === "reachability" ? ["preconditions"] : []),
|
|
84
|
-
]);
|
|
85
|
-
}
|
|
86
|
-
for (const field of ["impact", "likelihood"]) {
|
|
87
|
-
const detail = attackPath[field];
|
|
88
|
-
if (isObject(detail)) {
|
|
89
|
-
removeUnsupportedPersistedStrings(detail, ["level", "rationale", "why"]);
|
|
90
|
-
}
|
|
91
|
-
else if (detail !== undefined &&
|
|
92
|
-
detail !== null &&
|
|
93
|
-
!isNonEmptyString(detail)) {
|
|
94
|
-
delete attackPath[field];
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function normalizePersistedStringLists(section, fields) {
|
|
98
|
-
for (const field of fields) {
|
|
99
|
-
const value = section[field];
|
|
100
|
-
if (isNonEmptyString(value)) {
|
|
101
|
-
if (field !== "evidence")
|
|
102
|
-
section[field] = [value];
|
|
103
|
-
}
|
|
104
|
-
else if (Array.isArray(value))
|
|
105
|
-
section[field] = value.filter(isNonEmptyString);
|
|
106
|
-
else
|
|
107
|
-
delete section[field];
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function removeUnsupportedPersistedStrings(section, fields) {
|
|
111
|
-
for (const field of fields) {
|
|
112
|
-
if (!isNonEmptyString(section[field]))
|
|
113
|
-
delete section[field];
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function isNonEmptyString(value) {
|
|
117
|
-
return typeof value === "string" && value.length > 0;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
//# sourceMappingURL=finding-normalization.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"finding-normalization.js","sourceRoot":"","sources":["../src/finding-normalization.ts"],"names":[],"mappings":"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","sourcesContent":["import { isRecord as isObject } from \"./record.js\";\n\ntype JsonObject = Record<string, unknown>;\n\n/** Compatibility for historical report reads; never use this to admit new writes. */\nexport function normalizePersistedFindingDetails(finding: JsonObject): void {\n if (Array.isArray(finding[\"code_evidence\"])) {\n finding[\"code_evidence\"] = finding[\"code_evidence\"].filter(\n (evidence) =>\n isObject(evidence) &&\n isNonEmptyString(evidence[\"id\"]) &&\n isNonEmptyString(evidence[\"code\"]),\n );\n } else if (finding[\"code_evidence\"] !== null) {\n delete finding[\"code_evidence\"];\n }\n\n for (const [sectionName, listFields] of [\n [\"rootCause\", [\"evidenceRefs\", \"evidence_refs\"]],\n [\"root_cause\", [\"evidenceRefs\", \"evidence_refs\"]],\n [\n \"validation\",\n [\n \"assertions\",\n \"counterEvidence\",\n \"evidence\",\n \"evidenceRefs\",\n \"evidence_refs\",\n \"limitations\",\n ],\n ],\n [\n \"attackPath\",\n [\n \"assumptions\",\n \"blindspots\",\n \"controls\",\n \"evidenceRefs\",\n \"evidence_refs\",\n \"limitations\",\n \"preconditions\",\n \"steps\",\n ],\n ],\n ] satisfies Array<[string, string[]]>) {\n const section = finding[sectionName];\n if (!isObject(section)) continue;\n normalizePersistedStringLists(section, listFields);\n }\n\n const legacyRootCause = finding[\"root_cause\"];\n if (isObject(legacyRootCause)) {\n removeUnsupportedPersistedStrings(legacyRootCause, [\n \"summary\",\n \"code\",\n \"language\",\n ]);\n } else if (legacyRootCause !== null && typeof legacyRootCause !== \"string\") {\n delete finding[\"root_cause\"];\n }\n\n const validation = finding[\"validation\"];\n if (isObject(validation)) {\n removeUnsupportedPersistedStrings(\n validation,\n [\"method\", \"status\", \"summary\", \"disposition\", \"result\"].filter(\n (field) =>\n ![\"status\", \"disposition\", \"result\"].includes(field) ||\n validation[field] !== null,\n ),\n );\n }\n\n const attackPath = finding[\"attackPath\"];\n if (!isObject(attackPath)) return;\n removeUnsupportedPersistedStrings(attackPath, [\"summary\"]);\n for (const field of [\"dataFlow\", \"data_flow\", \"dataflow\", \"reachability\"]) {\n const detail = attackPath[field];\n if (!isObject(detail)) {\n if (!isNonEmptyString(detail)) delete attackPath[field];\n continue;\n }\n removeUnsupportedPersistedStrings(detail, [\n \"summary\",\n \"source\",\n \"sink\",\n \"outcome\",\n ...(field === \"reachability\" ? [\"attacker\", \"entrypoint\"] : []),\n ]);\n normalizePersistedStringLists(detail, [\n \"evidenceRefs\",\n \"evidence_refs\",\n \"transformations\",\n ...(field === \"reachability\" ? [\"preconditions\"] : []),\n ]);\n }\n for (const field of [\"impact\", \"likelihood\"]) {\n const detail = attackPath[field];\n if (isObject(detail)) {\n removeUnsupportedPersistedStrings(detail, [\"level\", \"rationale\", \"why\"]);\n } else if (\n detail !== undefined &&\n detail !== null &&\n !isNonEmptyString(detail)\n ) {\n delete attackPath[field];\n }\n }\n\n function normalizePersistedStringLists(\n section: JsonObject,\n fields: string[],\n ): void {\n for (const field of fields) {\n const value = section[field];\n if (isNonEmptyString(value)) {\n if (field !== \"evidence\") section[field] = [value];\n } else if (Array.isArray(value))\n section[field] = value.filter(isNonEmptyString);\n else delete section[field];\n }\n }\n\n function removeUnsupportedPersistedStrings(\n section: JsonObject,\n fields: string[],\n ): void {\n for (const field of fields) {\n if (!isNonEmptyString(section[field])) delete section[field];\n }\n }\n\n function isNonEmptyString(value: unknown): value is string {\n return typeof value === \"string\" && value.length > 0;\n }\n}\n"]}
|