@openai/codex-security 0.9.1 → 0.10.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 +37 -788
- package/_bundled_plugin/.codex-plugin/plugin.json +2 -0
- package/_bundled_plugin/.mcp.json +3 -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/access-advisory.md +1 -1
- 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/threat-model.md +1 -0
- package/_bundled_plugin/references/validate-scan-findings.md +3 -0
- package/_bundled_plugin/scripts/deep_scan_workbench.py +30 -12
- package/_bundled_plugin/scripts/dispatch_inventory_tool +7 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +47 -9
- package/_bundled_plugin/scripts/launch_codex_security_mcp +54 -16
- package/_bundled_plugin/scripts/launch_codex_security_mcp.cmd +2 -0
- 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 +257 -268
- 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 +291 -134
- package/_bundled_plugin/scripts/workbench_scan_start.py +208 -11
- 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_source_scopes.py +8 -0
- package/_bundled_plugin/scripts/workbench_target.py +486 -85
- package/_bundled_plugin/scripts/workbench_target_state.py +1108 -22
- package/_bundled_plugin/shared/workbench-history-repairs.json +64 -14
- package/_bundled_plugin/shared/workbench-migrations.json +66 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +4 -2
- package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +2 -2
- package/_bundled_plugin/skills/fix-finding/SKILL.md +1 -0
- package/_bundled_plugin/skills/publish-findings/SKILL.md +26 -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/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 +7 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +459 -157
- 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-diagnostics.d.ts +10 -0
- package/dist/classify-severity-diagnostics.d.ts.map +1 -0
- package/dist/classify-severity-diagnostics.js +57 -0
- package/dist/classify-severity-diagnostics.js.map +1 -0
- package/dist/classify-severity-records.d.ts +4 -0
- package/dist/classify-severity-records.d.ts.map +1 -1
- package/dist/classify-severity-records.js +35 -8
- package/dist/classify-severity-records.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 +8 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1860 -903
- 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-plan.d.ts.map +1 -1
- package/dist/component-plan.js +3 -3
- package/dist/component-plan.js.map +1 -1
- 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-aws.d.ts +6 -0
- package/dist/continuum-aws.d.ts.map +1 -0
- package/dist/continuum-aws.js +202 -0
- package/dist/continuum-aws.js.map +1 -0
- package/dist/continuum-collector.d.ts +44 -0
- package/dist/continuum-collector.d.ts.map +1 -0
- package/dist/continuum-collector.js +266 -0
- package/dist/continuum-collector.js.map +1 -0
- package/dist/continuum-findings.d.ts +31 -2
- package/dist/continuum-findings.d.ts.map +1 -1
- package/dist/continuum-findings.js +497 -59
- package/dist/continuum-findings.js.map +1 -1
- package/dist/contract.d.ts +1 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +3 -0
- package/dist/contract.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/crowdstrike-findings.d.ts +7 -0
- package/dist/crowdstrike-findings.d.ts.map +1 -0
- package/dist/crowdstrike-findings.js +210 -0
- package/dist/crowdstrike-findings.js.map +1 -0
- 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 +258 -59
- 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 +330 -1633
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +11 -2
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +56 -53
- 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 +6 -11
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +35 -177
- 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/host-protocol.d.ts +6 -0
- package/dist/host-protocol.d.ts.map +1 -1
- package/dist/host-protocol.js +11 -1
- package/dist/host-protocol.js.map +1 -1
- package/dist/host-records-protocol.d.ts +2 -0
- package/dist/host-records-protocol.d.ts.map +1 -1
- package/dist/host-records-protocol.js +4 -0
- package/dist/host-records-protocol.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 +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -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 +83 -39
- 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-schema.d.ts +2 -0
- package/dist/project-config-schema.d.ts.map +1 -1
- package/dist/project-config-schema.js +1 -0
- package/dist/project-config-schema.js.map +1 -1
- package/dist/project-config.d.ts +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +56 -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 +782 -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 +20 -2
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +26 -5
- 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/scan-settings.d.ts +1 -0
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +1 -0
- package/dist/scan-settings.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/severity-review.d.ts.map +1 -1
- package/dist/severity-review.js +1 -0
- package/dist/severity-review.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 +129 -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 +8 -1
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +103 -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 +7 -0
- package/dist/trusted-executable.d.ts.map +1 -1
- package/dist/trusted-executable.js +148 -37
- package/dist/trusted-executable.js.map +1 -1
- package/dist/value.js +3 -1
- package/dist/value.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/classify-severity-records.md +30 -0
- package/docs/cli.md +537 -124
- package/docs/findings-service.md +22 -9
- package/docs/hosted-remediation.md +13 -4
- package/docs/sdk.md +918 -0
- package/package.json +15 -6
- package/schemas/external-findings.schema.json +2 -1
- package/schemas/project-config.schema.json +5 -0
- 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
|
@@ -8,11 +8,11 @@ import os
|
|
|
8
8
|
import sqlite3
|
|
9
9
|
import sys
|
|
10
10
|
from collections.abc import Iterable, Iterator
|
|
11
|
+
from fractions import Fraction
|
|
11
12
|
from functools import cache
|
|
12
13
|
from itertools import chain
|
|
13
14
|
from pathlib import Path, PurePosixPath
|
|
14
15
|
from typing import Any, Callable
|
|
15
|
-
from urllib.parse import urlsplit
|
|
16
16
|
|
|
17
17
|
# Some plugin hosts launch Python with safe-path isolation enabled.
|
|
18
18
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
@@ -26,13 +26,39 @@ from finalize_scan_contract import (
|
|
|
26
26
|
from report_projection import SEVERITY_ORDER
|
|
27
27
|
from review_state import review_state
|
|
28
28
|
from workbench_constants import ARTIFACTS, FINDINGS_PAGE_MAX, PRIMARY_FINDING_LOCATION_SQL
|
|
29
|
-
from workbench_scan_start import scan_target_identity
|
|
30
29
|
from workbench_scan_usage import stored_scan_cost_fields
|
|
31
30
|
from workbench_source_scopes import public_scan_recipe
|
|
32
|
-
from workbench_target import
|
|
31
|
+
from workbench_target import (
|
|
32
|
+
require_remediation_target,
|
|
33
|
+
require_scan_target_identity,
|
|
34
|
+
verified_windows_checkout,
|
|
35
|
+
)
|
|
36
|
+
from workbench_target_state import (
|
|
37
|
+
RepositoryIdentityCache,
|
|
38
|
+
_timestamp_ns,
|
|
39
|
+
repository_relative_path,
|
|
40
|
+
same_repository_worktree,
|
|
41
|
+
scan_repository_generation,
|
|
42
|
+
)
|
|
33
43
|
from workbench_validation import timestamp_key
|
|
34
44
|
|
|
35
45
|
|
|
46
|
+
def reads_missing_history(args: argparse.Namespace, path: Path) -> bool:
|
|
47
|
+
"""Select an in-memory database only for history reads on a fresh profile."""
|
|
48
|
+
if args.command not in {"list-scans", "list-repositories", "list-global-findings"} and not (
|
|
49
|
+
args.command == "get-scan" and not (args.request_id or args.action_token)
|
|
50
|
+
):
|
|
51
|
+
return False
|
|
52
|
+
try:
|
|
53
|
+
path.lstat()
|
|
54
|
+
except FileNotFoundError:
|
|
55
|
+
return True
|
|
56
|
+
except OSError:
|
|
57
|
+
# The ordinary connection reports inaccessible storage.
|
|
58
|
+
pass
|
|
59
|
+
return False
|
|
60
|
+
|
|
61
|
+
|
|
36
62
|
def rename_scan(connection: sqlite3.Connection, scan: sqlite3.Row, name: str) -> dict[str, Any]:
|
|
37
63
|
name = name.strip()
|
|
38
64
|
if not name:
|
|
@@ -53,6 +79,26 @@ def scan_recipe(scan: sqlite3.Row) -> dict[str, Any]:
|
|
|
53
79
|
}
|
|
54
80
|
|
|
55
81
|
|
|
82
|
+
def expected_coverage_mode(scan: sqlite3.Row) -> str:
|
|
83
|
+
"""Return the coverage mode implied by the recorded scope, scan mode, and diff target kind."""
|
|
84
|
+
if scan["mode"] == "diff":
|
|
85
|
+
mode = {
|
|
86
|
+
"commit": "commit",
|
|
87
|
+
"range": "branch_diff",
|
|
88
|
+
"working_tree": "working_tree",
|
|
89
|
+
}.get(scan["diff_target_kind"])
|
|
90
|
+
if mode is None:
|
|
91
|
+
raise SystemExit("This migrated diff scan does not have a validated change set.")
|
|
92
|
+
return mode
|
|
93
|
+
if scan["scope"] != "." or (
|
|
94
|
+
"recipe_json" in scan.keys()
|
|
95
|
+
and scan["recipe_json"] is not None
|
|
96
|
+
and json.loads(scan["recipe_json"])["target"]["kind"] == "paths"
|
|
97
|
+
):
|
|
98
|
+
return "scoped_path"
|
|
99
|
+
return "deep_repository" if scan["mode"] == "deep" else "repository"
|
|
100
|
+
|
|
101
|
+
|
|
56
102
|
def preserve_sealed_completion(
|
|
57
103
|
binding: dict[str, Any], manifest: dict[str, Any] | None
|
|
58
104
|
) -> dict[str, Any]:
|
|
@@ -68,15 +114,34 @@ def preserve_sealed_completion(
|
|
|
68
114
|
return binding
|
|
69
115
|
|
|
70
116
|
|
|
117
|
+
def _windows_resume_checkout(scan: sqlite3.Row) -> Path:
|
|
118
|
+
from workbench_scan_start import scan_target_identity
|
|
119
|
+
|
|
120
|
+
replaced = "Cannot resume: the original checkout is missing or was replaced."
|
|
121
|
+
try:
|
|
122
|
+
repository = require_remediation_target(scan["target_path"])
|
|
123
|
+
except SystemExit as exc:
|
|
124
|
+
raise SystemExit(replaced) from exc
|
|
125
|
+
with verified_windows_checkout(scan, repository, replaced_message=replaced):
|
|
126
|
+
expected = (scan["target_revision"], scan["target_snapshot_digest"])
|
|
127
|
+
current = scan_target_identity(
|
|
128
|
+
repository, None, expected_digest=scan["target_snapshot_digest"]
|
|
129
|
+
)
|
|
130
|
+
if current[:2] != expected:
|
|
131
|
+
raise SystemExit("Cannot resume: the original checkout revision or contents changed.")
|
|
132
|
+
return repository
|
|
133
|
+
|
|
134
|
+
|
|
71
135
|
def cli_scan_resume(
|
|
72
136
|
wb: Any,
|
|
73
137
|
connection: sqlite3.Connection,
|
|
74
138
|
scan: sqlite3.Row,
|
|
75
139
|
workspace: sqlite3.Row,
|
|
76
140
|
) -> dict[str, Any]:
|
|
141
|
+
|
|
77
142
|
scan = scan_with_progress(connection, scan["id"])
|
|
78
|
-
if scan["mode"]
|
|
79
|
-
raise SystemExit("Resume requires a Deep Scan with a saved CLI launch recipe.")
|
|
143
|
+
if scan["mode"] not in {"standard", "deep"} or scan["recipe_json"] is None:
|
|
144
|
+
raise SystemExit("Resume requires a Standard or Deep Scan with a saved CLI launch recipe.")
|
|
80
145
|
if scan["status"] != "running" or scan["canceled_at"] is not None:
|
|
81
146
|
raise SystemExit(
|
|
82
147
|
"Resume requires a running scan; completed, failed, and canceled scans cannot resume."
|
|
@@ -97,21 +162,51 @@ def cli_scan_resume(
|
|
|
97
162
|
run["status"] not in {"running", "succeeded"} or run["cancel_requested"]
|
|
98
163
|
):
|
|
99
164
|
raise SystemExit("This Deep Scan has stopped and cannot resume.")
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
"Cannot
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
165
|
+
if os.name == "nt":
|
|
166
|
+
try:
|
|
167
|
+
repository = _windows_resume_checkout(scan)
|
|
168
|
+
except OSError as exc:
|
|
169
|
+
raise SystemExit(f"Cannot verify the original Windows checkout: {exc}") from exc
|
|
170
|
+
else:
|
|
171
|
+
from workbench_scan_start import scan_target_identity
|
|
172
|
+
|
|
173
|
+
try:
|
|
174
|
+
repository = require_scan_target_identity(scan)
|
|
175
|
+
except SystemExit as exc:
|
|
176
|
+
raise SystemExit(
|
|
177
|
+
"Cannot resume: the original checkout is missing or was replaced."
|
|
178
|
+
) from exc
|
|
179
|
+
if scan_target_identity(
|
|
180
|
+
repository, None, expected_digest=scan["target_snapshot_digest"]
|
|
181
|
+
) != (
|
|
182
|
+
scan["target_revision"],
|
|
183
|
+
scan["target_snapshot_digest"],
|
|
184
|
+
scan["target_device"],
|
|
185
|
+
scan["target_inode"],
|
|
186
|
+
):
|
|
187
|
+
raise SystemExit("Cannot resume: the original checkout revision or contents changed.")
|
|
113
188
|
recipe = wb.parse_scan_recipe(scan["recipe_json"], repository)
|
|
114
189
|
scan_dir = wb.require_canonical_scan_directory(Path(scan["scan_dir"]))
|
|
190
|
+
if os.name == "nt":
|
|
191
|
+
from windows_scan_local_files import DEEP_RESUME_DIRECTORY, deep_resume_output_identity
|
|
192
|
+
|
|
193
|
+
identity = scan["windows_resume_output_identity"]
|
|
194
|
+
if identity is not None:
|
|
195
|
+
try:
|
|
196
|
+
current = deep_resume_output_identity(scan_dir)
|
|
197
|
+
except OSError as exc:
|
|
198
|
+
raise SystemExit(
|
|
199
|
+
f"Cannot verify the registered Windows resume output: {exc}"
|
|
200
|
+
) from exc
|
|
201
|
+
if current != json.loads(identity):
|
|
202
|
+
raise SystemExit(
|
|
203
|
+
"Cannot resume: the original Windows output directory was replaced."
|
|
204
|
+
)
|
|
205
|
+
elif not any(entry != scan_dir / DEEP_RESUME_DIRECTORY for entry in scan_dir.iterdir()):
|
|
206
|
+
raise SystemExit(
|
|
207
|
+
"Cannot resume this empty Windows output because its original directory identity "
|
|
208
|
+
f"was not saved. Start a new scan with 'codex-security scans rerun {scan['id']}'."
|
|
209
|
+
)
|
|
115
210
|
result = {
|
|
116
211
|
"contract": wb.scan_contract(scan),
|
|
117
212
|
"lifecycle": json.loads(scan["lifecycle_json"]),
|
|
@@ -215,59 +310,61 @@ def _windows_path_key(value: str) -> str:
|
|
|
215
310
|
|
|
216
311
|
|
|
217
312
|
def _same_repository(
|
|
313
|
+
connection: sqlite3.Connection,
|
|
218
314
|
before: sqlite3.Row,
|
|
219
315
|
after: sqlite3.Row,
|
|
220
316
|
*,
|
|
221
|
-
|
|
317
|
+
identities: RepositoryIdentityCache | None = None,
|
|
222
318
|
) -> bool:
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
after_target = Path(after["target_path"])
|
|
227
|
-
if before_target.resolve() == after_target.resolve():
|
|
319
|
+
before_stored = scan_repository_generation(before)
|
|
320
|
+
after_stored = scan_repository_generation(after)
|
|
321
|
+
if before_stored is not None and before_stored == after_stored:
|
|
228
322
|
return True
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
323
|
+
if before["target_id"] and before["target_id"] == after["target_id"]:
|
|
324
|
+
return before_stored is None or after_stored is None
|
|
325
|
+
identities = identities or RepositoryIdentityCache(connection)
|
|
326
|
+
before_state = identities.for_row(before)
|
|
327
|
+
after_state = identities.for_row(after)
|
|
328
|
+
if (
|
|
329
|
+
not before_state.ownership_matches
|
|
330
|
+
or not after_state.ownership_matches
|
|
331
|
+
or before_stored is not None
|
|
332
|
+
and before_stored != before_state.live_identity
|
|
333
|
+
or after_stored is not None
|
|
334
|
+
and after_stored != after_state.live_identity
|
|
335
|
+
):
|
|
336
|
+
return False
|
|
232
337
|
if (
|
|
233
|
-
|
|
234
|
-
and
|
|
235
|
-
and Path(before_git_dir).resolve() == Path(after_git_dir).resolve()
|
|
338
|
+
before_state.resolved_path is not None
|
|
339
|
+
and before_state.resolved_path == after_state.resolved_path
|
|
236
340
|
):
|
|
341
|
+
return before_stored is None or after_stored is None
|
|
342
|
+
if before_state.repository is None or after_state.repository is None:
|
|
343
|
+
if same_repository_worktree(Path(before_state.target_path), Path(after_state.target_path)):
|
|
344
|
+
return True
|
|
345
|
+
before_relative = repository_relative_path(Path(before_state.target_path))
|
|
346
|
+
after_relative = repository_relative_path(Path(after_state.target_path))
|
|
347
|
+
after_origin = identities.origin(after_state)
|
|
348
|
+
return (
|
|
349
|
+
before_relative is not None
|
|
350
|
+
and before_relative == after_relative
|
|
351
|
+
and after_origin is not None
|
|
352
|
+
and identities.origin(before_state) == after_origin
|
|
353
|
+
)
|
|
354
|
+
before_identity = before_state.live_identity
|
|
355
|
+
after_identity = after_state.live_identity
|
|
356
|
+
if before_identity is not None and before_identity == after_identity:
|
|
237
357
|
return True
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
358
|
+
if before_identity is None or after_identity is None:
|
|
359
|
+
return False
|
|
360
|
+
after_origin = identities.origin(after_state)
|
|
361
|
+
return (
|
|
362
|
+
after_origin is not None
|
|
363
|
+
and identities.origin(before_state) == after_origin
|
|
364
|
+
and before_state.repository.relative_path == after_state.repository.relative_path
|
|
242
365
|
)
|
|
243
366
|
|
|
244
367
|
|
|
245
|
-
def _repository_origin(remote: str | None) -> tuple[str, str] | None:
|
|
246
|
-
if remote is None:
|
|
247
|
-
return None
|
|
248
|
-
if "://" in remote:
|
|
249
|
-
try:
|
|
250
|
-
parsed = urlsplit(remote)
|
|
251
|
-
port = parsed.port
|
|
252
|
-
except ValueError:
|
|
253
|
-
return None
|
|
254
|
-
if parsed.scheme not in {"https", "ssh"} or parsed.hostname is None:
|
|
255
|
-
return None
|
|
256
|
-
if parsed.query or parsed.fragment:
|
|
257
|
-
return None
|
|
258
|
-
host = parsed.hostname
|
|
259
|
-
if port is not None and port != {"https": 443, "ssh": 22}[parsed.scheme]:
|
|
260
|
-
host = f"{host}:{port}"
|
|
261
|
-
path = parsed.path
|
|
262
|
-
else:
|
|
263
|
-
authority, separator, path = remote.partition(":")
|
|
264
|
-
if not separator or "?" in path or "#" in path:
|
|
265
|
-
return None
|
|
266
|
-
host = authority.rsplit("@", 1)[-1]
|
|
267
|
-
path = path.strip("/").removesuffix(".git")
|
|
268
|
-
return (host.lower(), path) if host and path else None
|
|
269
|
-
|
|
270
|
-
|
|
271
368
|
SCAN_SUMMARY_COLUMNS = """
|
|
272
369
|
scans.*,
|
|
273
370
|
lifecycle.snapshot AS lifecycle_json,
|
|
@@ -363,30 +460,27 @@ def list_scans(
|
|
|
363
460
|
connection.create_function("codex_security_path_key", 1, _windows_path_key)
|
|
364
461
|
clauses: list[str] = []
|
|
365
462
|
values: list[Any] = []
|
|
463
|
+
worktree_order = ""
|
|
366
464
|
if args is not None and args.repository:
|
|
367
|
-
repository = Path(args.repository).expanduser().
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
placeholders = ", ".join("?" for _ in related_target_ids)
|
|
387
|
-
repository_clauses.append(f"scans.target_id IN ({placeholders})")
|
|
388
|
-
values.extend(related_target_ids)
|
|
389
|
-
clauses.append(f"({' OR '.join(repository_clauses)})")
|
|
465
|
+
repository = Path(args.repository).expanduser().absolute()
|
|
466
|
+
identities = RepositoryIdentityCache(connection)
|
|
467
|
+
repository = Path(identities.history_path(str(repository)))
|
|
468
|
+
clause, scope_values = identities.scope_for_path(str(repository)).sql(
|
|
469
|
+
supports_generation=identities.supports_generation
|
|
470
|
+
)
|
|
471
|
+
clauses.append(clause)
|
|
472
|
+
values.extend(scope_values)
|
|
473
|
+
if getattr(args, "prefer_worktree", False):
|
|
474
|
+
|
|
475
|
+
@cache
|
|
476
|
+
def in_worktree(target_path: str) -> bool:
|
|
477
|
+
try:
|
|
478
|
+
return repository.samefile(target_path)
|
|
479
|
+
except OSError:
|
|
480
|
+
return False
|
|
481
|
+
|
|
482
|
+
connection.create_function("in_worktree", 1, in_worktree)
|
|
483
|
+
worktree_order = "in_worktree(scans.target_path) DESC,"
|
|
390
484
|
if args is not None and args.scan_root:
|
|
391
485
|
scan_root = str(Path(args.scan_root).expanduser().resolve())
|
|
392
486
|
prefix = scan_root.rstrip(os.sep) + os.sep
|
|
@@ -433,7 +527,7 @@ def list_scans(
|
|
|
433
527
|
f"""
|
|
434
528
|
{SCAN_SUMMARY_QUERY}
|
|
435
529
|
{where}
|
|
436
|
-
ORDER BY
|
|
530
|
+
ORDER BY {worktree_order}
|
|
437
531
|
CASE WHEN scans.status = 'running' AND scans.canceled_at IS NULL THEN 0 ELSE 1 END,
|
|
438
532
|
MAX(julianday(upper(scans.updated_at)), julianday(upper(progress.updated_at))) DESC,
|
|
439
533
|
julianday(upper(scans.started_at)) DESC,
|
|
@@ -442,7 +536,11 @@ def list_scans(
|
|
|
442
536
|
""",
|
|
443
537
|
values,
|
|
444
538
|
).fetchall()
|
|
445
|
-
|
|
539
|
+
scans = [scan_summary(row) for row in rows[:limit]]
|
|
540
|
+
if worktree_order:
|
|
541
|
+
for scan in scans:
|
|
542
|
+
scan["inCurrentWorktree"] = in_worktree(scan["targetPath"])
|
|
543
|
+
result = {"scans": scans}
|
|
446
544
|
if limit is not None:
|
|
447
545
|
result.update(
|
|
448
546
|
{
|
|
@@ -454,6 +552,17 @@ def list_scans(
|
|
|
454
552
|
return result
|
|
455
553
|
|
|
456
554
|
|
|
555
|
+
def _scan_completion_order(scan: sqlite3.Row) -> tuple[int, int | Fraction, str]:
|
|
556
|
+
sequence = scan["completion_sequence"] if "completion_sequence" in scan.keys() else None
|
|
557
|
+
if sequence is not None:
|
|
558
|
+
return (1, sequence, scan["id"])
|
|
559
|
+
completed_at = scan["completed_at"] if "completed_at" in scan.keys() else None
|
|
560
|
+
timestamp = _timestamp_ns(completed_at)
|
|
561
|
+
if timestamp is None:
|
|
562
|
+
timestamp = _timestamp_ns(scan["started_at"])
|
|
563
|
+
return (0, timestamp if timestamp is not None else 0, scan["id"])
|
|
564
|
+
|
|
565
|
+
|
|
457
566
|
_FindingSites = dict[tuple[str, str | None, PurePosixPath, int, int], dict[str, Any] | None]
|
|
458
567
|
# Match the first location shown by compactFinding in finding-catalogue.ts.
|
|
459
568
|
_COMPARISON_LOCATION_RANK = {"root_control": 0, "expected_control": 1, "concrete_implementation": 1}
|
|
@@ -485,11 +594,14 @@ def _cross_mode_context(
|
|
|
485
594
|
findings: dict[str, list[dict[str, Any]]],
|
|
486
595
|
sites: dict[str, _FindingSites],
|
|
487
596
|
) -> dict[str, Any]:
|
|
488
|
-
#
|
|
597
|
+
# The saved generation includes the relative target path in a linked worktree.
|
|
598
|
+
same_target = before["target_id"] is not None and before["target_id"] == after["target_id"]
|
|
599
|
+
if not same_target:
|
|
600
|
+
generation = scan_repository_generation(before)
|
|
601
|
+
same_target = generation is not None and generation == scan_repository_generation(after)
|
|
489
602
|
if (
|
|
490
603
|
{before["mode"], after["mode"]} != {"standard", "deep"}
|
|
491
|
-
or
|
|
492
|
-
or before["target_id"] != after["target_id"]
|
|
604
|
+
or not same_target
|
|
493
605
|
or before["target_revision"] != after["target_revision"]
|
|
494
606
|
or before["target_snapshot_digest"] is None
|
|
495
607
|
or before["target_snapshot_digest"] != after["target_snapshot_digest"]
|
|
@@ -516,77 +628,85 @@ def list_unmatched_scan_pairs(
|
|
|
516
628
|
backfill_finding_details: Callable[[sqlite3.Connection, sqlite3.Row], None],
|
|
517
629
|
read_coverage: Callable[[sqlite3.Row], dict[str, Any]],
|
|
518
630
|
) -> dict[str, Any]:
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
631
|
+
requested_repository = Path(args.repository).expanduser().absolute()
|
|
632
|
+
repository = requested_repository.resolve()
|
|
633
|
+
identities = RepositoryIdentityCache(connection)
|
|
634
|
+
requested = identities.for_path(str(requested_repository))
|
|
635
|
+
if identities.supports_identity:
|
|
636
|
+
requested.require_owner()
|
|
637
|
+
clause, values = identities.scope_for_path(str(requested_repository)).sql(
|
|
638
|
+
supports_generation=identities.supports_generation
|
|
639
|
+
)
|
|
640
|
+
selected = connection.execute(
|
|
641
|
+
f"SELECT * FROM scans WHERE status = 'complete' AND {clause}",
|
|
642
|
+
values,
|
|
643
|
+
).fetchall()
|
|
644
|
+
|
|
645
|
+
focus_scan_id = getattr(args, "after_scan_id", None)
|
|
646
|
+
if focus_scan_id is None:
|
|
647
|
+
selected.sort(key=lambda scan: (timestamp_key(scan["started_at"]), scan["id"]))
|
|
648
|
+
else:
|
|
649
|
+
selected.sort(key=_scan_completion_order)
|
|
650
|
+
scan_ids = [scan["id"] for scan in selected]
|
|
538
651
|
|
|
539
652
|
available = []
|
|
540
|
-
for
|
|
653
|
+
for scan in selected:
|
|
541
654
|
try:
|
|
542
655
|
read_coverage(scan)
|
|
543
656
|
except SystemExit:
|
|
544
657
|
continue
|
|
545
|
-
available.append(
|
|
658
|
+
available.append(scan)
|
|
546
659
|
|
|
547
660
|
saved_pairs = {
|
|
548
|
-
(row["before_scan_id"], row["after_scan_id"])
|
|
661
|
+
frozenset((row["before_scan_id"], row["after_scan_id"]))
|
|
549
662
|
for row in connection.execute("SELECT before_scan_id, after_scan_id FROM scan_comparisons")
|
|
550
663
|
}
|
|
664
|
+
if focus_scan_id is not None and focus_scan_id not in scan_ids:
|
|
665
|
+
raise SystemExit("The scan to match is not a completed scan in this repository.")
|
|
551
666
|
batches = []
|
|
552
667
|
skipped = 0
|
|
553
668
|
matching_findings: dict[str, list[dict[str, Any]]] = {}
|
|
669
|
+
compact = os.environ.get("CODEX_SECURITY_MATCHING_PLAN_FORMAT") == "compact"
|
|
554
670
|
sites: dict[str, _FindingSites] = {}
|
|
555
671
|
known_links: list[sqlite3.Row] | None = None
|
|
556
|
-
for index,
|
|
672
|
+
for index, after in enumerate(available):
|
|
673
|
+
if focus_scan_id is not None and after["id"] != focus_scan_id:
|
|
674
|
+
continue
|
|
675
|
+
candidates = [
|
|
676
|
+
before
|
|
677
|
+
for before in available[:index]
|
|
678
|
+
if _same_repository(connection, before, after, identities=identities)
|
|
679
|
+
]
|
|
557
680
|
previous = [
|
|
558
681
|
before
|
|
559
|
-
for
|
|
560
|
-
if args.force or (before["id"], after["id"]) not in saved_pairs
|
|
682
|
+
for before in candidates
|
|
683
|
+
if args.force or frozenset((before["id"], after["id"])) not in saved_pairs
|
|
561
684
|
]
|
|
562
|
-
skipped +=
|
|
685
|
+
skipped += len(candidates) - len(previous)
|
|
563
686
|
if not previous:
|
|
564
687
|
continue
|
|
565
688
|
if known_links is None:
|
|
566
|
-
known_links = (
|
|
567
|
-
[]
|
|
568
|
-
if args.force
|
|
569
|
-
else _saved_finding_links(connection, {scan["id"] for scan in selected})
|
|
570
|
-
)
|
|
689
|
+
known_links = [] if args.force else _saved_finding_links(connection, set(scan_ids))
|
|
571
690
|
for scan in (*previous, after):
|
|
572
691
|
if scan["id"] not in matching_findings:
|
|
573
692
|
backfill_finding_details(connection, scan)
|
|
574
693
|
matching_findings[scan["id"]] = [
|
|
575
694
|
_matching_input(row) for row in _scan_findings(connection, scan["id"]).values()
|
|
576
695
|
]
|
|
577
|
-
known_groups =
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
696
|
+
known_groups = []
|
|
697
|
+
if known_links:
|
|
698
|
+
# Unavailable scans can still contribute a saved finding identity.
|
|
699
|
+
through_after = set(scan_ids[: scan_ids.index(after["id"]) + 1])
|
|
700
|
+
known_groups = _known_finding_groups(known_links, through_after)
|
|
581
701
|
batches.append(
|
|
582
702
|
{
|
|
583
|
-
"afterFindings": matching_findings[after["id"]],
|
|
584
703
|
"afterScanId": after["id"],
|
|
704
|
+
**({} if compact else {"afterFindings": matching_findings[after["id"]]}),
|
|
585
705
|
"beforeScans": [
|
|
586
706
|
{
|
|
587
707
|
**_cross_mode_context(before, after, matching_findings, sites),
|
|
588
|
-
"findings": matching_findings[before["id"]],
|
|
589
708
|
"scanId": before["id"],
|
|
709
|
+
**({} if compact else {"findings": matching_findings[before["id"]]}),
|
|
590
710
|
}
|
|
591
711
|
for before in previous
|
|
592
712
|
],
|
|
@@ -594,6 +714,7 @@ def list_unmatched_scan_pairs(
|
|
|
594
714
|
}
|
|
595
715
|
)
|
|
596
716
|
return {
|
|
717
|
+
**({"findingsByScanId": matching_findings} if compact else {}),
|
|
597
718
|
"batches": batches,
|
|
598
719
|
"repository": str(repository),
|
|
599
720
|
"scanCount": len(selected),
|
|
@@ -666,7 +787,7 @@ def compare_scans(
|
|
|
666
787
|
raise SystemExit("Select two different scans to compare.")
|
|
667
788
|
if before["status"] != "complete" or after["status"] != "complete":
|
|
668
789
|
raise SystemExit("Only completed scans can be compared.")
|
|
669
|
-
if not _same_repository(before, after):
|
|
790
|
+
if not _same_repository(connection, before, after):
|
|
670
791
|
raise SystemExit("Semantic scan comparisons require the same repository target.")
|
|
671
792
|
cached = connection.execute(
|
|
672
793
|
"SELECT result_json FROM scan_comparisons WHERE before_scan_id = ? AND after_scan_id = ?",
|
|
@@ -683,7 +804,7 @@ def compare_scans(
|
|
|
683
804
|
f"'codex-security scans compare {after['id']} {before['id']}'."
|
|
684
805
|
)
|
|
685
806
|
raise SystemExit(
|
|
686
|
-
"No saved matches for these scans. Run 'codex-security scans
|
|
807
|
+
"No saved matches for these scans. Run 'codex-security scans compare BEFORE AFTER' first."
|
|
687
808
|
)
|
|
688
809
|
if include_matching_inputs and backfill_finding_details is not None:
|
|
689
810
|
backfill_finding_details(connection, before)
|
|
@@ -801,14 +922,13 @@ def compare_scans(
|
|
|
801
922
|
for pair in related
|
|
802
923
|
]
|
|
803
924
|
if include_matching_inputs:
|
|
925
|
+
identities = RepositoryIdentityCache(connection)
|
|
804
926
|
after_key = (timestamp_key(after["started_at"]), after["id"])
|
|
805
927
|
known_scan_ids = {
|
|
806
928
|
scan["id"]
|
|
807
|
-
for scan in connection.execute(
|
|
808
|
-
"SELECT id, started_at, target_id, target_path FROM scans WHERE status = 'complete'"
|
|
809
|
-
)
|
|
929
|
+
for scan in connection.execute("SELECT * FROM scans WHERE status = 'complete'")
|
|
810
930
|
if (timestamp_key(scan["started_at"]), scan["id"]) <= after_key
|
|
811
|
-
and _same_repository(scan, after)
|
|
931
|
+
and _same_repository(connection, scan, after, identities=identities)
|
|
812
932
|
}
|
|
813
933
|
excluded_pairs = {(before["id"], after["id"]), (after["id"], before["id"])}
|
|
814
934
|
known_groups = _known_finding_groups(
|
|
@@ -847,7 +967,7 @@ def save_scan_comparison(
|
|
|
847
967
|
raise SystemExit("Select two different scans to compare.")
|
|
848
968
|
if before["status"] != "complete" or after["status"] != "complete":
|
|
849
969
|
raise SystemExit("Only completed scans can be compared.")
|
|
850
|
-
if not _same_repository(before, after):
|
|
970
|
+
if not _same_repository(connection, before, after):
|
|
851
971
|
raise SystemExit("Semantic scan comparisons require the same repository target.")
|
|
852
972
|
read_coverage(after)
|
|
853
973
|
allowed = {
|
|
@@ -928,8 +1048,10 @@ def save_scan_comparison(
|
|
|
928
1048
|
with connection:
|
|
929
1049
|
connection.execute("BEGIN IMMEDIATE")
|
|
930
1050
|
connection.execute(
|
|
931
|
-
"DELETE FROM scan_comparisons
|
|
932
|
-
|
|
1051
|
+
"DELETE FROM scan_comparisons "
|
|
1052
|
+
"WHERE (before_scan_id = ? AND after_scan_id = ?) "
|
|
1053
|
+
"OR (before_scan_id = ? AND after_scan_id = ?)",
|
|
1054
|
+
(before["id"], after["id"], after["id"], before["id"]),
|
|
933
1055
|
)
|
|
934
1056
|
connection.execute(
|
|
935
1057
|
"""
|
|
@@ -1091,6 +1213,41 @@ def finding_relations(
|
|
|
1091
1213
|
return result
|
|
1092
1214
|
|
|
1093
1215
|
|
|
1216
|
+
def finding_management_updated_at(connection: sqlite3.Connection, scan_id: str) -> str | None:
|
|
1217
|
+
return connection.execute(
|
|
1218
|
+
"""
|
|
1219
|
+
SELECT MAX(updated_at)
|
|
1220
|
+
FROM (
|
|
1221
|
+
SELECT triage.updated_at
|
|
1222
|
+
FROM finding_triage AS triage
|
|
1223
|
+
JOIN finding_occurrences AS occurrences ON occurrences.id = triage.occurrence_id
|
|
1224
|
+
WHERE occurrences.scan_id = ?
|
|
1225
|
+
UNION ALL
|
|
1226
|
+
SELECT remediation.updated_at
|
|
1227
|
+
FROM finding_remediation_attempts AS remediation
|
|
1228
|
+
JOIN finding_occurrences AS occurrences ON occurrences.id = remediation.occurrence_id
|
|
1229
|
+
WHERE occurrences.scan_id = ?
|
|
1230
|
+
)
|
|
1231
|
+
""",
|
|
1232
|
+
(scan_id, scan_id),
|
|
1233
|
+
).fetchone()[0]
|
|
1234
|
+
|
|
1235
|
+
|
|
1236
|
+
def finding_triage_result(connection: sqlite3.Connection, occurrence_id: str) -> dict[str, Any]:
|
|
1237
|
+
row = connection.execute(
|
|
1238
|
+
"SELECT status, close_reason, note, updated_at FROM finding_triage WHERE occurrence_id = ?",
|
|
1239
|
+
(occurrence_id,),
|
|
1240
|
+
).fetchone()
|
|
1241
|
+
if row is None:
|
|
1242
|
+
return {"status": "open"}
|
|
1243
|
+
return {
|
|
1244
|
+
"closeReason": row["close_reason"],
|
|
1245
|
+
"note": row["note"],
|
|
1246
|
+
"status": row["status"],
|
|
1247
|
+
"updatedAt": row["updated_at"],
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
|
|
1094
1251
|
def finding_matches(
|
|
1095
1252
|
connection: sqlite3.Connection, occurrence_id: str, scan_id: str, started_at: str
|
|
1096
1253
|
) -> tuple[list[dict[str, Any]], str, list[str]]:
|