@openai/codex-security 0.8.2 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +201 -178
- package/_bundled_plugin/.app.json +4 -0
- package/_bundled_plugin/.mcp.json +6 -1
- package/_bundled_plugin/examples/completed-scan/findings.json +16 -4
- package/_bundled_plugin/examples/completed-scan/report.md +11 -8
- package/_bundled_plugin/examples/completed-scan/scan-manifest.json +4 -2
- package/_bundled_plugin/mcp/fzstd-LICENSE.txt +21 -0
- package/_bundled_plugin/mcp/helpers.mjs +2 -11
- package/_bundled_plugin/mcp/helpers.mjs.br +0 -0
- package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +3 -210
- package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
- package/_bundled_plugin/mcp/package.json +1 -0
- package/_bundled_plugin/mcp/permission-profile-preflight.mjs +51 -14
- package/_bundled_plugin/mcp/server.mjs +2 -11
- package/_bundled_plugin/mcp/server.mjs.br +0 -0
- package/_bundled_plugin/mcp/session-decompression.mjs +712 -0
- package/_bundled_plugin/references/artifact-storage.md +1 -1
- package/_bundled_plugin/references/core-scan.md +14 -5
- package/_bundled_plugin/references/default-severity-rubric.md +33 -0
- package/_bundled_plugin/references/final-report.md +5 -3
- package/_bundled_plugin/references/finding-detail-fields.md +19 -18
- package/_bundled_plugin/references/sarif-adapter.md +8 -2
- package/_bundled_plugin/references/scan-artifacts.md +21 -12
- package/_bundled_plugin/references/scan-contract.md +27 -33
- package/_bundled_plugin/references/threat-model.md +1 -0
- package/_bundled_plugin/schemas/tools/scan-draft.schema.json +2 -2
- package/_bundled_plugin/scripts/check_deep_scan_target.py +97 -0
- package/_bundled_plugin/scripts/codex_profile.mjs +7 -1
- package/_bundled_plugin/scripts/deep_scan_config.py +20 -1
- package/_bundled_plugin/scripts/deep_scan_workbench.py +188 -454
- package/_bundled_plugin/scripts/filesystem_identity.py +1 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +317 -377
- package/_bundled_plugin/scripts/finding_preview.py +25 -29
- package/_bundled_plugin/scripts/launch_codex_security_mcp +1 -0
- package/_bundled_plugin/scripts/legacy_findings.py +148 -0
- package/_bundled_plugin/scripts/posix_scan_local_files.py +198 -0
- package/_bundled_plugin/scripts/read_codex_session.mjs +21 -0
- package/_bundled_plugin/scripts/report_projection.py +167 -178
- package/_bundled_plugin/scripts/review_state.py +8 -2
- package/_bundled_plugin/scripts/servicenow_avit.py +20 -0
- package/_bundled_plugin/scripts/snapshot_sqlite.py +1 -0
- package/_bundled_plugin/scripts/threat_model_projection.py +22 -26
- package/_bundled_plugin/scripts/validate_scan_contract.py +9 -7
- package/_bundled_plugin/scripts/windows_scan_local_files.py +600 -72
- package/_bundled_plugin/scripts/workbench/__init__.py +1 -1
- package/_bundled_plugin/scripts/workbench/handoff.py +47 -0
- package/_bundled_plugin/scripts/workbench/retained_coverage.py +38 -75
- package/_bundled_plugin/scripts/workbench/retained_records.py +18 -30
- package/_bundled_plugin/scripts/workbench/runtime_toml.py +4 -1
- package/_bundled_plugin/scripts/workbench/saved_coverage.py +152 -248
- package/_bundled_plugin/scripts/workbench/saved_outputs.py +9 -0
- package/_bundled_plugin/scripts/workbench/saved_sources.py +47 -40
- package/_bundled_plugin/scripts/workbench/storage.py +71 -7
- package/_bundled_plugin/scripts/workbench_cli.py +121 -14
- package/_bundled_plugin/scripts/workbench_constants.py +19 -0
- package/_bundled_plugin/scripts/workbench_coverage_receipts.py +3 -3
- package/_bundled_plugin/scripts/workbench_db.py +550 -492
- package/_bundled_plugin/scripts/workbench_feedback.py +8 -7
- package/_bundled_plugin/scripts/workbench_finding_index.py +1 -0
- package/_bundled_plugin/scripts/workbench_finding_workflows.py +90 -4
- package/_bundled_plugin/scripts/workbench_native_indexes.py +29 -33
- package/_bundled_plugin/scripts/workbench_progress.py +10 -1
- package/_bundled_plugin/scripts/workbench_publication.py +14 -10
- package/_bundled_plugin/scripts/workbench_remediation.py +508 -11
- package/_bundled_plugin/scripts/workbench_saved_results.py +132 -77
- package/_bundled_plugin/scripts/workbench_scan_history.py +139 -80
- package/_bundled_plugin/scripts/workbench_scan_start.py +84 -25
- package/_bundled_plugin/scripts/workbench_scan_usage.py +666 -117
- package/_bundled_plugin/scripts/workbench_schema.py +44 -55
- package/_bundled_plugin/scripts/workbench_setup.py +251 -0
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +13 -0
- package/_bundled_plugin/scripts/workbench_source_scopes.py +33 -23
- package/_bundled_plugin/scripts/workbench_target.py +330 -66
- package/_bundled_plugin/scripts/workbench_target_state.py +3 -0
- package/_bundled_plugin/scripts/workbench_validation.py +44 -12
- package/_bundled_plugin/shared/workbench-history-repairs.json +19 -16
- package/_bundled_plugin/shared/workbench-migrations.json +53 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +1 -1
- package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +4 -68
- package/_bundled_plugin/skills/check-skills/SKILL.md +43 -0
- package/_bundled_plugin/skills/check-skills/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/cloud-findings/SKILL.md +6 -4
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +7 -50
- package/_bundled_plugin/skills/fix-finding/SKILL.md +19 -2
- package/_bundled_plugin/skills/publish-findings/SKILL.md +81 -45
- package/_bundled_plugin/skills/publish-findings/references/checkmarx-import.md +37 -0
- package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +5 -24
- package/_bundled_plugin/skills/publish-findings/scripts/collect_checkmarx.py +464 -0
- package/_bundled_plugin/skills/threat-model-visualize/scripts/build_explorer.py +36 -9
- package/_bundled_plugin/skills/track-findings/SKILL.md +5 -3
- package/_bundled_plugin/skills/triage-finding/references/github-rest-intake.md +22 -68
- package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +12 -6
- package/dist/api.d.ts +45 -5
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +1144 -411
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +10 -7
- package/dist/auth.js.map +1 -1
- package/dist/bedrock-oss-pricing.d.ts +6 -0
- package/dist/bedrock-oss-pricing.d.ts.map +1 -0
- package/dist/bedrock-oss-pricing.js +58 -0
- package/dist/bedrock-oss-pricing.js.map +1 -0
- package/dist/bedrock-pricing.d.ts +15 -0
- package/dist/bedrock-pricing.d.ts.map +1 -0
- package/dist/bedrock-pricing.js +117 -0
- package/dist/bedrock-pricing.js.map +1 -0
- package/dist/blackduck-findings.d.ts +8 -0
- package/dist/blackduck-findings.d.ts.map +1 -0
- package/dist/blackduck-findings.js +320 -0
- package/dist/blackduck-findings.js.map +1 -0
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +51 -36
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/checkmarx-evidence.d.ts +19 -0
- package/dist/checkmarx-evidence.d.ts.map +1 -0
- package/dist/checkmarx-evidence.js +36 -0
- package/dist/checkmarx-evidence.js.map +1 -0
- package/dist/checkmarx-findings.d.ts +4 -0
- package/dist/checkmarx-findings.d.ts.map +1 -0
- package/dist/checkmarx-findings.js +27 -0
- package/dist/checkmarx-findings.js.map +1 -0
- package/dist/checkmarx-one.d.ts +4 -0
- package/dist/checkmarx-one.d.ts.map +1 -0
- package/dist/checkmarx-one.js +53 -0
- package/dist/checkmarx-one.js.map +1 -0
- package/dist/checkmarx-repository.d.ts +12 -0
- package/dist/checkmarx-repository.d.ts.map +1 -0
- package/dist/checkmarx-repository.js +181 -0
- package/dist/checkmarx-repository.js.map +1 -0
- package/dist/checkmarx-xml.d.ts +12 -0
- package/dist/checkmarx-xml.d.ts.map +1 -0
- package/dist/checkmarx-xml.js +196 -0
- package/dist/checkmarx-xml.js.map +1 -0
- package/dist/classify-severity-records.d.ts +6 -9
- package/dist/classify-severity-records.d.ts.map +1 -1
- package/dist/classify-severity-records.js +9 -21
- package/dist/classify-severity-records.js.map +1 -1
- package/dist/classify-severity.d.ts +4 -1
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +30 -13
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli.d.ts +14 -5
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2112 -1266
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.js +2 -2
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codex-prompt.d.ts +2 -0
- package/dist/codex-prompt.d.ts.map +1 -1
- package/dist/codex-prompt.js +6 -0
- package/dist/codex-prompt.js.map +1 -1
- package/dist/component-scan.d.ts +16 -3
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +32 -6
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +221 -65
- package/dist/config.js.map +1 -1
- package/dist/continuum-findings.d.ts +7 -0
- package/dist/continuum-findings.d.ts.map +1 -0
- package/dist/continuum-findings.js +225 -0
- package/dist/continuum-findings.js.map +1 -0
- package/dist/contract-values.d.ts +30 -0
- package/dist/contract-values.d.ts.map +1 -0
- package/dist/contract-values.js +78 -0
- package/dist/contract-values.js.map +1 -0
- package/dist/contract.d.ts +2 -20
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +58 -669
- package/dist/contract.js.map +1 -1
- package/dist/cost-model.d.ts +13 -1
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +66 -115
- package/dist/cost-model.js.map +1 -1
- package/dist/cost.d.ts +61 -4
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +2560 -100
- package/dist/cost.js.map +1 -1
- package/dist/custom-publish.d.ts +4 -0
- package/dist/custom-publish.d.ts.map +1 -1
- package/dist/custom-publish.js +40 -3
- package/dist/custom-publish.js.map +1 -1
- package/dist/custom-validation-prompt.d.ts +1 -1
- package/dist/custom-validation-prompt.d.ts.map +1 -1
- package/dist/custom-validation-prompt.js +5 -0
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/custom-validation.d.ts +2 -0
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +4 -0
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts +4 -4
- package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
- package/dist/deduplication/deduplication-prompts.js +2 -2
- package/dist/deduplication/deduplication-prompts.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts +14 -11
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
- package/dist/deduplication/deduplication-reviewer.js +11 -4
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/deduplication.js.map +1 -1
- package/dist/deduplication/finding-schema.d.ts +19 -1
- package/dist/deduplication/finding-schema.d.ts.map +1 -1
- package/dist/deduplication/finding-schema.js +25 -0
- package/dist/deduplication/finding-schema.js.map +1 -1
- package/dist/deduplication/local.d.ts +2 -2
- package/dist/deduplication/local.d.ts.map +1 -1
- package/dist/deduplication/local.js +5 -10
- package/dist/deduplication/local.js.map +1 -1
- package/dist/deduplication/records.d.ts +8 -2
- package/dist/deduplication/records.d.ts.map +1 -1
- package/dist/deduplication/records.js +36 -8
- package/dist/deduplication/records.js.map +1 -1
- package/dist/deduplication/refusal.d.ts.map +1 -1
- package/dist/deduplication/refusal.js +25 -5
- package/dist/deduplication/refusal.js.map +1 -1
- package/dist/deduplication/scan.d.ts +3 -0
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +1 -1
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-config.d.ts +0 -1
- package/dist/deep-config.d.ts.map +1 -1
- package/dist/deep-config.js +22 -33
- package/dist/deep-config.js.map +1 -1
- package/dist/deep-scan-defaults.d.ts +2 -0
- package/dist/deep-scan-defaults.d.ts.map +1 -1
- package/dist/deep-scan-defaults.js +28 -1
- package/dist/deep-scan-defaults.js.map +1 -1
- package/dist/deep-scan.d.ts +13 -0
- package/dist/deep-scan.d.ts.map +1 -1
- package/dist/deep-scan.js +262 -7
- package/dist/deep-scan.js.map +1 -1
- package/dist/default-severity-rubric.d.ts +1 -2
- package/dist/default-severity-rubric.d.ts.map +1 -1
- package/dist/default-severity-rubric.js +2 -66
- package/dist/default-severity-rubric.js.map +1 -1
- package/dist/endor-findings.d.ts +3 -1
- package/dist/endor-findings.d.ts.map +1 -1
- package/dist/endor-findings.js +108 -80
- package/dist/endor-findings.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +9 -2
- package/dist/errors.js.map +1 -1
- package/dist/external-findings-import.d.ts +5 -3
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +11 -16
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts +15 -4
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +619 -225
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +20 -6
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +2356 -308
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +28 -2
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +174 -81
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-findings.d.ts +17 -3
- package/dist/external-findings.d.ts.map +1 -1
- package/dist/external-findings.js +153 -1
- package/dist/external-findings.js.map +1 -1
- package/dist/external-import-contract.d.ts +33 -1
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +335 -51
- package/dist/external-import-contract.js.map +1 -1
- package/dist/external-import-models.d.ts +1 -1
- package/dist/external-import-models.d.ts.map +1 -1
- package/dist/external-import-models.js.map +1 -1
- package/dist/feedback.d.ts.map +1 -1
- package/dist/feedback.js +5 -4
- package/dist/feedback.js.map +1 -1
- package/dist/finding-prompt.d.ts +5 -0
- package/dist/finding-prompt.d.ts.map +1 -0
- package/dist/finding-prompt.js +32 -0
- package/dist/finding-prompt.js.map +1 -0
- package/dist/finding-retrieval.d.ts +3 -3
- package/dist/finding-retrieval.d.ts.map +1 -1
- package/dist/finding-retrieval.js.map +1 -1
- package/dist/finding-workflow.d.ts +6 -1
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js +2 -2
- package/dist/finding-workflow.js.map +1 -1
- package/dist/findings-client.d.ts +1 -0
- package/dist/findings-client.d.ts.map +1 -1
- package/dist/findings-client.js +27 -3
- package/dist/findings-client.js.map +1 -1
- package/dist/git-remote.d.ts +4 -0
- package/dist/git-remote.d.ts.map +1 -1
- package/dist/git-remote.js +20 -0
- package/dist/git-remote.js.map +1 -1
- package/dist/github-advisories.d.ts +3 -12
- package/dist/github-advisories.d.ts.map +1 -1
- package/dist/github-advisories.js +9 -31
- package/dist/github-advisories.js.map +1 -1
- package/dist/github-dependabot-findings.d.ts.map +1 -1
- package/dist/github-dependabot-findings.js +22 -20
- package/dist/github-dependabot-findings.js.map +1 -1
- package/dist/github-findings.d.ts +4 -1
- package/dist/github-findings.d.ts.map +1 -1
- package/dist/github-findings.js +392 -79
- package/dist/github-findings.js.map +1 -1
- package/dist/github.d.ts +17 -7
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +43 -30
- package/dist/github.js.map +1 -1
- package/dist/host-protocol.d.ts +2 -2
- package/dist/host-protocol.d.ts.map +1 -1
- package/dist/host-protocol.js.map +1 -1
- package/dist/host-records-protocol.d.ts +10 -11
- package/dist/host-records-protocol.d.ts.map +1 -1
- package/dist/host-records-protocol.js +69 -9
- package/dist/host-records-protocol.js.map +1 -1
- package/dist/hosted-git-remotes.d.ts +5 -0
- package/dist/hosted-git-remotes.d.ts.map +1 -0
- package/dist/hosted-git-remotes.js +285 -0
- package/dist/hosted-git-remotes.js.map +1 -0
- package/dist/hosted-git-repository.d.ts +28 -0
- package/dist/hosted-git-repository.d.ts.map +1 -0
- package/dist/hosted-git-repository.js +222 -0
- package/dist/hosted-git-repository.js.map +1 -0
- package/dist/hosted-scan-protocol.js +2 -2
- package/dist/hosted-scan-protocol.js.map +1 -1
- package/dist/hosted-scan.d.ts +15 -0
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +71 -44
- package/dist/hosted-scan.js.map +1 -1
- package/dist/hosted-scanner-http.d.ts +21 -0
- package/dist/hosted-scanner-http.d.ts.map +1 -0
- package/dist/hosted-scanner-http.js +204 -0
- package/dist/hosted-scanner-http.js.map +1 -0
- package/dist/hosted-scanner-v1.d.ts +6 -0
- package/dist/hosted-scanner-v1.d.ts.map +1 -0
- package/dist/hosted-scanner-v1.js +60 -0
- package/dist/hosted-scanner-v1.js.map +1 -0
- package/dist/import-scan.d.ts.map +1 -1
- package/dist/import-scan.js +3 -0
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +24 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/inspector-findings.d.ts.map +1 -1
- package/dist/inspector-findings.js +58 -81
- package/dist/inspector-findings.js.map +1 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +86 -10
- package/dist/knowledge-base.js.map +1 -1
- package/dist/local-git-metadata.d.ts +5 -0
- package/dist/local-git-metadata.d.ts.map +1 -0
- package/dist/local-git-metadata.js +130 -0
- package/dist/local-git-metadata.js.map +1 -0
- package/dist/multiscan.d.ts +6 -4
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +160 -77
- package/dist/multiscan.js.map +1 -1
- package/dist/native-json-findings.d.ts +2 -1
- package/dist/native-json-findings.d.ts.map +1 -1
- package/dist/native-json-findings.js +12 -2
- package/dist/native-json-findings.js.map +1 -1
- package/dist/opengrep-findings.d.ts +1 -0
- package/dist/opengrep-findings.d.ts.map +1 -1
- package/dist/opengrep-findings.js +49 -31
- package/dist/opengrep-findings.js.map +1 -1
- package/dist/operation-telemetry.d.ts +104 -0
- package/dist/operation-telemetry.d.ts.map +1 -0
- package/dist/operation-telemetry.js +293 -0
- package/dist/operation-telemetry.js.map +1 -0
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +90 -35
- package/dist/patch-tui.js.map +1 -1
- package/dist/plugin-python-probe.d.ts +4 -0
- package/dist/plugin-python-probe.d.ts.map +1 -0
- package/dist/plugin-python-probe.js +10 -0
- package/dist/plugin-python-probe.js.map +1 -0
- package/dist/private-finding-import.d.ts +341 -0
- package/dist/private-finding-import.d.ts.map +1 -0
- package/dist/private-finding-import.js +411 -0
- package/dist/private-finding-import.js.map +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +2 -2
- package/dist/project-config.js.map +1 -1
- package/dist/provider-profile.d.ts +11 -3
- package/dist/provider-profile.d.ts.map +1 -1
- package/dist/provider-profile.js +80 -11
- package/dist/provider-profile.js.map +1 -1
- package/dist/publication-telemetry.d.ts +45 -0
- package/dist/publication-telemetry.d.ts.map +1 -0
- package/dist/publication-telemetry.js +50 -0
- package/dist/publication-telemetry.js.map +1 -0
- package/dist/publication.js +7 -1
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts +4 -0
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +42 -2
- package/dist/publish.js.map +1 -1
- package/dist/reader-selection.d.ts +15 -0
- package/dist/reader-selection.d.ts.map +1 -0
- package/dist/reader-selection.js +89 -0
- package/dist/reader-selection.js.map +1 -0
- package/dist/record.d.ts +6 -1
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +53 -2
- package/dist/record.js.map +1 -1
- package/dist/remediation.d.ts +3 -1
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +28 -2
- package/dist/remediation.js.map +1 -1
- package/dist/request-metadata.d.ts +3 -0
- package/dist/request-metadata.d.ts.map +1 -1
- package/dist/request-metadata.js +9 -0
- package/dist/request-metadata.js.map +1 -1
- package/dist/result.d.ts +6 -0
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +3 -1
- package/dist/result.js.map +1 -1
- package/dist/retry-windows-rename.d.ts +8 -0
- package/dist/retry-windows-rename.d.ts.map +1 -0
- package/dist/retry-windows-rename.js +24 -0
- package/dist/retry-windows-rename.js.map +1 -0
- package/dist/runtime.d.ts +22 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +408 -162
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan-bootstrap.d.ts +1 -0
- package/dist/saved-scan-bootstrap.d.ts.map +1 -1
- package/dist/saved-scan-bootstrap.js +18 -15
- package/dist/saved-scan-bootstrap.js.map +1 -1
- package/dist/scan-activity.d.ts.map +1 -1
- package/dist/scan-activity.js +172 -64
- package/dist/scan-activity.js.map +1 -1
- package/dist/scan-comparison.d.ts +10 -5
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +68 -25
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +7 -6
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +91 -79
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-executor.d.ts +12 -1
- package/dist/scan-executor.d.ts.map +1 -1
- package/dist/scan-executor.js +22 -2
- package/dist/scan-executor.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +31 -28
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts +12 -0
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +106 -77
- package/dist/scan-logs.js.map +1 -1
- package/dist/scan-measurement.d.ts +26 -0
- package/dist/scan-measurement.d.ts.map +1 -0
- package/dist/scan-measurement.js +77 -0
- package/dist/scan-measurement.js.map +1 -0
- package/dist/scan-progress.d.ts +1 -0
- package/dist/scan-progress.d.ts.map +1 -1
- package/dist/scan-progress.js +3 -0
- package/dist/scan-progress.js.map +1 -1
- package/dist/scan-sessions.d.ts.map +1 -1
- package/dist/scan-sessions.js +4 -1
- package/dist/scan-sessions.js.map +1 -1
- package/dist/scan-settings.d.ts +1 -1
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +1 -24
- package/dist/scan-settings.js.map +1 -1
- package/dist/scanner-import.d.ts +64 -6
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +406 -48
- package/dist/scanner-import.js.map +1 -1
- package/dist/scanner-repository-url.d.ts +17 -0
- package/dist/scanner-repository-url.d.ts.map +1 -0
- package/dist/scanner-repository-url.js +71 -0
- package/dist/scanner-repository-url.js.map +1 -0
- package/dist/security-policy.d.ts +1 -1
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js.map +1 -1
- package/dist/semgrep-findings.d.ts +6 -3
- package/dist/semgrep-findings.d.ts.map +1 -1
- package/dist/semgrep-findings.js +124 -88
- package/dist/semgrep-findings.js.map +1 -1
- package/dist/semgrep-guardian-findings.d.ts +38 -0
- package/dist/semgrep-guardian-findings.d.ts.map +1 -0
- package/dist/semgrep-guardian-findings.js +165 -0
- package/dist/semgrep-guardian-findings.js.map +1 -0
- package/dist/semgrep-platform-collector.d.ts +26 -0
- package/dist/semgrep-platform-collector.d.ts.map +1 -0
- package/dist/semgrep-platform-collector.js +108 -0
- package/dist/semgrep-platform-collector.js.map +1 -0
- package/dist/semgrep-platform-findings.d.ts +213 -0
- package/dist/semgrep-platform-findings.d.ts.map +1 -0
- package/dist/semgrep-platform-findings.js +1078 -0
- package/dist/semgrep-platform-findings.js.map +1 -0
- package/dist/semgrep-platform-v1.d.ts +6 -0
- package/dist/semgrep-platform-v1.d.ts.map +1 -0
- package/dist/semgrep-platform-v1.js +83 -0
- package/dist/semgrep-platform-v1.js.map +1 -0
- package/dist/server/api.d.ts +1 -1
- package/dist/server/api.d.ts.map +1 -1
- package/dist/server/api.js.map +1 -1
- package/dist/server/embedding-tokenizer.cdx.json +33 -0
- package/dist/server/embedding-tokenizer.d.ts +2 -0
- package/dist/server/embedding-tokenizer.d.ts.map +1 -0
- package/dist/server/embedding-tokenizer.js +322 -0
- package/dist/server/embedding-tokenizer.js.map +6 -0
- package/dist/server/embeddings.d.ts +16 -2
- package/dist/server/embeddings.d.ts.map +1 -1
- package/dist/server/embeddings.js +35 -5
- package/dist/server/embeddings.js.map +1 -1
- package/dist/session-lines.d.ts +5 -0
- package/dist/session-lines.d.ts.map +1 -0
- package/dist/session-lines.js +60 -0
- package/dist/session-lines.js.map +1 -0
- package/dist/severity-review.d.ts +3 -1
- package/dist/severity-review.d.ts.map +1 -1
- package/dist/severity-review.js +3 -2
- package/dist/severity-review.js.map +1 -1
- package/dist/severity-rubric.d.ts +20 -0
- package/dist/severity-rubric.d.ts.map +1 -0
- package/dist/severity-rubric.js +73 -0
- package/dist/severity-rubric.js.map +1 -0
- package/dist/severity-store.js +15 -5
- package/dist/severity-store.js.map +1 -1
- package/dist/skill-authentication.d.ts +1 -0
- package/dist/skill-authentication.d.ts.map +1 -1
- package/dist/skill-authentication.js +1 -0
- package/dist/skill-authentication.js.map +1 -1
- package/dist/snyk-findings.d.ts +7 -2
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +108 -84
- package/dist/snyk-findings.js.map +1 -1
- package/dist/snyk-rest-findings.d.ts +76 -0
- package/dist/snyk-rest-findings.d.ts.map +1 -0
- package/dist/snyk-rest-findings.js +1051 -0
- package/dist/snyk-rest-findings.js.map +1 -0
- package/dist/snyk-rest-v1.d.ts +28 -0
- package/dist/snyk-rest-v1.d.ts.map +1 -0
- package/dist/snyk-rest-v1.js +132 -0
- package/dist/snyk-rest-v1.js.map +1 -0
- package/dist/snyk-token-origin.d.ts +4 -0
- package/dist/snyk-token-origin.d.ts.map +1 -0
- package/dist/snyk-token-origin.js +82 -0
- package/dist/snyk-token-origin.js.map +1 -0
- package/dist/sonar-collector.d.ts +16 -0
- package/dist/sonar-collector.d.ts.map +1 -0
- package/dist/sonar-collector.js +380 -0
- package/dist/sonar-collector.js.map +1 -0
- package/dist/sonar-findings.d.ts +49 -0
- package/dist/sonar-findings.d.ts.map +1 -0
- package/dist/sonar-findings.js +288 -0
- package/dist/sonar-findings.js.map +1 -0
- package/dist/sonar-import.d.ts +111 -0
- package/dist/sonar-import.d.ts.map +1 -0
- package/dist/sonar-import.js +277 -0
- package/dist/sonar-import.js.map +1 -0
- package/dist/suggest-owners.d.ts.map +1 -1
- package/dist/suggest-owners.js +2 -1
- package/dist/suggest-owners.js.map +1 -1
- package/dist/target-drift.d.ts +9 -0
- package/dist/target-drift.d.ts.map +1 -0
- package/dist/target-drift.js +27 -0
- package/dist/target-drift.js.map +1 -0
- package/dist/targets.d.ts +5 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +73 -31
- package/dist/targets.js.map +1 -1
- package/dist/tenable-findings.d.ts +9 -0
- package/dist/tenable-findings.d.ts.map +1 -0
- package/dist/tenable-findings.js +122 -0
- package/dist/tenable-findings.js.map +1 -0
- package/dist/terminal-columns.d.ts +4 -0
- package/dist/terminal-columns.d.ts.map +1 -0
- package/dist/terminal-columns.js +19 -0
- package/dist/terminal-columns.js.map +1 -0
- package/dist/terminal-stream.d.ts +13 -0
- package/dist/terminal-stream.d.ts.map +1 -0
- package/dist/terminal-stream.js +35 -0
- package/dist/terminal-stream.js.map +1 -0
- package/dist/trivy-findings.d.ts +19 -0
- package/dist/trivy-findings.d.ts.map +1 -0
- package/dist/trivy-findings.js +435 -0
- package/dist/trivy-findings.js.map +1 -0
- package/dist/trivy-import.d.ts +19 -0
- package/dist/trivy-import.d.ts.map +1 -0
- package/dist/trivy-import.js +151 -0
- package/dist/trivy-import.js.map +1 -0
- package/dist/validation-records.d.ts +0 -3
- package/dist/validation-records.d.ts.map +1 -1
- package/dist/validation-records.js +1 -17
- package/dist/validation-records.js.map +1 -1
- package/dist/veracode-findings.d.ts +9 -0
- package/dist/veracode-findings.d.ts.map +1 -0
- package/dist/veracode-findings.js +409 -0
- package/dist/veracode-findings.js.map +1 -0
- package/dist/vertex-pricing.d.ts +8 -0
- package/dist/vertex-pricing.d.ts.map +1 -0
- package/dist/vertex-pricing.js +20 -0
- package/dist/vertex-pricing.js.map +1 -0
- package/dist/windows-path.d.ts +1 -0
- package/dist/windows-path.d.ts.map +1 -1
- package/dist/windows-path.js +27 -1
- package/dist/windows-path.js.map +1 -1
- package/dist/wiz-csv.d.ts +2 -2
- package/dist/wiz-csv.d.ts.map +1 -1
- package/dist/wiz-csv.js +1 -3
- package/dist/wiz-csv.js.map +1 -1
- package/dist/wiz-findings.d.ts +14 -2
- package/dist/wiz-findings.d.ts.map +1 -1
- package/dist/wiz-findings.js +143 -50
- package/dist/wiz-findings.js.map +1 -1
- package/docs/classify-severity-records.md +28 -13
- package/docs/cli.md +623 -843
- package/docs/dedupe-records.md +54 -24
- package/docs/findings-service.md +87 -47
- package/docs/hosted-remediation.md +14 -7
- package/docs/hosted-scans.md +64 -41
- package/docs/telemetry.md +236 -0
- package/docs/validate-records.md +78 -44
- package/package.json +19 -17
- package/schemas/external-findings.schema.json +14 -1
- package/schemas/hosted-scan-v2.fixture.json +16 -1
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
- package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +0 -96
- package/_bundled_plugin/scripts/validate_tracking_source.py +0 -82
- package/_bundled_plugin/scripts/workbench_local_dedupe.py +0 -136
- package/dist/deduplication/records-protocol.d.ts +0 -4
- package/dist/deduplication/records-protocol.d.ts.map +0 -1
- package/dist/deduplication/records-protocol.js +0 -49
- package/dist/deduplication/records-protocol.js.map +0 -1
- package/dist/external-imports-feature.d.ts +0 -6
- package/dist/external-imports-feature.d.ts.map +0 -1
- package/dist/external-imports-feature.js +0 -51
- package/dist/external-imports-feature.js.map +0 -1
- package/dist/finding-normalization.d.ts +0 -5
- package/dist/finding-normalization.d.ts.map +0 -1
- package/dist/finding-normalization.js +0 -120
- package/dist/finding-normalization.js.map +0 -1
|
@@ -1,19 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ExternalFinding, ExternalSourceRepository } from "./external-findings.js";
|
|
2
|
+
import type { Provider } from "./external-import-models.js";
|
|
3
|
+
export type LocalFindingProvider = Provider | "tenable";
|
|
4
|
+
/** File reader names mapped to the provider stored with each finding. */
|
|
2
5
|
export declare const EXTERNAL_FINDINGS_PROVIDERS: {
|
|
3
6
|
readonly wiz: "wiz";
|
|
4
7
|
readonly snyk: "snyk";
|
|
5
8
|
readonly semgrep: "semgrep";
|
|
9
|
+
readonly trivy: "trivy";
|
|
6
10
|
readonly opengrep: "semgrep";
|
|
7
11
|
readonly endor: "endor";
|
|
8
12
|
readonly github: "github";
|
|
9
13
|
readonly inspector: "inspector";
|
|
14
|
+
readonly blackduck: "blackduck";
|
|
15
|
+
readonly veracode: "veracode";
|
|
16
|
+
readonly sonar: "sonar";
|
|
17
|
+
readonly continuum: "continuum";
|
|
18
|
+
readonly checkmarx: "checkmarx";
|
|
19
|
+
readonly tenable: "tenable";
|
|
10
20
|
};
|
|
11
21
|
export type ExternalFindingsReader = keyof typeof EXTERNAL_FINDINGS_PROVIDERS;
|
|
22
|
+
export type CloudFindingsReader = Exclude<ExternalFindingsReader, "tenable">;
|
|
23
|
+
export declare function requireCloudReader(options: ExternalFindingsReaderOptions): asserts options is ExternalFindingsReaderOptions & {
|
|
24
|
+
provider: CloudFindingsReader;
|
|
25
|
+
};
|
|
12
26
|
export declare const EXTERNAL_FINDINGS_READERS: ExternalFindingsReader[];
|
|
13
|
-
/** File readers available in this SDK
|
|
27
|
+
/** File readers available in this SDK. Cloud supports a subset of these readers. */
|
|
14
28
|
export interface ExternalFindingsReaderOptions {
|
|
15
29
|
provider: ExternalFindingsReader;
|
|
16
30
|
sourceRepositoryUrl?: string;
|
|
17
31
|
inspectorProjectMap?: ReadonlyMap<string, string>;
|
|
32
|
+
trivyScanRoot?: string;
|
|
18
33
|
}
|
|
34
|
+
/** Repository references retained by a provider's individual finding. */
|
|
35
|
+
export declare function localFindingRepositories(provider: Provider, finding: ExternalFinding): ExternalSourceRepository[];
|
|
36
|
+
/** Repository claims retained by the Semgrep SARIF reader. */
|
|
37
|
+
export declare function semgrepSarifRepositories({ evidence }: ExternalFinding, allowPartialCloudUrl?: boolean): {
|
|
38
|
+
url: string;
|
|
39
|
+
branch?: string;
|
|
40
|
+
}[];
|
|
41
|
+
/** Repository claims from every project or SARIF run, even those with no findings. */
|
|
42
|
+
export declare function snykFileRepositories(input: unknown): {
|
|
43
|
+
url: string;
|
|
44
|
+
}[];
|
|
19
45
|
//# sourceMappingURL=external-findings-read.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-findings-read.d.ts","sourceRoot":"","sources":["../src/external-findings-read.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"external-findings-read.d.ts","sourceRoot":"","sources":["../src/external-findings-read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAGf,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAwD5D,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExD,yEAAyE;AACzE,eAAO,MAAM,2B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sarifRunRepositories } from "./scanner-import.js";
|
|
2
|
+
import { CodexSecurityError } from "./errors.js";
|
|
3
|
+
import { readTenableFindings } from "./tenable-findings.js";
|
|
4
|
+
import { dependabotRepository } from "./github-dependabot-findings.js";
|
|
5
|
+
import { normalizeSnykFile, readSnykReport, emptySnykReportRepositories, snykRepositoryUrls, } from "./snyk-findings.js";
|
|
6
|
+
import { isSemgrepSarifDriver, normalizeSemgrepFindings, readSemgrepReport, } from "./semgrep-findings.js";
|
|
7
|
+
import { semgrepPlatformReportRepository } from "./semgrep-platform-findings.js";
|
|
8
|
+
import { normalizeTrivyFindings, needsPreviousTrivyProjection, normalizePreviousTrivyFindings, } from "./trivy-findings.js";
|
|
4
9
|
import { readOpenGrepFindings } from "./opengrep-findings.js";
|
|
5
|
-
import {
|
|
10
|
+
import { normalizeEndorFindings, normalizePreviousEndorFindings, endorRepositoryUrls, } from "./endor-findings.js";
|
|
6
11
|
import { readGitHubFindings } from "./github-findings.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
12
|
+
import { readSonarFindings } from "./sonar-findings.js";
|
|
13
|
+
import { normalizeVeracodeFindings, normalizePreviousVeracodeFindings, } from "./veracode-findings.js";
|
|
14
|
+
import { needsPreviousBlackDuckProjection, normalizeBlackDuckFindings, normalizePreviousBlackDuckFindings, } from "./blackduck-findings.js";
|
|
15
|
+
import { normalizeContinuumFindings, normalizePreviousContinuumFindings, } from "./continuum-findings.js";
|
|
16
|
+
import { readCheckmarxFindings } from "./checkmarx-findings.js";
|
|
17
|
+
import { normalizeInspectorFindings, normalizePreviousInspectorFindings, } from "./inspector-findings.js";
|
|
18
|
+
import { hasPreviousCloudProjection } from "./reader-selection.js";
|
|
9
19
|
import { isRecord } from "./record.js";
|
|
10
|
-
import { readVendorFindingsForPublication } from "./wiz-findings.js";
|
|
11
|
-
/** File reader names mapped to
|
|
20
|
+
import { readLocalWizFindings, readVendorFindingsForPublication, wizFindingRepository, } from "./wiz-findings.js";
|
|
21
|
+
/** File reader names mapped to the provider stored with each finding. */
|
|
12
22
|
export const EXTERNAL_FINDINGS_PROVIDERS = {
|
|
13
23
|
wiz: "wiz",
|
|
14
24
|
snyk: "snyk",
|
|
15
25
|
semgrep: "semgrep",
|
|
26
|
+
trivy: "trivy",
|
|
16
27
|
// OpenGrep uses the existing SAST contract; evidence retains its scanner origin.
|
|
17
28
|
opengrep: "semgrep",
|
|
18
29
|
endor: "endor",
|
|
19
30
|
github: "github",
|
|
20
31
|
inspector: "inspector",
|
|
32
|
+
blackduck: "blackduck",
|
|
33
|
+
veracode: "veracode",
|
|
34
|
+
sonar: "sonar",
|
|
35
|
+
continuum: "continuum",
|
|
36
|
+
checkmarx: "checkmarx",
|
|
37
|
+
tenable: "tenable",
|
|
21
38
|
};
|
|
39
|
+
export function requireCloudReader(options) {
|
|
40
|
+
if (options.provider === "tenable")
|
|
41
|
+
throw new CodexSecurityError("Tenable findings require a local import (--to local).");
|
|
42
|
+
}
|
|
22
43
|
export const EXTERNAL_FINDINGS_READERS = Object.keys(EXTERNAL_FINDINGS_PROVIDERS);
|
|
44
|
+
/** Repository references retained by a provider's individual finding. */
|
|
45
|
+
export function localFindingRepositories(provider, finding) {
|
|
46
|
+
const { evidence } = finding;
|
|
47
|
+
if (provider === "snyk")
|
|
48
|
+
return snykRepositoryUrls(evidence.source_data, {
|
|
49
|
+
normalizeGitRemote: false,
|
|
50
|
+
}).map((url) => ({ url }));
|
|
51
|
+
if (provider === "endor")
|
|
52
|
+
return endorRepositoryUrls(evidence.source_data).map((url) => ({ url }));
|
|
53
|
+
if (provider === "wiz") {
|
|
54
|
+
const repository = wizFindingRepository(evidence);
|
|
55
|
+
return repository ? [repository] : [];
|
|
56
|
+
}
|
|
57
|
+
if (provider === "github") {
|
|
58
|
+
const url = dependabotRepository(finding);
|
|
59
|
+
if (url)
|
|
60
|
+
return [{ url, platform: "github" }];
|
|
61
|
+
}
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
/** Repository claims retained by the Semgrep SARIF reader. */
|
|
65
|
+
export function semgrepSarifRepositories({ evidence }, allowPartialCloudUrl = false) {
|
|
66
|
+
const data = evidence.source_data;
|
|
67
|
+
const document = data?.["documentContext"];
|
|
68
|
+
const driver = data?.["driverContext"];
|
|
69
|
+
const partial = allowPartialCloudUrl && document === undefined;
|
|
70
|
+
if ((!partial && (!isRecord(document) || document["version"] !== "2.1.0")) ||
|
|
71
|
+
!isRecord(driver) ||
|
|
72
|
+
typeof driver["name"] !== "string" ||
|
|
73
|
+
!isSemgrepSarifDriver(driver["name"]) ||
|
|
74
|
+
!isRecord(data?.["result"]))
|
|
75
|
+
return [];
|
|
76
|
+
const context = data["runContext"];
|
|
77
|
+
const references = isRecord(context)
|
|
78
|
+
? context["versionControlProvenance"]
|
|
79
|
+
: undefined;
|
|
80
|
+
return Array.isArray(references)
|
|
81
|
+
? references.flatMap((reference) => isRecord(reference) &&
|
|
82
|
+
typeof reference["repositoryUri"] === "string" &&
|
|
83
|
+
reference["repositoryUri"].trim()
|
|
84
|
+
? [
|
|
85
|
+
{
|
|
86
|
+
url: reference["repositoryUri"],
|
|
87
|
+
...(!partial &&
|
|
88
|
+
typeof reference["branch"] === "string" && {
|
|
89
|
+
branch: reference["branch"],
|
|
90
|
+
}),
|
|
91
|
+
},
|
|
92
|
+
]
|
|
93
|
+
: [])
|
|
94
|
+
: [];
|
|
95
|
+
}
|
|
96
|
+
/** A run may name a repository even when it produces no findings. */
|
|
97
|
+
function sarifFileRepositories(input, producer) {
|
|
98
|
+
if (isRecord(input) &&
|
|
99
|
+
input["version"] === "2.1.0" &&
|
|
100
|
+
Array.isArray(input["runs"]))
|
|
101
|
+
return input["runs"].flatMap((run) => sarifRunRepositories(run, producer));
|
|
102
|
+
}
|
|
103
|
+
/** Repository claims from every project or SARIF run, even those with no findings. */
|
|
104
|
+
export function snykFileRepositories(input) {
|
|
105
|
+
return (sarifFileRepositories(input, "Snyk") ?? emptySnykReportRepositories(input));
|
|
106
|
+
}
|
|
23
107
|
/** @internal Read vendor evidence for the local and Cloud import entrypoints. */
|
|
24
|
-
export async function readExternalFindings(path, options, target = "cloud") {
|
|
25
|
-
|
|
26
|
-
|
|
108
|
+
export async function readExternalFindings(path, options, target = "cloud", references = []) {
|
|
109
|
+
const { provider } = options;
|
|
110
|
+
const url = options.sourceRepositoryUrl ?? "";
|
|
111
|
+
// Both projections describe the same captured rows, including exclusions.
|
|
112
|
+
function withReplay(findings, couldDiffer, previous) {
|
|
27
113
|
return {
|
|
28
|
-
findings
|
|
29
|
-
|
|
114
|
+
findings,
|
|
115
|
+
previousFindings: target === "cloud" && couldDiffer(findings) ? previous : undefined,
|
|
30
116
|
};
|
|
31
117
|
}
|
|
32
|
-
if (
|
|
33
|
-
|
|
118
|
+
if (provider === "tenable") {
|
|
119
|
+
if (target === "cloud")
|
|
120
|
+
requireCloudReader(options);
|
|
121
|
+
return { findings: await readTenableFindings(path, url) };
|
|
122
|
+
}
|
|
123
|
+
if (provider === "sonar") {
|
|
124
|
+
const findings = await readSonarFindings(path, url, target);
|
|
125
|
+
const binding = findings.report?.["repositoryUrl"];
|
|
34
126
|
return {
|
|
35
127
|
findings,
|
|
36
|
-
sourceRepositories:
|
|
37
|
-
normalizeGitRemote: false,
|
|
38
|
-
}).map((url) => ({ url }))),
|
|
128
|
+
sourceRepositories: typeof binding === "string" ? [{ url: binding }] : [],
|
|
39
129
|
};
|
|
40
130
|
}
|
|
41
|
-
if (
|
|
42
|
-
const findings =
|
|
43
|
-
sourceRepositoryUrl:
|
|
131
|
+
if (provider === "opengrep" || provider === "checkmarx") {
|
|
132
|
+
const findings = provider === "opengrep"
|
|
133
|
+
? await readOpenGrepFindings(path, { sourceRepositoryUrl: url }, target)
|
|
134
|
+
: await readCheckmarxFindings(path, url, target);
|
|
135
|
+
return { findings, sourceRepositories: [{ url }] };
|
|
136
|
+
}
|
|
137
|
+
if (provider === "snyk") {
|
|
138
|
+
const input = await readSnykReport(path);
|
|
139
|
+
const findings = await normalizeSnykFile(input, target, references);
|
|
140
|
+
return { findings, sourceRepositories: snykFileRepositories(input) };
|
|
141
|
+
}
|
|
142
|
+
if (provider === "semgrep") {
|
|
143
|
+
const input = await readSemgrepReport(path);
|
|
144
|
+
const findings = normalizeSemgrepFindings(input, {
|
|
145
|
+
sourceRepositoryUrl: options.sourceRepositoryUrl,
|
|
146
|
+
sourceRepositories: references,
|
|
44
147
|
}, target);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return Array.isArray(references)
|
|
51
|
-
? references.flatMap((reference) => isRecord(reference) &&
|
|
52
|
-
typeof reference["repositoryUri"] === "string" &&
|
|
53
|
-
reference["repositoryUri"].trim()
|
|
54
|
-
? [{ url: reference["repositoryUri"] }]
|
|
55
|
-
: [])
|
|
56
|
-
: [];
|
|
57
|
-
});
|
|
148
|
+
if (semgrepPlatformReportRepository(findings))
|
|
149
|
+
return { findings };
|
|
150
|
+
const sourceRepositories = sarifFileRepositories(input, "Semgrep") ?? [];
|
|
151
|
+
if (!sourceRepositories.length && options.sourceRepositoryUrl)
|
|
152
|
+
sourceRepositories.push({ url: options.sourceRepositoryUrl });
|
|
58
153
|
return { findings, sourceRepositories };
|
|
59
154
|
}
|
|
60
|
-
if (
|
|
61
|
-
|
|
155
|
+
if (provider === "github")
|
|
156
|
+
return { findings: await readGitHubFindings(path, target) };
|
|
157
|
+
if (provider === "wiz") {
|
|
158
|
+
const wiz = target === "local"
|
|
159
|
+
? await readLocalWizFindings(path)
|
|
160
|
+
: await readVendorFindingsForPublication(path, target);
|
|
161
|
+
const sourceRepositories = wiz.current.findings.flatMap((finding) => localFindingRepositories("wiz", finding));
|
|
62
162
|
return {
|
|
63
|
-
findings:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}))),
|
|
163
|
+
findings: wiz.current,
|
|
164
|
+
...("legacy" in wiz && { publication: wiz }),
|
|
165
|
+
sourceRepositories: [...wiz.sourceRepositories, ...sourceRepositories],
|
|
67
166
|
};
|
|
68
167
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
168
|
+
const input = await readScannerJson(path);
|
|
169
|
+
if (provider === "trivy") {
|
|
170
|
+
const args = [input, target, options.trivyScanRoot];
|
|
171
|
+
return withReplay(normalizeTrivyFindings(...args), needsPreviousTrivyProjection, () => normalizePreviousTrivyFindings(...args));
|
|
172
|
+
}
|
|
173
|
+
if (provider === "endor") {
|
|
174
|
+
const findings = normalizeEndorFindings(input, target);
|
|
73
175
|
return {
|
|
74
|
-
findings
|
|
75
|
-
sourceRepositories:
|
|
176
|
+
...withReplay(findings, hasPreviousCloudProjection, () => normalizePreviousEndorFindings(input, target)),
|
|
177
|
+
sourceRepositories: sarifFileRepositories(input, "Endor") ??
|
|
178
|
+
findings.findings.flatMap((row) => localFindingRepositories(provider, row)),
|
|
76
179
|
};
|
|
77
180
|
}
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (!url)
|
|
89
|
-
return [];
|
|
90
|
-
const github = asset["nativeType"] === "github#repositoryBranch" ||
|
|
91
|
-
(asset["type"] === "REPOSITORY_BRANCH" &&
|
|
92
|
-
isGitHubCloudHost(url.hostname));
|
|
93
|
-
if (!github)
|
|
94
|
-
return asset["type"] === "REPOSITORY_BRANCH"
|
|
95
|
-
? [{ url: asset["cloudProviderURL"] }]
|
|
96
|
-
: [];
|
|
97
|
-
const [, owner, repository] = url.pathname.split("/");
|
|
98
|
-
return owner && repository
|
|
99
|
-
? [
|
|
100
|
-
{
|
|
101
|
-
url: `${url.origin}/${owner}/${repository}`,
|
|
102
|
-
platform: "github",
|
|
103
|
-
},
|
|
104
|
-
]
|
|
105
|
-
: [];
|
|
106
|
-
});
|
|
107
|
-
return {
|
|
108
|
-
findings: publication.current,
|
|
109
|
-
publication,
|
|
110
|
-
sourceRepositories: [
|
|
111
|
-
...publication.sourceRepositories,
|
|
112
|
-
...sourceRepositories,
|
|
181
|
+
const [normalize, previous, couldDiffer] = {
|
|
182
|
+
inspector: [
|
|
183
|
+
normalizeInspectorFindings,
|
|
184
|
+
normalizePreviousInspectorFindings,
|
|
185
|
+
() => true,
|
|
186
|
+
],
|
|
187
|
+
continuum: [
|
|
188
|
+
normalizeContinuumFindings,
|
|
189
|
+
normalizePreviousContinuumFindings,
|
|
190
|
+
() => !Array.isArray(input),
|
|
113
191
|
],
|
|
192
|
+
blackduck: [
|
|
193
|
+
normalizeBlackDuckFindings,
|
|
194
|
+
normalizePreviousBlackDuckFindings,
|
|
195
|
+
needsPreviousBlackDuckProjection,
|
|
196
|
+
],
|
|
197
|
+
veracode: [
|
|
198
|
+
normalizeVeracodeFindings,
|
|
199
|
+
normalizePreviousVeracodeFindings,
|
|
200
|
+
hasPreviousCloudProjection,
|
|
201
|
+
],
|
|
202
|
+
}[provider];
|
|
203
|
+
const args = [input, url, target, options.inspectorProjectMap];
|
|
204
|
+
return {
|
|
205
|
+
...withReplay(normalize(...args), couldDiffer, () => previous(...args)),
|
|
206
|
+
sourceRepositories: [{ url }],
|
|
114
207
|
};
|
|
115
208
|
}
|
|
116
209
|
//# sourceMappingURL=external-findings-read.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-findings-read.js","sourceRoot":"","sources":["../src/external-findings-read.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,kBAAkB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AC,CAAC;QACxD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,kBAAkB,CAAC,KAAK,QAAQ;YACnE,OAAO,EAAE,CAAC;QACZ,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACjD,IAAI,CAAC,GAAG;YAAE,OAAO,EAAE,CAAC;QACpB,MAAM,MAAM,GACV,KAAK,CAAC,YAAY,CAAC,KAAK,yBAAyB;YACjD,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,mBAAmB;gBACpC,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;QACrC,IAAI,CAAC,MAAM;YACT,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,mBAAmB;gBAC1C,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,kBAAkB,CAAC,EAAE,CAAC;gBACtC,CAAC,CAAC,EAAE,CAAC;QACT,MAAM,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtD,OAAO,KAAK,IAAI,UAAU;YACxB,CAAC,CAAC;gBACE;oBACE,GAAG,EAAE,GAAG,GAAG,CAAC,MAAM,IAAI,KAAK,IAAI,UAAU,EAAE;oBAC3C,QAAQ,EAAE,QAAiB;iBAC5B;aACF;YACH,CAAC,CAAC,EAAE,CAAC;IACT,CAAC,CACF,CAAC;IACF,OAAO;QACL,QAAQ,EAAE,WAAW,CAAC,OAAO;QAC7B,WAAW;QACX,kBAAkB,EAAE;YAClB,GAAG,WAAW,CAAC,kBAAkB;YACjC,GAAG,kBAAkB;SACtB;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ExternalFindings,\n ExternalPublicationInput,\n ExternalSourceRepository,\n} from \"./external-findings.js\";\nimport type { Provider } from \"./external-import-models.js\";\nimport type { ExternalImportTarget } from \"./external-import-contract.js\";\nimport { wizCsvRepositoryUrl } from \"./wiz-csv.js\";\nimport { readSnykFindings, snykRepositoryUrls } from \"./snyk-findings.js\";\nimport { readSemgrepFindings } from \"./semgrep-findings.js\";\nimport { readOpenGrepFindings } from \"./opengrep-findings.js\";\nimport { readEndorFindings, endorRepositoryUrls } from \"./endor-findings.js\";\nimport { readGitHubFindings } from \"./github-findings.js\";\nimport { readInspectorFindings } from \"./inspector-findings.js\";\nimport { isGitHubCloudHost } from \"./git-remote.js\";\nimport { isRecord } from \"./record.js\";\nimport { readVendorFindingsForPublication } from \"./wiz-findings.js\";\n\n/** File reader names mapped to their stored and Cloud source provider. */\nexport const EXTERNAL_FINDINGS_PROVIDERS = {\n wiz: \"wiz\",\n snyk: \"snyk\",\n semgrep: \"semgrep\",\n // OpenGrep uses the existing SAST contract; evidence retains its scanner origin.\n opengrep: \"semgrep\",\n endor: \"endor\",\n github: \"github\",\n inspector: \"inspector\",\n} as const satisfies Record<string, Provider>;\n\nexport type ExternalFindingsReader = keyof typeof EXTERNAL_FINDINGS_PROVIDERS;\n\nexport const EXTERNAL_FINDINGS_READERS = Object.keys(\n EXTERNAL_FINDINGS_PROVIDERS,\n) as ExternalFindingsReader[];\n\n/** File readers available in this SDK, shared by local and Cloud imports. */\nexport interface ExternalFindingsReaderOptions {\n provider: ExternalFindingsReader;\n sourceRepositoryUrl?: string;\n inspectorProjectMap?: ReadonlyMap<string, string>;\n}\n\n/** @internal Shared parser output, including immutable Cloud retry projections. */\nexport interface ReadExternalFindings {\n findings: ExternalFindings;\n /** Preserve previous Wiz projections when resuming immutable Cloud requests. */\n publication?: ExternalPublicationInput;\n sourceRepositories?: ExternalSourceRepository[];\n}\n\n/** @internal Read vendor evidence for the local and Cloud import entrypoints. */\nexport async function readExternalFindings(\n path: string,\n options: ExternalFindingsReaderOptions,\n target: ExternalImportTarget = \"cloud\",\n): Promise<ReadExternalFindings> {\n if (options.provider === \"opengrep\") {\n const sourceRepositoryUrl = options.sourceRepositoryUrl ?? \"\";\n return {\n findings: await readOpenGrepFindings(\n path,\n { sourceRepositoryUrl },\n target,\n ),\n sourceRepositories: [{ url: sourceRepositoryUrl }],\n };\n }\n if (options.provider === \"snyk\") {\n const findings = await readSnykFindings(path, target);\n return {\n findings,\n sourceRepositories: findings.findings.flatMap(({ evidence }) =>\n snykRepositoryUrls(evidence.source_data, {\n normalizeGitRemote: false,\n }).map((url) => ({ url })),\n ),\n };\n }\n if (options.provider === \"semgrep\") {\n const findings = await readSemgrepFindings(\n path,\n {\n sourceRepositoryUrl: options.sourceRepositoryUrl ?? \"\",\n },\n target,\n );\n const sourceRepositories = findings.findings.flatMap(({ evidence }) => {\n const context = evidence.source_data?.[\"runContext\"];\n const references = isRecord(context)\n ? context[\"versionControlProvenance\"]\n : undefined;\n return Array.isArray(references)\n ? references.flatMap((reference) =>\n isRecord(reference) &&\n typeof reference[\"repositoryUri\"] === \"string\" &&\n reference[\"repositoryUri\"].trim()\n ? [{ url: reference[\"repositoryUri\"] }]\n : [],\n )\n : [];\n });\n return { findings, sourceRepositories };\n }\n if (options.provider === \"endor\") {\n const parsed = await readEndorFindings(path, target);\n return {\n findings: parsed,\n sourceRepositories: parsed.findings.flatMap((finding) =>\n endorRepositoryUrls(finding.evidence.source_data).map((url) => ({\n url,\n })),\n ),\n };\n }\n if (options.provider === \"github\")\n return { findings: await readGitHubFindings(path, target) };\n if (options.provider === \"inspector\") {\n const url = options.sourceRepositoryUrl ?? \"\";\n return {\n findings: await readInspectorFindings(\n path,\n url,\n target,\n options.inspectorProjectMap,\n ),\n sourceRepositories: [{ url }],\n };\n }\n const publication = await readVendorFindingsForPublication(path, target);\n // Raw package exports keep repository-branch URLs in retained source data.\n const sourceRepositories = publication.current.findings.flatMap(\n ({ evidence }) => {\n const csvUrl = wizCsvRepositoryUrl(evidence);\n if (csvUrl) return [{ url: csvUrl, platform: \"github\" as const }];\n const asset = evidence.source_data?.[\"vulnerableAsset\"];\n if (!isRecord(asset) || typeof asset[\"cloudProviderURL\"] !== \"string\")\n return [];\n const url = URL.parse(asset[\"cloudProviderURL\"]);\n if (!url) return [];\n const github =\n asset[\"nativeType\"] === \"github#repositoryBranch\" ||\n (asset[\"type\"] === \"REPOSITORY_BRANCH\" &&\n isGitHubCloudHost(url.hostname));\n if (!github)\n return asset[\"type\"] === \"REPOSITORY_BRANCH\"\n ? [{ url: asset[\"cloudProviderURL\"] }]\n : [];\n const [, owner, repository] = url.pathname.split(\"/\");\n return owner && repository\n ? [\n {\n url: `${url.origin}/${owner}/${repository}`,\n platform: \"github\" as const,\n },\n ]\n : [];\n },\n );\n return {\n findings: publication.current,\n publication,\n sourceRepositories: [\n ...publication.sourceRepositories,\n ...sourceRepositories,\n ],\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"external-findings-read.js","sourceRoot":"","sources":["../src/external-findings-read.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACL,sBAAsB,EACtB,8BAA8B,EAC9B,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OA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AW,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;QACvE,kBAAkB,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;KAC9B,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ExternalFinding,\n ExternalFindings,\n ExternalPublicationInput,\n ExternalSourceRepository,\n} from \"./external-findings.js\";\nimport { readScannerJson, sarifRunRepositories } from \"./scanner-import.js\";\nimport type { Provider } from \"./external-import-models.js\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport { readTenableFindings } from \"./tenable-findings.js\";\nimport type { ExternalImportTarget } from \"./external-import-contract.js\";\nimport { dependabotRepository } from \"./github-dependabot-findings.js\";\nimport {\n normalizeSnykFile,\n readSnykReport,\n emptySnykReportRepositories,\n snykRepositoryUrls,\n} from \"./snyk-findings.js\";\nimport {\n isSemgrepSarifDriver,\n normalizeSemgrepFindings,\n readSemgrepReport,\n} from \"./semgrep-findings.js\";\nimport { semgrepPlatformReportRepository } from \"./semgrep-platform-findings.js\";\nimport {\n normalizeTrivyFindings,\n needsPreviousTrivyProjection,\n normalizePreviousTrivyFindings,\n} from \"./trivy-findings.js\";\nimport { readOpenGrepFindings } from \"./opengrep-findings.js\";\nimport {\n normalizeEndorFindings,\n normalizePreviousEndorFindings,\n endorRepositoryUrls,\n} from \"./endor-findings.js\";\nimport { readGitHubFindings } from \"./github-findings.js\";\nimport { readSonarFindings } from \"./sonar-findings.js\";\nimport {\n normalizeVeracodeFindings,\n normalizePreviousVeracodeFindings,\n} from \"./veracode-findings.js\";\nimport {\n needsPreviousBlackDuckProjection,\n normalizeBlackDuckFindings,\n normalizePreviousBlackDuckFindings,\n} from \"./blackduck-findings.js\";\nimport {\n normalizeContinuumFindings,\n normalizePreviousContinuumFindings,\n} from \"./continuum-findings.js\";\nimport { readCheckmarxFindings } from \"./checkmarx-findings.js\";\nimport {\n normalizeInspectorFindings,\n normalizePreviousInspectorFindings,\n} from \"./inspector-findings.js\";\nimport { hasPreviousCloudProjection } from \"./reader-selection.js\";\nimport { isRecord } from \"./record.js\";\nimport {\n readLocalWizFindings,\n readVendorFindingsForPublication,\n wizFindingRepository,\n} from \"./wiz-findings.js\";\n\nexport type LocalFindingProvider = Provider | \"tenable\";\n\n/** File reader names mapped to the provider stored with each finding. */\nexport const EXTERNAL_FINDINGS_PROVIDERS = {\n wiz: \"wiz\",\n snyk: \"snyk\",\n semgrep: \"semgrep\",\n trivy: \"trivy\",\n // OpenGrep uses the existing SAST contract; evidence retains its scanner origin.\n opengrep: \"semgrep\",\n endor: \"endor\",\n github: \"github\",\n inspector: \"inspector\",\n blackduck: \"blackduck\",\n veracode: \"veracode\",\n sonar: \"sonar\",\n continuum: \"continuum\",\n checkmarx: \"checkmarx\",\n tenable: \"tenable\",\n} as const satisfies Record<string, LocalFindingProvider>;\n\nexport type ExternalFindingsReader = keyof typeof EXTERNAL_FINDINGS_PROVIDERS;\nexport type CloudFindingsReader = Exclude<ExternalFindingsReader, \"tenable\">;\n\nexport function requireCloudReader(\n options: ExternalFindingsReaderOptions,\n): asserts options is ExternalFindingsReaderOptions & {\n provider: CloudFindingsReader;\n} {\n if (options.provider === \"tenable\")\n throw new CodexSecurityError(\n \"Tenable findings require a local import (--to local).\",\n );\n}\n\nexport const EXTERNAL_FINDINGS_READERS = Object.keys(\n EXTERNAL_FINDINGS_PROVIDERS,\n) as ExternalFindingsReader[];\n\n/** File readers available in this SDK. Cloud supports a subset of these readers. */\nexport interface ExternalFindingsReaderOptions {\n provider: ExternalFindingsReader;\n sourceRepositoryUrl?: string;\n inspectorProjectMap?: ReadonlyMap<string, string>;\n trivyScanRoot?: string;\n}\n\n/** @internal Shared parser output, including immutable Cloud retry projections. */\nexport interface ReadExternalFindings {\n findings: ExternalFindings;\n previousFindings?: () => ExternalFindings;\n /** Preserve previous Wiz projections when resuming immutable Cloud requests. */\n publication?: ExternalPublicationInput;\n sourceRepositories?: ExternalSourceRepository[];\n}\n\n/** Repository references retained by a provider's individual finding. */\nexport function localFindingRepositories(\n provider: Provider,\n finding: ExternalFinding,\n): ExternalSourceRepository[] {\n const { evidence } = finding;\n if (provider === \"snyk\")\n return snykRepositoryUrls(evidence.source_data, {\n normalizeGitRemote: false,\n }).map((url) => ({ url }));\n if (provider === \"endor\")\n return endorRepositoryUrls(evidence.source_data).map((url) => ({ url }));\n if (provider === \"wiz\") {\n const repository = wizFindingRepository(evidence);\n return repository ? [repository] : [];\n }\n if (provider === \"github\") {\n const url = dependabotRepository(finding);\n if (url) return [{ url, platform: \"github\" }];\n }\n return [];\n}\n\n/** Repository claims retained by the Semgrep SARIF reader. */\nexport function semgrepSarifRepositories(\n { evidence }: ExternalFinding,\n allowPartialCloudUrl = false,\n): { url: string; branch?: string }[] {\n const data = evidence.source_data;\n const document = data?.[\"documentContext\"];\n const driver = data?.[\"driverContext\"];\n const partial = allowPartialCloudUrl && document === undefined;\n if (\n (!partial && (!isRecord(document) || document[\"version\"] !== \"2.1.0\")) ||\n !isRecord(driver) ||\n typeof driver[\"name\"] !== \"string\" ||\n !isSemgrepSarifDriver(driver[\"name\"]) ||\n !isRecord(data?.[\"result\"])\n )\n return [];\n const context = data[\"runContext\"];\n const references = isRecord(context)\n ? context[\"versionControlProvenance\"]\n : undefined;\n return Array.isArray(references)\n ? references.flatMap((reference) =>\n isRecord(reference) &&\n typeof reference[\"repositoryUri\"] === \"string\" &&\n reference[\"repositoryUri\"].trim()\n ? [\n {\n url: reference[\"repositoryUri\"],\n ...(!partial &&\n typeof reference[\"branch\"] === \"string\" && {\n branch: reference[\"branch\"],\n }),\n },\n ]\n : [],\n )\n : [];\n}\n\n/** A run may name a repository even when it produces no findings. */\nfunction sarifFileRepositories(\n input: unknown,\n producer: \"Endor\" | \"Semgrep\" | \"Snyk\",\n) {\n if (\n isRecord(input) &&\n input[\"version\"] === \"2.1.0\" &&\n Array.isArray(input[\"runs\"])\n )\n return input[\"runs\"].flatMap((run) => sarifRunRepositories(run, producer));\n}\n\n/** Repository claims from every project or SARIF run, even those with no findings. */\nexport function snykFileRepositories(input: unknown) {\n return (\n sarifFileRepositories(input, \"Snyk\") ?? emptySnykReportRepositories(input)\n );\n}\n\n/** @internal Read vendor evidence for the local and Cloud import entrypoints. */\nexport async function readExternalFindings(\n path: string,\n options: ExternalFindingsReaderOptions,\n target: ExternalImportTarget = \"cloud\",\n references: readonly ExternalSourceRepository[] = [],\n): Promise<ReadExternalFindings> {\n const { provider } = options;\n const url = options.sourceRepositoryUrl ?? \"\";\n // Both projections describe the same captured rows, including exclusions.\n function withReplay(\n findings: ExternalFindings,\n couldDiffer: (findings: ExternalFindings) => boolean,\n previous: () => ExternalFindings,\n ): ReadExternalFindings {\n return {\n findings,\n previousFindings:\n target === \"cloud\" && couldDiffer(findings) ? previous : undefined,\n };\n }\n if (provider === \"tenable\") {\n if (target === \"cloud\") requireCloudReader(options);\n return { findings: await readTenableFindings(path, url) };\n }\n if (provider === \"sonar\") {\n const findings = await readSonarFindings(path, url, target);\n const binding = findings.report?.[\"repositoryUrl\"];\n return {\n findings,\n sourceRepositories: typeof binding === \"string\" ? [{ url: binding }] : [],\n };\n }\n if (provider === \"opengrep\" || provider === \"checkmarx\") {\n const findings =\n provider === \"opengrep\"\n ? await readOpenGrepFindings(path, { sourceRepositoryUrl: url }, target)\n : await readCheckmarxFindings(path, url, target);\n return { findings, sourceRepositories: [{ url }] };\n }\n if (provider === \"snyk\") {\n const input = await readSnykReport(path);\n const findings = await normalizeSnykFile(input, target, references);\n return { findings, sourceRepositories: snykFileRepositories(input) };\n }\n if (provider === \"semgrep\") {\n const input = await readSemgrepReport(path);\n const findings = normalizeSemgrepFindings(\n input,\n {\n sourceRepositoryUrl: options.sourceRepositoryUrl,\n sourceRepositories: references,\n },\n target,\n );\n if (semgrepPlatformReportRepository(findings)) return { findings };\n const sourceRepositories = sarifFileRepositories(input, \"Semgrep\") ?? [];\n if (!sourceRepositories.length && options.sourceRepositoryUrl)\n sourceRepositories.push({ url: options.sourceRepositoryUrl });\n return { findings, sourceRepositories };\n }\n if (provider === \"github\")\n return { findings: await readGitHubFindings(path, target) };\n if (provider === \"wiz\") {\n const wiz =\n target === \"local\"\n ? await readLocalWizFindings(path)\n : await readVendorFindingsForPublication(path, target);\n const sourceRepositories = wiz.current.findings.flatMap((finding) =>\n localFindingRepositories(\"wiz\", finding),\n );\n return {\n findings: wiz.current,\n ...(\"legacy\" in wiz && { publication: wiz }),\n sourceRepositories: [...wiz.sourceRepositories, ...sourceRepositories],\n };\n }\n const input = await readScannerJson(path);\n if (provider === \"trivy\") {\n const args = [input, target, options.trivyScanRoot] as const;\n return withReplay(\n normalizeTrivyFindings(...args),\n needsPreviousTrivyProjection,\n () => normalizePreviousTrivyFindings(...args),\n );\n }\n if (provider === \"endor\") {\n const findings = normalizeEndorFindings(input, target);\n return {\n ...withReplay(findings, hasPreviousCloudProjection, () =>\n normalizePreviousEndorFindings(input, target),\n ),\n sourceRepositories:\n sarifFileRepositories(input, \"Endor\") ??\n findings.findings.flatMap((row) =>\n localFindingRepositories(provider, row),\n ),\n };\n }\n const [normalize, previous, couldDiffer] = (\n {\n inspector: [\n normalizeInspectorFindings,\n normalizePreviousInspectorFindings,\n () => true,\n ],\n continuum: [\n normalizeContinuumFindings,\n normalizePreviousContinuumFindings,\n () => !Array.isArray(input),\n ],\n blackduck: [\n normalizeBlackDuckFindings,\n normalizePreviousBlackDuckFindings,\n needsPreviousBlackDuckProjection,\n ],\n veracode: [\n normalizeVeracodeFindings,\n normalizePreviousVeracodeFindings,\n hasPreviousCloudProjection,\n ],\n } as const\n )[provider];\n const args = [input, url, target, options.inspectorProjectMap] as const;\n return {\n ...withReplay(normalize(...args), couldDiffer, () => previous(...args)),\n sourceRepositories: [{ url }],\n };\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CodexSecurityError } from "./errors.js";
|
|
2
|
+
import type { LocalExternalImportOptions } from "./external-findings-import.js";
|
|
2
3
|
import type { ExternalFindingEvidence } from "./external-import-models.js";
|
|
3
4
|
/** A provider occurrence and its evidence, independent of a Codex assessment. */
|
|
4
5
|
export interface ExternalFinding {
|
|
@@ -8,8 +9,9 @@ export interface ExternalFinding {
|
|
|
8
9
|
/** Repository provenance retained by a reader outside the published evidence. */
|
|
9
10
|
export interface ExternalSourceRepository {
|
|
10
11
|
url: string;
|
|
11
|
-
platform?: "github";
|
|
12
|
+
platform?: "github" | "gitlab";
|
|
12
13
|
}
|
|
14
|
+
export declare function snapshotSourceRepositories(references?: readonly ExternalSourceRepository[]): ExternalSourceRepository[];
|
|
13
15
|
export interface ExternalFindings {
|
|
14
16
|
read: number;
|
|
15
17
|
/** Reader-retained run metadata, including diagnostics for empty reports. */
|
|
@@ -21,14 +23,26 @@ export interface ExternalFindings {
|
|
|
21
23
|
reason: string;
|
|
22
24
|
}[];
|
|
23
25
|
}
|
|
26
|
+
export declare function hasNoExternalRecords(input: ExternalFindings): boolean;
|
|
27
|
+
/** Classify a reader selection before deciding whether to store, publish, or report it. */
|
|
28
|
+
export declare function externalImportDisposition(input: ExternalFindings): "ready" | "empty" | "excluded" | "failed";
|
|
29
|
+
/** No findings can be imported. The selection retains every reader exclusion and diagnostic. */
|
|
30
|
+
export declare class NoPublishableFindingsError extends CodexSecurityError {
|
|
31
|
+
readonly selection: ExternalFindings;
|
|
32
|
+
readonly summary: string;
|
|
33
|
+
constructor(selection: ExternalFindings);
|
|
34
|
+
}
|
|
35
|
+
export declare function reportForJson(report: ExternalFindings["report"]): Record<string, unknown> | undefined;
|
|
36
|
+
export declare const nativeErrorStackGetter: (() => any) | undefined;
|
|
24
37
|
/** Capture the caller's import settings before reading an export or resolving its destination. */
|
|
25
|
-
export declare function snapshotImportOptions<P extends
|
|
38
|
+
export declare function snapshotImportOptions<P extends LocalExternalImportOptions["provider"]>({ repository, provider, sourceKey, sourceRepositoryUrl, trivyScanRoot, inspectorProjectMap, }: LocalExternalImportOptions & {
|
|
26
39
|
provider: P;
|
|
27
40
|
}): {
|
|
28
41
|
repository: string;
|
|
29
42
|
provider: P;
|
|
30
43
|
sourceKey: string;
|
|
31
44
|
sourceRepositoryUrl: string | undefined;
|
|
45
|
+
trivyScanRoot: string | undefined;
|
|
32
46
|
inspectorProjectMap: Map<string, string> | undefined;
|
|
33
47
|
};
|
|
34
48
|
//# sourceMappingURL=external-findings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-findings.d.ts","sourceRoot":"","sources":["../src/external-findings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"external-findings.d.ts","sourceRoot":"","sources":["../src/external-findings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAQhF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,iFAAiF;AACjF,MAAM,WAAW,eAAe;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,uBAAuB,CAAC;CACnC;AAED,iFAAiF;AACjF,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAChC;AAED,wBAAgB,0BAA0B,CACxC,UAAU,GAAE,SAAS,wBAAwB,EAAO,GACnD,wBAAwB,EAAE,CAE5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;QACjC,MAAM,EAAE,MAAM,CA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