@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
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { isDeepStrictEqual } from "node:util";
|
|
3
|
+
import { semgrepPlatformFindingBinding, semgrepPlatformReportScope, semgrepPlatformRepositoryReference, isSemgrepPlatformEvidence, semgrepReferenceMatches, } from "./semgrep-platform-findings.js";
|
|
4
|
+
import { gitPathToHttpPath, gitServiceHostname, isPublicGitHost, gitTransportBytes, hostedRepositoryMatches, normalizeHostedGitRepositoryUrl, } from "./hosted-git-repository.js";
|
|
3
5
|
import { checkRetainedTrivyProvider, checkTrivyReportProvider, matchTrivyCheckout, } from "./trivy-import.js";
|
|
4
6
|
import { readGitRemoteNames, readHostedGitRemotes, } from "./hosted-git-remotes.js";
|
|
5
7
|
import { CodexSecurityError } from "./errors.js";
|
|
6
|
-
import { externalImportDisposition, NoPublishableFindingsError, cloneImportPreview, snapshotImportOptions, snapshotNormalizedFindings, snapshotSourceRepositories, } from "./external-findings.js";
|
|
8
|
+
import { externalImportDisposition, NoPublishableFindingsError, cloneImportPreview, reportForJson, snapshotImportOptions, snapshotNormalizedFindings, snapshotSourceRepositories, } from "./external-findings.js";
|
|
7
9
|
import { cloudRepositoryUrlKey, requireSafeJsonInteger, repositoryUrlKey, validateExternalEvidence, } from "./external-import-contract.js";
|
|
8
|
-
import { localFindingRepositories, semgrepSarifRepositories, } from "./external-findings-read.js";
|
|
10
|
+
import { EXTERNAL_FINDINGS_PROVIDERS, EXTERNAL_FINDINGS_READERS, localFindingRepositories, semgrepSarifRepositories, LOCAL_ONLY_PROVIDERS, } from "./external-findings-read.js";
|
|
9
11
|
import { tenableReportFormat, tenableSourceRepository, } from "./tenable-findings.js";
|
|
12
|
+
import { crowdstrikeCheckout, crowdstrikeReportFormat, } from "./crowdstrike-findings.js";
|
|
10
13
|
import { guardianFindingRepository, guardianSelectionFormat, } from "./semgrep-guardian-findings.js";
|
|
11
14
|
import { hasGitMetadata, localGitProtectionRoots, commandGitProtectionRoots, } from "./local-git-metadata.js";
|
|
12
15
|
import { blackDuckReportRepositories, projectedBlackDuckRepositoryUrl, } from "./blackduck-findings.js";
|
|
@@ -16,16 +19,33 @@ import { continuumReportRepositories } from "./continuum-findings.js";
|
|
|
16
19
|
import { veracodeReportRepositories } from "./veracode-findings.js";
|
|
17
20
|
import { inspectorReportRepository } from "./inspector-findings.js";
|
|
18
21
|
import { declaredScannerRepositoryUrl } from "./scanner-repository-url.js";
|
|
22
|
+
import { armorCodeRepositoryUrl } from "./armorcode-findings.js";
|
|
19
23
|
import { sonarRepositoryUrls } from "./sonar-findings.js";
|
|
20
24
|
import { isRecord } from "./record.js";
|
|
21
25
|
import { dependabotRepository } from "./github-dependabot-findings.js";
|
|
22
26
|
import { retainedGitHubRepository } from "./github-findings.js";
|
|
23
27
|
import { snykRestImportRepository, snykRestCheckoutMatches, } from "./snyk-rest-findings.js";
|
|
24
|
-
import { bundledPluginRoot, canonicalConfigPath, canonicalizeModelSafePath,
|
|
28
|
+
import { bundledPluginRoot, canonicalConfigPath, canonicalizeModelSafePath, resolveInputPath, resolveParentTraversal, requireOutputOutsideRepositories, runWorkbench, workbenchEnvironment, } from "./runtime.js";
|
|
25
29
|
import { abortable, enclosingGitWorktreeRoot, gitOutput, normalizeRepository, } from "./targets.js";
|
|
26
30
|
function requireIdentity(value, field) {
|
|
27
31
|
if (typeof value !== "string" || !value.trim() || value.includes("\0"))
|
|
28
32
|
throw new CodexSecurityError(`${field} must be nonempty and contain no NUL characters.`);
|
|
33
|
+
if (!value.isWellFormed())
|
|
34
|
+
throw new CodexSecurityError(`${field} must contain valid Unicode.`);
|
|
35
|
+
}
|
|
36
|
+
function validateFindingIds(current) {
|
|
37
|
+
const identities = new Set();
|
|
38
|
+
for (const finding of current.findings) {
|
|
39
|
+
requireIdentity(finding.source_finding_id, "Source finding id");
|
|
40
|
+
if (identities.has(finding.source_finding_id))
|
|
41
|
+
throw new CodexSecurityError(`Duplicate source finding id ${JSON.stringify(finding.source_finding_id)}.`);
|
|
42
|
+
identities.add(finding.source_finding_id);
|
|
43
|
+
if (!isRecord(finding.evidence))
|
|
44
|
+
throw new CodexSecurityError("Imported evidence must be an object.");
|
|
45
|
+
if (typeof finding.evidence.title !== "string" ||
|
|
46
|
+
typeof finding.evidence.severity !== "string")
|
|
47
|
+
throw new CodexSecurityError("Imported evidence requires a title and severity.");
|
|
48
|
+
}
|
|
29
49
|
}
|
|
30
50
|
function checkStoredNumber(value) {
|
|
31
51
|
if (!Number.isFinite(value))
|
|
@@ -289,17 +309,17 @@ export async function configuredFetchRemotes(repository, provider, protectedRoot
|
|
|
289
309
|
}
|
|
290
310
|
return remotes;
|
|
291
311
|
}
|
|
312
|
+
async function hostedCheckoutRemotes(repository, protectedRoots, environment, signal) {
|
|
313
|
+
if (!(await hasGitMetadata(repository, signal)))
|
|
314
|
+
return undefined;
|
|
315
|
+
return readHostedGitRemotes(repository, [...protectedRoots, await canonicalConfigPath(process.cwd())], environment, signal);
|
|
316
|
+
}
|
|
292
317
|
async function requireMatchingRepository(repository, provider, sources, strictSources, hostedSources, platformFor, snyk, protectedRoots, environment, signal, possibleSshHost, fetchRemotes, isCheckmarxSource) {
|
|
293
318
|
if (!snyk && sources.length === 0 && hostedSources.length === 0)
|
|
294
319
|
return false;
|
|
295
320
|
let allSourcesMatched = true;
|
|
296
321
|
if (snyk || hostedSources.length) {
|
|
297
|
-
|
|
298
|
-
return false;
|
|
299
|
-
const remotes = await readHostedGitRemotes(repository, [
|
|
300
|
-
...protectedRoots,
|
|
301
|
-
await abortable(() => canonicalConfigPath(process.cwd()), signal),
|
|
302
|
-
], environment, signal);
|
|
322
|
+
const remotes = await hostedCheckoutRemotes(repository, protectedRoots, environment, signal);
|
|
303
323
|
if (snyk) {
|
|
304
324
|
if (remotes &&
|
|
305
325
|
!remotes.some((remote) => snykRestCheckoutMatches(snyk, remote)))
|
|
@@ -356,22 +376,32 @@ async function requireMatchingRepository(repository, provider, sources, strictSo
|
|
|
356
376
|
export function sonarCheckoutMatchesSource(repository, url, protectedRoots, environment, signal) {
|
|
357
377
|
return requireMatchingRepository(repository, "sonar", [{ url }], new Map(), [], () => "sonar", undefined, [...protectedRoots], environment, signal);
|
|
358
378
|
}
|
|
379
|
+
/** @internal Resolve and protect the local checkout and workbench state directory. */
|
|
359
380
|
async function localContext(selectedRepository, dependencies, mode = "import") {
|
|
360
381
|
dependencies.signal?.throwIfAborted();
|
|
361
382
|
const environment = workbenchEnvironment(dependencies.environment ?? process.env);
|
|
362
|
-
const
|
|
383
|
+
const requested = resolveInputPath(selectedRepository, process.cwd(), environment);
|
|
384
|
+
const path = await abortable(() => resolveParentTraversal(requested), dependencies.signal);
|
|
363
385
|
const repository = mode === "read"
|
|
364
386
|
? await abortable(() => canonicalConfigPath(path), dependencies.signal)
|
|
365
387
|
: await normalizeRepository(path, dependencies.signal);
|
|
388
|
+
const lexicalPath = resolve(requested);
|
|
389
|
+
const lexicalRepository = lexicalPath === resolve(path)
|
|
390
|
+
? repository
|
|
391
|
+
: await abortable(() => canonicalConfigPath(lexicalPath), dependencies.signal);
|
|
366
392
|
const protectedRoot = [
|
|
367
393
|
...new Set([
|
|
368
394
|
repository,
|
|
369
|
-
...(
|
|
395
|
+
...(mode === "read" ? [lexicalRepository] : []),
|
|
396
|
+
...(await abortable(() => commandGitProtectionRoots(path, environment, dependencies.signal, {
|
|
397
|
+
requestedPaths: [lexicalPath, lexicalRepository],
|
|
398
|
+
}), dependencies.signal)),
|
|
370
399
|
]),
|
|
371
400
|
];
|
|
372
401
|
requireOutputOutsideRepositories(protectedRoot, await abortable(() => canonicalizeModelSafePath(environment.CODEX_SECURITY_STATE_DIR), dependencies.signal), "runtime");
|
|
373
402
|
return {
|
|
374
403
|
repository,
|
|
404
|
+
selectedPath: path,
|
|
375
405
|
options: {
|
|
376
406
|
pluginRoot: await abortable(() => bundledPluginRoot(), dependencies.signal),
|
|
377
407
|
environment,
|
|
@@ -383,8 +413,63 @@ async function localContext(selectedRepository, dependencies, mode = "import") {
|
|
|
383
413
|
}
|
|
384
414
|
/** Prepare scanner evidence without writing state or performing a security assessment. */
|
|
385
415
|
export async function prepareNormalizedLocalImport(input, options, dependencies = {}) {
|
|
386
|
-
dependencies
|
|
387
|
-
|
|
416
|
+
const { signal } = dependencies;
|
|
417
|
+
signal?.throwIfAborted();
|
|
418
|
+
const settings = snapshotImportOptions(options);
|
|
419
|
+
const reader = EXTERNAL_FINDINGS_READERS.find((name) => name === settings.provider);
|
|
420
|
+
if (reader)
|
|
421
|
+
return prepareLocalImport(input, { ...settings, provider: EXTERNAL_FINDINGS_PROVIDERS[reader] }, dependencies);
|
|
422
|
+
const references = snapshotSourceRepositories(dependencies.sourceRepositories);
|
|
423
|
+
requireIdentity(settings.provider, "Provider");
|
|
424
|
+
requireIdentity(settings.sourceKey, "Source key");
|
|
425
|
+
const current = snapshotNormalizedFindings(input, checkStoredNumber);
|
|
426
|
+
validateFindingIds(current);
|
|
427
|
+
if (current.report !== undefined && !isRecord(current.report))
|
|
428
|
+
throw new CodexSecurityError("Report metadata must be an object.");
|
|
429
|
+
if (current.read !== current.findings.length + current.excluded.length)
|
|
430
|
+
throw new CodexSecurityError("Every source record must be accounted for by a finding or exclusion.");
|
|
431
|
+
const positions = new Set();
|
|
432
|
+
for (const { position, source_finding_id, reason } of current.excluded) {
|
|
433
|
+
if (!Number.isSafeInteger(position) ||
|
|
434
|
+
position < 1 ||
|
|
435
|
+
position > current.read ||
|
|
436
|
+
positions.has(position))
|
|
437
|
+
throw new CodexSecurityError("An excluded position must be unique and within the reported record count.");
|
|
438
|
+
positions.add(position);
|
|
439
|
+
requireIdentity(reason, "Exclusion reason");
|
|
440
|
+
if (source_finding_id !== null)
|
|
441
|
+
requireIdentity(source_finding_id, "Excluded source finding id");
|
|
442
|
+
}
|
|
443
|
+
const platform = references.find((ref) => ref.platform)?.platform;
|
|
444
|
+
const urls = new Set(references.map(({ url }) => url));
|
|
445
|
+
if (settings.sourceRepositoryUrl !== undefined)
|
|
446
|
+
urls.add(settings.sourceRepositoryUrl);
|
|
447
|
+
for (const finding of current.findings) {
|
|
448
|
+
finding.evidence = validateExternalEvidence(finding.evidence, "local");
|
|
449
|
+
const repository = finding.evidence.details?.repository;
|
|
450
|
+
if (repository)
|
|
451
|
+
urls.add(repository.url);
|
|
452
|
+
}
|
|
453
|
+
const sources = Array.from(urls, (url) => ({
|
|
454
|
+
url: declaredScannerRepositoryUrl(url, settings.provider, "local"),
|
|
455
|
+
platform,
|
|
456
|
+
}));
|
|
457
|
+
const [source] = sources;
|
|
458
|
+
const context = await localContext(settings.repository, dependencies);
|
|
459
|
+
let matched = false;
|
|
460
|
+
if (source) {
|
|
461
|
+
if (references.some((ref) => ref.platform && ref.platform !== platform) ||
|
|
462
|
+
sources.some(({ url }) => !hostedRepositoryMatches(source, url)))
|
|
463
|
+
throw new CodexSecurityError("The findings declare conflicting source repositories.");
|
|
464
|
+
const remotes = await hostedCheckoutRemotes(context.repository, context.options.protectedRoot, context.options.environment, signal);
|
|
465
|
+
matched =
|
|
466
|
+
remotes?.some((remote) => hostedRepositoryMatches(source, remote)) ??
|
|
467
|
+
false;
|
|
468
|
+
if (!matched &&
|
|
469
|
+
remotes?.some((remote) => /^https?:\/\//iu.test(normalizeHostedGitRepositoryUrl(remote, undefined, platform !== undefined))))
|
|
470
|
+
throw new CodexSecurityError(`Imported repository ${JSON.stringify(source.url)} does not match a configured fetch remote of ${context.repository}.`);
|
|
471
|
+
}
|
|
472
|
+
return preparedLocalStorage(current, settings, context, dependencies, matched, { sourceRepositories: sources });
|
|
388
473
|
}
|
|
389
474
|
// A scanner can repeat the same repository reference for every finding in a run.
|
|
390
475
|
export function distinctSourceRepositories(sources) {
|
|
@@ -399,35 +484,27 @@ export function distinctSourceRepositories(sources) {
|
|
|
399
484
|
});
|
|
400
485
|
}
|
|
401
486
|
/** @internal Prepare evidence using settings captured by either local import entrypoint. */
|
|
402
|
-
export async function prepareLocalImport(input, options, dependencies, readerSources = distinctSourceRepositories(snapshotSourceRepositories(dependencies.sourceRepositories)), parsedInput
|
|
487
|
+
export async function prepareLocalImport(input, options, dependencies, readerSources = distinctSourceRepositories(snapshotSourceRepositories(dependencies.sourceRepositories)), parsedInput, fetchRemotes) {
|
|
403
488
|
requireIdentity(options.sourceKey, "Source key");
|
|
404
|
-
const parsedSources = distinctSourceRepositories(parsedInput);
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
489
|
+
const parsedSources = distinctSourceRepositories(parsedInput ?? []);
|
|
490
|
+
// File readers interpret their source option while parsing. For normalized
|
|
491
|
+
// input the caller declares one repository for the whole selection.
|
|
492
|
+
const normalizedSource = parsedInput === undefined && options.sourceRepositoryUrl !== undefined
|
|
493
|
+
? declaredScannerRepositoryUrl(options.sourceRepositoryUrl, options.provider, "local")
|
|
494
|
+
: undefined;
|
|
495
|
+
const current = snapshotNormalizedFindings(input, checkStoredNumber, "local", options.provider);
|
|
496
|
+
for (const [provider, format] of [
|
|
497
|
+
["tenable", tenableReportFormat],
|
|
498
|
+
["crowdstrike", crowdstrikeReportFormat],
|
|
499
|
+
])
|
|
500
|
+
if (options.provider !== provider &&
|
|
501
|
+
(current.report?.["format"] === format ||
|
|
502
|
+
current.findings.some((row) => row.evidence?.source_data?.["format"] === format)))
|
|
503
|
+
throw new CodexSecurityError(`Retained ${LOCAL_ONLY_PROVIDERS[provider]} evidence requires the ${provider} provider.`);
|
|
410
504
|
checkTrivyReportProvider(options.provider, current.report);
|
|
411
|
-
// The JSON snapshot omits inherited or non-enumerable SDK reader properties.
|
|
412
|
-
if (!("snykRestContext" in current) && "snykRestContext" in input)
|
|
413
|
-
current.snykRestContext = structuredClone(input.snykRestContext);
|
|
414
|
-
if (options.provider === "snyk" || current.snykRestContext !== undefined) {
|
|
415
|
-
for (const key of [
|
|
416
|
-
"sourceRepositoryUrl",
|
|
417
|
-
"sourceRepositoryPlatform",
|
|
418
|
-
])
|
|
419
|
-
if (key in input && !(key in current))
|
|
420
|
-
Object.assign(current, { [key]: structuredClone(input[key]) });
|
|
421
|
-
}
|
|
422
505
|
let dependabotSource;
|
|
423
|
-
|
|
506
|
+
validateFindingIds(current);
|
|
424
507
|
for (const finding of current.findings) {
|
|
425
|
-
requireIdentity(finding.source_finding_id, "Source finding id");
|
|
426
|
-
if (identities.has(finding.source_finding_id))
|
|
427
|
-
throw new CodexSecurityError(`Duplicate source finding id ${JSON.stringify(finding.source_finding_id)}.`);
|
|
428
|
-
identities.add(finding.source_finding_id);
|
|
429
|
-
if (!isRecord(finding.evidence))
|
|
430
|
-
throw new CodexSecurityError("Imported evidence must be an object.");
|
|
431
508
|
checkRetainedTrivyProvider(options.provider, finding, "local");
|
|
432
509
|
if (options.provider !== "github")
|
|
433
510
|
continue;
|
|
@@ -443,15 +520,27 @@ export async function prepareLocalImport(input, options, dependencies, readerSou
|
|
|
443
520
|
dependabotSource = native;
|
|
444
521
|
}
|
|
445
522
|
const context = await localContext(options.repository, dependencies);
|
|
523
|
+
// Neither report records the checkout, so check the operator's URL against its remotes.
|
|
524
|
+
const requireFetchRemote = async (source, provider) => {
|
|
525
|
+
const remotes = await hostedCheckoutRemotes(context.repository, context.options.protectedRoot, context.options.environment, dependencies.signal);
|
|
526
|
+
if (!remotes?.some((remote) => hostedRepositoryMatches(source, remote)))
|
|
527
|
+
throw new CodexSecurityError(`${LOCAL_ONLY_PROVIDERS[provider]}'s source repository must match a configured Git fetch remote of the selected checkout.`);
|
|
528
|
+
};
|
|
446
529
|
if (options.provider === "tenable") {
|
|
447
530
|
const source = tenableSourceRepository(current, options.sourceRepositoryUrl, [...readerSources, ...parsedSources]);
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
531
|
+
await requireFetchRemote(source, "tenable");
|
|
532
|
+
return preparedLocalStorage(current, options, context, dependencies, true, {
|
|
533
|
+
sourceRepositories: [source],
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
if (options.provider === "crowdstrike") {
|
|
537
|
+
const source = await crowdstrikeCheckout(current, options.sourceRepositoryUrl, [...readerSources, ...parsedSources], context.repository);
|
|
538
|
+
// FCS scans plain directories; only a Git checkout has remotes to compare.
|
|
539
|
+
const bound = source !== undefined &&
|
|
540
|
+
(await hasGitMetadata(context.repository, dependencies.signal));
|
|
541
|
+
if (bound)
|
|
542
|
+
await requireFetchRemote(source, "crowdstrike");
|
|
543
|
+
return preparedLocalStorage(current, options, context, dependencies, bound, source ? { sourceRepositories: [source] } : {});
|
|
455
544
|
}
|
|
456
545
|
const { repository, options: workbenchOptions } = context;
|
|
457
546
|
const sources = new Map();
|
|
@@ -462,7 +551,7 @@ export async function prepareLocalImport(input, options, dependencies, readerSou
|
|
|
462
551
|
projectedBlackDuckRepositoryUrl(finding, "local")) ||
|
|
463
552
|
checkmarx.projections.has(finding));
|
|
464
553
|
const mixed = projected.length > 0 && readerSources.length > 0;
|
|
465
|
-
const nativeSources = new Map((mixed ? current.findings : projected)
|
|
554
|
+
const nativeSources = new Map((mixed || normalizedSource ? current.findings : projected)
|
|
466
555
|
.filter(({ evidence }) => options.provider !== "endor" ||
|
|
467
556
|
isRecord(evidence.source_data?.["runContext"]))
|
|
468
557
|
.map((finding) => [
|
|
@@ -523,7 +612,6 @@ export async function prepareLocalImport(input, options, dependencies, readerSou
|
|
|
523
612
|
if (semgrepPlatformRepositoryUrl)
|
|
524
613
|
addSemgrepSource(semgrepPlatformRepositoryUrl);
|
|
525
614
|
const known = new Set(parsedSources.map(({ url }) => url));
|
|
526
|
-
const legacyWitnesses = semgrepLegacyRepositoryWitnesses(current.findings, options.provider, readerSources);
|
|
527
615
|
const hasPlatformEvidence = options.provider === "semgrep" &&
|
|
528
616
|
(semgrepReportScope !== undefined ||
|
|
529
617
|
current.findings.some((row) => isSemgrepPlatformEvidence(row, options.provider)));
|
|
@@ -532,8 +620,14 @@ export async function prepareLocalImport(input, options, dependencies, readerSou
|
|
|
532
620
|
for (const finding of current.findings) {
|
|
533
621
|
const retained = bound.get(finding.source_finding_id) ?? checkmarxRepository(finding);
|
|
534
622
|
const native = nativeSources.get(finding) ?? [];
|
|
535
|
-
const sarif = hasPlatformEvidence
|
|
536
|
-
|
|
623
|
+
const sarif = hasPlatformEvidence ||
|
|
624
|
+
(normalizedSource && options.provider === "semgrep")
|
|
625
|
+
? semgrepSarifRepositories(finding)
|
|
626
|
+
: [];
|
|
627
|
+
if (normalizedSource)
|
|
628
|
+
for (const source of sarif)
|
|
629
|
+
known.add(source.url);
|
|
630
|
+
const semgrep = semgrepPlatformFindingBinding(finding, options.provider, readerSources, semgrepReportScope, [retained, ...native, ...sarif]);
|
|
537
631
|
if (semgrep) {
|
|
538
632
|
addSemgrepSource(semgrep.url);
|
|
539
633
|
if (semgrep.sourceData)
|
|
@@ -542,6 +636,11 @@ export async function prepareLocalImport(input, options, dependencies, readerSou
|
|
|
542
636
|
Object.assign(finding.evidence, semgrep.migration);
|
|
543
637
|
}
|
|
544
638
|
const { evidence } = finding;
|
|
639
|
+
if (options.provider === "armorcode") {
|
|
640
|
+
const nativeUrl = armorCodeRepositoryUrl(evidence.source_data, "local");
|
|
641
|
+
if (nativeUrl)
|
|
642
|
+
sources.set(nativeUrl, { url: nativeUrl });
|
|
643
|
+
}
|
|
545
644
|
if (options.provider === "github") {
|
|
546
645
|
const source = retainedGitHubRepository(finding, (url) => identify(url).key);
|
|
547
646
|
if (source)
|
|
@@ -712,6 +811,14 @@ export async function prepareLocalImport(input, options, dependencies, readerSou
|
|
|
712
811
|
(reportUrl &&
|
|
713
812
|
hosted.some((source) => !semgrepReferenceMatches(source, reportUrl))))
|
|
714
813
|
throw new Error("The retained Checkmarx report repository does not match the finding repository.");
|
|
814
|
+
if (options.provider === "armorcode") {
|
|
815
|
+
if (options.sourceRepositoryUrl !== undefined) {
|
|
816
|
+
const url = declaredScannerRepositoryUrl(options.sourceRepositoryUrl, "ArmorCode", "local");
|
|
817
|
+
sources.set(url, { url });
|
|
818
|
+
}
|
|
819
|
+
if (!sameRepositories(sources.keys()))
|
|
820
|
+
throw new CodexSecurityError("ArmorCode findings must belong to a single source repository.");
|
|
821
|
+
}
|
|
715
822
|
const sonarSources = sonarRepositoryUrls(options.provider, current.findings, current.report, "local");
|
|
716
823
|
const manualSource = options.provider === "sonar" && options.sourceRepositoryUrl
|
|
717
824
|
? declaredScannerRepositoryUrl(options.sourceRepositoryUrl, "Sonar", "local")
|
|
@@ -757,6 +864,13 @@ export async function prepareLocalImport(input, options, dependencies, readerSou
|
|
|
757
864
|
if (!sameRepositories(sources.keys()))
|
|
758
865
|
throw new CodexSecurityError("The normalized repository does not match the Snyk reader's repository.");
|
|
759
866
|
}
|
|
867
|
+
if (normalizedSource && !snyk) {
|
|
868
|
+
if (!sameRepositories([normalizedSource, ...sources.keys(), ...known]) ||
|
|
869
|
+
hosted.some((source) => !semgrepReferenceMatches(source, normalizedSource)))
|
|
870
|
+
throw new CodexSecurityError("The declared repository does not match the normalized finding source.");
|
|
871
|
+
if (!hosted.length && !sources.size)
|
|
872
|
+
sources.set(normalizedSource, { url: normalizedSource });
|
|
873
|
+
}
|
|
760
874
|
const ordinarySources = [...sources.values()];
|
|
761
875
|
// A reader can identify the VCS for both a hosted project and an ordinary row.
|
|
762
876
|
const loosePlatformFor = localRepositoryPlatform(options.provider, [...ordinarySources, ...hostedReferences], false);
|
|
@@ -766,19 +880,67 @@ export async function prepareLocalImport(input, options, dependencies, readerSou
|
|
|
766
880
|
: await requireMatchingRepository(repository, options.provider, ordinarySources, strictSources, hosted, (source, bound) => bound ? platformFor(source) : loosePlatformFor(source), snyk, workbenchOptions.protectedRoot, workbenchOptions.environment, dependencies.signal, selected?.protocol === "https:" ? selected.hostname : undefined, fetchRemotes, checkmarx.projections.size
|
|
767
881
|
? (url) => checkmarxKeys.has(identify(url).key)
|
|
768
882
|
: undefined);
|
|
769
|
-
|
|
883
|
+
let storedSources = [...references, ...ordinarySources, ...hosted];
|
|
884
|
+
const [project] = hosted;
|
|
885
|
+
if (options.provider === "semgrep" &&
|
|
886
|
+
!hasOrdinaryRows &&
|
|
887
|
+
!ordinarySources.length &&
|
|
888
|
+
hosted.length === 1 &&
|
|
889
|
+
project &&
|
|
890
|
+
references.every(({ url }) => url === project.url)) {
|
|
891
|
+
// A typed hint and a bare URL can be two witnesses for the same native
|
|
892
|
+
// project. Keep the hint if any stored occurrence needs it to verify its scope.
|
|
893
|
+
storedSources = [project];
|
|
894
|
+
const native = semgrepPlatformRepositoryReference(project.url, []);
|
|
895
|
+
if (native.platform !== project.platform) {
|
|
896
|
+
try {
|
|
897
|
+
if (current.findings.every((finding) => {
|
|
898
|
+
const binding = semgrepPlatformFindingBinding(finding, "semgrep", [
|
|
899
|
+
native,
|
|
900
|
+
]);
|
|
901
|
+
return (binding?.url === native.url &&
|
|
902
|
+
!binding.migration &&
|
|
903
|
+
isDeepStrictEqual(binding.sourceData, finding.evidence.source_data));
|
|
904
|
+
}))
|
|
905
|
+
storedSources = [native];
|
|
906
|
+
}
|
|
907
|
+
catch {
|
|
908
|
+
// A private SCM alias or SSH mapping can require the reader's platform.
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
if (snyk)
|
|
913
|
+
storedSources.push({
|
|
914
|
+
url: snyk.url,
|
|
915
|
+
platform: snyk.platform === "github"
|
|
916
|
+
? "github"
|
|
917
|
+
: snyk.gitlab
|
|
918
|
+
? "gitlab"
|
|
919
|
+
: undefined,
|
|
920
|
+
});
|
|
921
|
+
return preparedLocalStorage(current, options, context, dependencies, matchesRepositoryRemote, {
|
|
922
|
+
sourceRepositories: distinctSourceRepositories(storedSources),
|
|
923
|
+
inspectorProjectMap: options.inspectorProjectMap
|
|
924
|
+
? [...options.inspectorProjectMap]
|
|
925
|
+
: undefined,
|
|
926
|
+
});
|
|
770
927
|
}
|
|
771
|
-
|
|
928
|
+
/** @internal Prepare the transactional write after validating the report and repository. */
|
|
929
|
+
function preparedLocalStorage(current, { provider, sourceKey }, { repository, options: workbenchOptions, }, dependencies, matchesRepositoryRemote, provenance) {
|
|
772
930
|
dependencies.signal?.throwIfAborted();
|
|
773
931
|
const preview = {
|
|
774
932
|
...cloneImportPreview(current),
|
|
775
933
|
repository,
|
|
776
|
-
source: { provider
|
|
934
|
+
source: { provider, source_key: sourceKey },
|
|
777
935
|
};
|
|
778
936
|
const payload = JSON.stringify({
|
|
779
937
|
repository,
|
|
780
|
-
provider
|
|
781
|
-
sourceKey
|
|
938
|
+
provider,
|
|
939
|
+
sourceKey,
|
|
940
|
+
read: current.read,
|
|
941
|
+
excluded: current.excluded,
|
|
942
|
+
report: reportForJson(current.report),
|
|
943
|
+
provenance,
|
|
782
944
|
findings: current.findings.map(({ source_finding_id, evidence }) => ({
|
|
783
945
|
source_finding_id,
|
|
784
946
|
evidence,
|
|
@@ -821,6 +983,7 @@ function preparedLocalStorage(current, options, { repository, options: workbench
|
|
|
821
983
|
}, dependencies.signal);
|
|
822
984
|
return {
|
|
823
985
|
...summary,
|
|
986
|
+
importId: result["importId"],
|
|
824
987
|
findings: result["findings"],
|
|
825
988
|
counts: result["counts"],
|
|
826
989
|
};
|
|
@@ -829,14 +992,50 @@ function preparedLocalStorage(current, options, { repository, options: workbench
|
|
|
829
992
|
}
|
|
830
993
|
/** Read imported source records, including evidence that has not been assessed by Codex. */
|
|
831
994
|
export async function listLocalExternalFindings(selection, dependencies = {}) {
|
|
995
|
+
return (await readLocalExternalFindings(selection, dependencies)).findings;
|
|
996
|
+
}
|
|
997
|
+
export async function readLocalExternalFindings(selection, dependencies) {
|
|
832
998
|
dependencies.signal?.throwIfAborted();
|
|
833
999
|
if (selection.id !== undefined)
|
|
834
1000
|
requireIdentity(selection.id, "Finding id");
|
|
835
|
-
const {
|
|
1001
|
+
const { selectedPath, result } = await runLocalFindingWorkbench(selection.repository, "read-external-findings", { id: selection.id }, dependencies);
|
|
1002
|
+
return {
|
|
1003
|
+
repository: selectedPath,
|
|
1004
|
+
findings: result["findings"],
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
/** Read the precise versions selected by the caller or captured by an earlier import. */
|
|
1008
|
+
export async function selectLocalExternalFindings(selection, dependencies = {}) {
|
|
1009
|
+
const { repository, importId, findings } = selection;
|
|
1010
|
+
if ((importId === undefined) === (findings === undefined))
|
|
1011
|
+
throw new CodexSecurityError("Select one import ID or a list of versioned findings.");
|
|
1012
|
+
const { result } = await runLocalFindingWorkbench(repository, "read-external-findings", importId !== undefined
|
|
1013
|
+
? { importId, ifCurrent: selection.ifCurrent }
|
|
1014
|
+
: { findings: findings.map(({ id, version }) => ({ id, version })) }, dependencies);
|
|
1015
|
+
return result;
|
|
1016
|
+
}
|
|
1017
|
+
/** List this checkout's nonempty imports, most recent first. */
|
|
1018
|
+
export async function listLocalExternalImports({ repository }, dependencies = {}) {
|
|
1019
|
+
const { result } = await runLocalFindingWorkbench(repository, "list-external-imports", {}, dependencies);
|
|
1020
|
+
return result["imports"];
|
|
1021
|
+
}
|
|
1022
|
+
/** @internal Attach Cloud acknowledgements to the versions that were submitted. */
|
|
1023
|
+
export async function recordExternalFindingPublications(input, dependencies = {}) {
|
|
1024
|
+
const { repository, ...receipt } = input;
|
|
1025
|
+
await runLocalFindingWorkbench(repository, "record-external-finding-publications", receipt, dependencies);
|
|
1026
|
+
}
|
|
1027
|
+
/** Read the destination and receipt for each acknowledged finding version. */
|
|
1028
|
+
export async function listLocalFindingPublications({ repository, id }, dependencies = {}) {
|
|
1029
|
+
const { result } = await runLocalFindingWorkbench(repository, "list-external-finding-publications", { id }, dependencies);
|
|
1030
|
+
return result["publications"];
|
|
1031
|
+
}
|
|
1032
|
+
/** @internal Run a command against the workbench for the selected checkout. */
|
|
1033
|
+
async function runLocalFindingWorkbench(path, command, selection, dependencies) {
|
|
1034
|
+
const { repository, selectedPath, options } = await localContext(path, dependencies, "read");
|
|
836
1035
|
const result = await abortable(() => {
|
|
837
1036
|
dependencies.signal?.throwIfAborted();
|
|
838
|
-
return (dependencies.runWorkbench ?? runWorkbench)(options, [
|
|
1037
|
+
return (dependencies.runWorkbench ?? runWorkbench)(options, [command], JSON.stringify({ repository, ...selection }));
|
|
839
1038
|
}, dependencies.signal);
|
|
840
|
-
return result
|
|
1039
|
+
return { selectedPath, result };
|
|
841
1040
|
}
|
|
842
1041
|
//# sourceMappingURL=external-findings-local.js.map
|