@openai/codex-security 0.8.3 → 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 +192 -151
- package/_bundled_plugin/.mcp.json +5 -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 +5 -2
- 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/default-severity-rubric.md +9 -4
- package/_bundled_plugin/references/final-report.md +5 -3
- package/_bundled_plugin/references/finding-detail-fields.md +18 -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/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 +165 -342
- package/_bundled_plugin/scripts/filesystem_identity.py +1 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +153 -227
- package/_bundled_plugin/scripts/finding_preview.py +20 -0
- 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 +11 -0
- package/_bundled_plugin/scripts/read_codex_session.mjs +21 -0
- package/_bundled_plugin/scripts/report_projection.py +81 -43
- 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 +7 -1
- package/_bundled_plugin/scripts/windows_scan_local_files.py +388 -17
- 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 +30 -51
- 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 +9 -17
- 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 +30 -12
- package/_bundled_plugin/scripts/workbench_constants.py +10 -0
- package/_bundled_plugin/scripts/workbench_coverage_receipts.py +3 -3
- package/_bundled_plugin/scripts/workbench_db.py +369 -137
- 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 +4 -0
- package/_bundled_plugin/scripts/workbench_native_indexes.py +12 -12
- 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 +13 -0
- package/_bundled_plugin/scripts/workbench_saved_results.py +132 -77
- package/_bundled_plugin/scripts/workbench_scan_history.py +117 -55
- package/_bundled_plugin/scripts/workbench_scan_start.py +83 -24
- package/_bundled_plugin/scripts/workbench_scan_usage.py +644 -68
- package/_bundled_plugin/scripts/workbench_schema.py +44 -55
- package/_bundled_plugin/scripts/workbench_setup.py +13 -1
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +13 -0
- package/_bundled_plugin/scripts/workbench_source_scopes.py +18 -0
- package/_bundled_plugin/scripts/workbench_target.py +127 -56
- package/_bundled_plugin/scripts/workbench_target_state.py +3 -0
- package/_bundled_plugin/scripts/workbench_validation.py +43 -3
- package/_bundled_plugin/shared/workbench-history-repairs.json +19 -23
- package/_bundled_plugin/shared/workbench-migrations.json +34 -0
- package/_bundled_plugin/skills/cloud-findings/SKILL.md +5 -5
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +7 -50
- package/_bundled_plugin/skills/fix-finding/SKILL.md +1 -1
- package/_bundled_plugin/skills/publish-findings/SKILL.md +32 -25
- package/_bundled_plugin/skills/publish-findings/references/checkmarx-import.md +37 -0
- package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +3 -3
- package/_bundled_plugin/skills/publish-findings/scripts/collect_checkmarx.py +464 -0
- package/_bundled_plugin/skills/threat-model-visualize/scripts/build_explorer.py +22 -1
- package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +6 -2
- package/dist/api.d.ts +39 -4
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +774 -292
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +4 -6
- 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.map +1 -1
- package/dist/blackduck-findings.js +35 -20
- package/dist/blackduck-findings.js.map +1 -1
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +4 -4
- 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 +1 -9
- package/dist/classify-severity-records.d.ts.map +1 -1
- package/dist/classify-severity-records.js +3 -13
- package/dist/classify-severity-records.js.map +1 -1
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +2 -4
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli.d.ts +11 -5
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1734 -1238
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.js +2 -2
- package/dist/cloud-publish.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 +27 -2
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +100 -66
- package/dist/config.js.map +1 -1
- package/dist/continuum-findings.d.ts.map +1 -1
- package/dist/continuum-findings.js +80 -12
- package/dist/continuum-findings.js.map +1 -1
- package/dist/contract-values.d.ts +2 -0
- package/dist/contract-values.d.ts.map +1 -1
- package/dist/contract-values.js +12 -9
- package/dist/contract-values.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 -112
- package/dist/cost-model.js.map +1 -1
- package/dist/cost.d.ts +42 -3
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +483 -104
- 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/deduplication/local.d.ts +2 -2
- package/dist/deduplication/local.d.ts.map +1 -1
- package/dist/deduplication/local.js +2 -2
- package/dist/deduplication/local.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 +2 -0
- package/dist/deep-scan.d.ts.map +1 -1
- package/dist/deep-scan.js +28 -4
- package/dist/deep-scan.js.map +1 -1
- package/dist/default-severity-rubric.d.ts +1 -1
- package/dist/default-severity-rubric.d.ts.map +1 -1
- package/dist/default-severity-rubric.js +1 -1
- 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 +103 -45
- 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 +8 -1
- 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 +7 -6
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts +7 -5
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +337 -89
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +8 -6
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +1318 -258
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +20 -2
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +148 -66
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-findings.d.ts +15 -3
- package/dist/external-findings.d.ts.map +1 -1
- package/dist/external-findings.js +42 -1
- package/dist/external-findings.js.map +1 -1
- package/dist/external-import-contract.d.ts +5 -1
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +23 -9
- 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/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/github-advisories.d.ts.map +1 -1
- package/dist/github-advisories.js +0 -2
- package/dist/github-advisories.js.map +1 -1
- package/dist/github-dependabot-findings.d.ts.map +1 -1
- package/dist/github-dependabot-findings.js +15 -4
- 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 +55 -30
- package/dist/github-findings.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.map +1 -1
- package/dist/hosted-scan.js +16 -11
- 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 +18 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/inspector-findings.d.ts.map +1 -1
- package/dist/inspector-findings.js +47 -65
- package/dist/inspector-findings.js.map +1 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +68 -5
- package/dist/knowledge-base.js.map +1 -1
- package/dist/local-git-metadata.d.ts +1 -1
- package/dist/local-git-metadata.d.ts.map +1 -1
- package/dist/local-git-metadata.js +1 -2
- package/dist/local-git-metadata.js.map +1 -1
- package/dist/multiscan.d.ts +6 -4
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +138 -65
- 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 +17 -13
- 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/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 +97 -2
- package/dist/private-finding-import.d.ts.map +1 -1
- package/dist/private-finding-import.js +58 -34
- package/dist/private-finding-import.js.map +1 -1
- package/dist/provider-profile.d.ts +1 -1
- package/dist/provider-profile.d.ts.map +1 -1
- package/dist/provider-profile.js +8 -1
- 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/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 +2 -0
- package/dist/reader-selection.d.ts.map +1 -1
- package/dist/reader-selection.js +8 -0
- package/dist/reader-selection.js.map +1 -1
- package/dist/remediation.d.ts +1 -4
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +3 -7
- 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 +4 -0
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +1 -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 +20 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +313 -110
- 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 +141 -56
- 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 +60 -15
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +6 -6
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +75 -42
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-executor.d.ts +10 -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 +9 -19
- 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 +20 -2
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +200 -8
- package/dist/scanner-import.js.map +1 -1
- package/dist/scanner-repository-url.d.ts +4 -1
- package/dist/scanner-repository-url.d.ts.map +1 -1
- package/dist/scanner-repository-url.js +10 -6
- package/dist/scanner-repository-url.js.map +1 -1
- 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 +107 -43
- 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 +207 -6
- package/dist/semgrep-platform-findings.d.ts.map +1 -1
- package/dist/semgrep-platform-findings.js +983 -103
- package/dist/semgrep-platform-findings.js.map +1 -1
- 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/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 +93 -70
- 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.map +1 -1
- package/dist/sonar-collector.js +0 -3
- package/dist/sonar-collector.js.map +1 -1
- package/dist/sonar-import.d.ts.map +1 -1
- package/dist/sonar-import.js +2 -4
- package/dist/sonar-import.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 +2 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +56 -20
- 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-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.js +1 -1
- package/dist/validation-records.js.map +1 -1
- package/dist/veracode-findings.d.ts +2 -0
- package/dist/veracode-findings.d.ts.map +1 -1
- package/dist/veracode-findings.js +49 -11
- package/dist/veracode-findings.js.map +1 -1
- 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 +26 -1
- package/dist/windows-path.js.map +1 -1
- package/dist/wiz-findings.d.ts +4 -0
- package/dist/wiz-findings.d.ts.map +1 -1
- package/dist/wiz-findings.js +57 -3
- package/dist/wiz-findings.js.map +1 -1
- package/docs/classify-severity-records.md +27 -12
- package/docs/cli.md +497 -550
- package/docs/dedupe-records.md +44 -24
- package/docs/findings-service.md +66 -39
- package/docs/hosted-remediation.md +14 -7
- package/docs/hosted-scans.md +50 -42
- package/docs/telemetry.md +236 -0
- package/docs/validate-records.md +78 -44
- package/package.json +18 -15
- package/schemas/external-findings.schema.json +3 -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/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 -155
- package/dist/finding-normalization.js.map +0 -1
package/dist/endor-findings.js
CHANGED
|
@@ -1,40 +1,86 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { markPreviousCloudProjection } from "./reader-selection.js";
|
|
2
|
+
import { validateEnrichedExternalEvidence, validateExternalEvidence, } from "./external-import-contract.js";
|
|
3
|
+
import { asRecord } from "./record.js";
|
|
4
|
+
import { array, normalizeRecords, readScannerJson, record, relativePath, reportableScannerSeverity, requiredText, sarifRunRepositories, sarifRunResults, strings, readSarifRuns, text, validateSarifRuleReference, } from "./scanner-import.js";
|
|
4
5
|
/** @internal Repository claims retained in the adapter's original SARIF context. */
|
|
5
|
-
export function endorRepositoryUrls(sourceData) {
|
|
6
|
-
|
|
7
|
-
return [];
|
|
8
|
-
const run = sourceData["runContext"];
|
|
6
|
+
export function endorRepositoryUrls(sourceData, retainedUrlsOnly = false) {
|
|
7
|
+
const run = asRecord(sourceData)?.["runContext"];
|
|
9
8
|
if (run == null)
|
|
10
9
|
return [];
|
|
11
|
-
|
|
10
|
+
if (retainedUrlsOnly) {
|
|
11
|
+
// Historical projections can retain opaque run metadata alongside explicit URLs.
|
|
12
|
+
const entries = asRecord(run)?.["versionControlProvenance"];
|
|
13
|
+
if (!Array.isArray(entries))
|
|
14
|
+
return [];
|
|
15
|
+
return entries
|
|
16
|
+
.map((entry) => asRecord(entry)?.["repositoryUri"])
|
|
17
|
+
.filter((url) => typeof url === "string");
|
|
18
|
+
}
|
|
19
|
+
return sarifRunRepositories(run, "Endor").map((ref) => ref.url);
|
|
20
|
+
}
|
|
21
|
+
function positiveCount(value) {
|
|
22
|
+
return ((typeof value === "number" || typeof value === "string") &&
|
|
23
|
+
Number(value) > 0);
|
|
24
|
+
}
|
|
25
|
+
function endorListObjects(root) {
|
|
26
|
+
const list = record(root["list"], "Endor list");
|
|
27
|
+
const response = record(list["response"] ?? {}, "Endor list response");
|
|
28
|
+
const { next_page_id: nextId, next_page_token: token, total_size: total, } = response;
|
|
29
|
+
if (nextId != null && typeof nextId !== "string")
|
|
30
|
+
throw new Error("Endor next_page_id must be a string.");
|
|
31
|
+
if (text(nextId) ||
|
|
32
|
+
(token != null && token !== 0 && token !== "0" && token !== ""))
|
|
33
|
+
throw new Error("The Endor list response has another page. Supply a complete export or an explicitly selected array.");
|
|
34
|
+
const values = array(list["objects"] ?? [], "Endor list.objects");
|
|
35
|
+
if (values.length)
|
|
36
|
+
return values;
|
|
37
|
+
// Protobuf can omit an empty repeated field. Recognize only its known
|
|
38
|
+
// pagination envelope; don't mistake an unrecognized payload for no matches.
|
|
39
|
+
if (positiveCount(total) ||
|
|
40
|
+
(list["objects"] == null &&
|
|
41
|
+
(Object.keys(list).some((key) => key !== "response" && key !== "objects") ||
|
|
42
|
+
Object.keys(response).some((key) => !["next_page_token", "next_page_id"].includes(key) &&
|
|
43
|
+
!(key === "total_size" && (total === 0 || total === "0"))))))
|
|
44
|
+
throw new Error("Expected Endor list.objects in the finding export.");
|
|
45
|
+
const { count } = record(root["count_response"] ?? {}, "Endor count response");
|
|
46
|
+
const { groups } = record(root["group_response"] ?? {}, "Endor group response");
|
|
47
|
+
if (positiveCount(count) ||
|
|
48
|
+
(groups != null && Object.keys(record(groups, "Endor groups")).length))
|
|
49
|
+
throw new Error("The Endor report contains a summary without finding objects. Supply the complete finding export.");
|
|
50
|
+
return values;
|
|
12
51
|
}
|
|
13
52
|
/** Saved Endor Finding objects, an array, or an unmasked ListFindingsResponse. */
|
|
14
53
|
export function normalizeEndorFindings(input, target = "cloud") {
|
|
54
|
+
return normalizeReport(input, target, false);
|
|
55
|
+
}
|
|
56
|
+
const reducedReports = new WeakSet();
|
|
57
|
+
/** A native upload would ask the worker to reconstruct fields that Cloud could not accept. */
|
|
58
|
+
export function requiresStructuredEndorReport(findings) {
|
|
59
|
+
return reducedReports.has(findings);
|
|
60
|
+
}
|
|
61
|
+
/** @internal Reproduce the selection from before malware and fully qualified package mapping. */
|
|
62
|
+
export function normalizePreviousEndorFindings(input, target = "cloud") {
|
|
63
|
+
return normalizeReport(input, target, true);
|
|
64
|
+
}
|
|
65
|
+
function normalizeReport(input, target, previous) {
|
|
15
66
|
const root = Array.isArray(input) ? null : record(input, "Endor report");
|
|
16
67
|
if (root?.["version"] === "2.1.0" && root["runs"] !== undefined)
|
|
17
68
|
return normalizeEndorSarif(root, target);
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const response = record(list["response"] ?? {}, "Endor list response");
|
|
21
|
-
const token = response["next_page_token"];
|
|
22
|
-
if (text(response["next_page_id"]) ||
|
|
23
|
-
(token != null && token !== 0 && token !== "0" && token !== "")) {
|
|
24
|
-
throw new Error("The Endor list response has another page. Supply a complete export or an explicitly selected array.");
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
const values = list
|
|
28
|
-
? array(list["objects"] ?? [], "Endor list.objects")
|
|
69
|
+
const values = root?.["list"] !== undefined
|
|
70
|
+
? endorListObjects(root)
|
|
29
71
|
: Array.isArray(input)
|
|
30
72
|
? input
|
|
31
73
|
: [input];
|
|
32
|
-
|
|
74
|
+
let changed = false;
|
|
75
|
+
let reduced = false;
|
|
76
|
+
const result = normalizeRecords(values, (value) => {
|
|
33
77
|
const finding = record(value, "Endor finding");
|
|
34
78
|
const meta = record(finding["meta"], "Endor meta");
|
|
35
79
|
const spec = record(finding["spec"], "Endor spec");
|
|
36
80
|
requiredText(spec["project_uuid"], "Endor project_uuid");
|
|
37
|
-
const
|
|
81
|
+
const bareName = text(spec["target_dependency_name"]);
|
|
82
|
+
const name = bareName ??
|
|
83
|
+
(previous ? null : text(spec["target_dependency_package_name"]));
|
|
38
84
|
const paths = [
|
|
39
85
|
...new Set(strings(spec["dependency_file_paths"])
|
|
40
86
|
.map(relativePath)
|
|
@@ -66,12 +112,15 @@ export function normalizeEndorFindings(input, target = "cloud") {
|
|
|
66
112
|
const vulnerability = record(metadata["vulnerability"] ?? {}, "Endor vulnerability");
|
|
67
113
|
const advisory = text(record(vulnerability["meta"] ?? {}, "Vulnerability meta")["name"]);
|
|
68
114
|
const aliases = strings(record(vulnerability["spec"] ?? {}, "Vulnerability spec")["aliases"]);
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
115
|
+
const vulnerabilityIds = [
|
|
116
|
+
...new Set([...(advisory ? [advisory] : []), ...aliases]),
|
|
117
|
+
];
|
|
118
|
+
const malware = previous ? undefined : asRecord(metadata["malware"]);
|
|
119
|
+
const advisories = new Set([
|
|
120
|
+
...vulnerabilityIds,
|
|
121
|
+
...strings([asRecord(malware?.["meta"])?.["name"]]),
|
|
122
|
+
...strings(asRecord(malware?.["spec"])?.["aliases"]),
|
|
123
|
+
]);
|
|
75
124
|
// A recommended version can refer to an introducing dependency; retain it in source_data.
|
|
76
125
|
const packages = name
|
|
77
126
|
? (paths.length ? paths : [null]).map((path) => ({
|
|
@@ -86,7 +135,11 @@ export function normalizeEndorFindings(input, target = "cloud") {
|
|
|
86
135
|
: [];
|
|
87
136
|
const context = record(finding["context"] ?? {}, "Endor context");
|
|
88
137
|
const updated = text(meta["update_time"]);
|
|
89
|
-
|
|
138
|
+
const malwareIds = advisories.size > vulnerabilityIds.length
|
|
139
|
+
? { advisory_ids: [...advisories] }
|
|
140
|
+
: undefined;
|
|
141
|
+
const fallbackPackage = name !== bareName ? { packages } : undefined;
|
|
142
|
+
const evidence = validateEnrichedExternalEvidence({
|
|
90
143
|
title: requiredText(meta["name"], "Endor finding title"),
|
|
91
144
|
description: [
|
|
92
145
|
text(spec["summary"]),
|
|
@@ -95,33 +148,38 @@ export function normalizeEndorFindings(input, target = "cloud") {
|
|
|
95
148
|
]
|
|
96
149
|
.filter(Boolean)
|
|
97
150
|
.join("\n\n") || text(meta["description"]),
|
|
98
|
-
severity,
|
|
151
|
+
severity: reportableScannerSeverity(text(spec["level"])?.replace(/^FINDING_LEVEL_/u, "")),
|
|
99
152
|
branch: context["type"] === "CONTEXT_TYPE_REF" ? text(context["id"]) : null,
|
|
100
153
|
code_revision: text(record(spec["source_code_version"] ?? {}, "Endor source code version")["sha"]),
|
|
101
154
|
source_updated_at: updated === null ? null : Math.floor(Date.parse(updated) / 1000),
|
|
102
|
-
advisory_ids:
|
|
103
|
-
|
|
104
|
-
],
|
|
105
|
-
packages,
|
|
155
|
+
advisory_ids: vulnerabilityIds,
|
|
156
|
+
packages: bareName ? packages : [],
|
|
106
157
|
locations,
|
|
107
158
|
source_data: structuredClone(finding),
|
|
108
|
-
}, target);
|
|
159
|
+
}, target, malwareIds && fallbackPackage && { ...malwareIds, ...fallbackPackage }, malwareIds, fallbackPackage);
|
|
160
|
+
const acceptedIds = evidence.advisory_ids.length;
|
|
161
|
+
const acceptedPackages = evidence.packages.length;
|
|
162
|
+
changed ||=
|
|
163
|
+
acceptedIds > vulnerabilityIds.length ||
|
|
164
|
+
(!bareName && acceptedPackages > 0);
|
|
165
|
+
reduced ||=
|
|
166
|
+
acceptedIds < advisories.size || acceptedPackages < packages.length;
|
|
167
|
+
return evidence;
|
|
109
168
|
}, (value) => requiredText(record(value, "Endor finding")["uuid"], "Endor finding uuid"), target);
|
|
169
|
+
if (target === "cloud") {
|
|
170
|
+
if (changed)
|
|
171
|
+
markPreviousCloudProjection(result);
|
|
172
|
+
if (reduced)
|
|
173
|
+
reducedReports.add(result);
|
|
174
|
+
}
|
|
175
|
+
return result;
|
|
110
176
|
}
|
|
111
177
|
/** Endor's documented SARIF producer uses properties.finding-uuid, not its rule name. */
|
|
112
178
|
export function normalizeEndorSarif(input, target = "cloud") {
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
throw new Error("Expected Endor SARIF 2.1.0.");
|
|
116
|
-
const entries = array(document["runs"], "SARIF runs").flatMap((value) => {
|
|
117
|
-
const run = record(value, "SARIF run");
|
|
118
|
-
const tool = record(run["tool"], "SARIF tool");
|
|
119
|
-
const driver = record(tool["driver"], "SARIF driver");
|
|
120
|
-
if (driver["name"] !== "endorctl")
|
|
179
|
+
const entries = readSarifRuns(input, "Endor", (context) => {
|
|
180
|
+
if (context.driver["name"] !== "endorctl")
|
|
121
181
|
throw new Error("Expected the endorctl SARIF producer.");
|
|
122
|
-
|
|
123
|
-
throw new Error("Use a self-contained Endor SARIF report.");
|
|
124
|
-
return sarifRunResults(document, run, tool, driver, "Endor");
|
|
182
|
+
return sarifRunResults(context, "Endor");
|
|
125
183
|
});
|
|
126
184
|
return normalizeRecords(entries, ({ result: value, context }) => {
|
|
127
185
|
const result = record(value, "Endor result");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endor-findings.js","sourceRoot":"","sources":["../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,CAAC,EAC5C,yBAAyB,CAC1B,CAAC,cAAc,CAAC,EACjB,oBAAoB,CACrB,EACH,MAAM,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAY,EACZ,MAAM,GAAyB,OAAO;IAEtC,OAAO,sBAAsB,CAAC,MAAM,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;AACrE,CAAC","sourcesContent":["import type { ExternalImportTarget } from \"./external-import-contract.js\";\nimport { validateExternalEvidence } from \"./external-import-contract.js\";\nimport type { ExternalFindings } from \"./external-findings.js\";\nimport { isRecord } from \"./record.js\";\nimport {\n array,\n hasSarifExternalPropertyReferences,\n normalizeRecords,\n readScannerJson,\n record,\n relativePath,\n requiredText,\n sarifRunResults,\n strings,\n text,\n validateSarifRuleReference,\n} from \"./scanner-import.js\";\n\n/** @internal Repository claims retained in the adapter's original SARIF context. */\nexport function endorRepositoryUrls(sourceData: unknown): string[] {\n if (!isRecord(sourceData)) return [];\n const run = sourceData[\"runContext\"];\n if (run == null) return [];\n return array(\n record(run, \"Endor run context\")[\"versionControlProvenance\"] ?? [],\n \"Endor version control provenance\",\n ).map((entry) =>\n requiredText(\n record(entry, \"Endor repository provenance\")[\"repositoryUri\"],\n \"Endor repository URI\",\n ),\n );\n}\n\n/** Saved Endor Finding objects, an array, or an unmasked ListFindingsResponse. */\nexport function normalizeEndorFindings(\n input: unknown,\n target: ExternalImportTarget = \"cloud\",\n): ExternalFindings {\n const root = Array.isArray(input) ? null : record(input, \"Endor report\");\n if (root?.[\"version\"] === \"2.1.0\" && root[\"runs\"] !== undefined)\n return normalizeEndorSarif(root, target);\n const list =\n root?.[\"list\"] === undefined ? null : record(root[\"list\"], \"Endor list\");\n if (list) {\n const response = record(list[\"response\"] ?? {}, \"Endor list response\");\n const token = response[\"next_page_token\"];\n if (\n text(response[\"next_page_id\"]) ||\n (token != null && token !== 0 && token !== \"0\" && token !== \"\")\n ) {\n throw new Error(\n \"The Endor list response has another page. Supply a complete export or an explicitly selected array.\",\n );\n }\n }\n const values = list\n ? array(list[\"objects\"] ?? [], \"Endor list.objects\")\n : Array.isArray(input)\n ? input\n : [input];\n return normalizeRecords(\n values,\n (value) => {\n const finding = record(value, \"Endor finding\");\n const meta = record(finding[\"meta\"], \"Endor meta\");\n const spec = record(finding[\"spec\"], \"Endor spec\");\n requiredText(spec[\"project_uuid\"], \"Endor project_uuid\");\n const name = text(spec[\"target_dependency_name\"]);\n const paths = [\n ...new Set(\n strings(spec[\"dependency_file_paths\"])\n .map(relativePath)\n .filter((p): p is string => p !== null),\n ),\n ];\n const metadata = record(\n spec[\"finding_metadata\"] ?? {},\n \"Endor finding_metadata\",\n );\n const codeLocations = [\"sast_data\", \"ai_sast_data\"].flatMap((field) => {\n const data = record(metadata[field] ?? {}, `Endor ${field}`);\n const location = record(\n data[\"location\"] ?? {},\n `Endor ${field} location`,\n );\n const path = relativePath(location[\"relative_path\"]);\n if (path === null) return [];\n const line = location[\"start_line\"];\n return [\n {\n path,\n line:\n typeof line === \"number\" && Number.isSafeInteger(line) && line > 0\n ? line\n : null,\n },\n ];\n });\n const locations = [\n ...paths\n .filter(\n (path) => !codeLocations.some((location) => location.path === path),\n )\n .map((path) => ({ path })),\n ...new Map(\n codeLocations.map((location) => [JSON.stringify(location), location]),\n ).values(),\n ];\n const vulnerability = record(\n metadata[\"vulnerability\"] ?? {},\n \"Endor vulnerability\",\n );\n const advisory = text(\n record(vulnerability[\"meta\"] ?? {}, \"Vulnerability meta\")[\"name\"],\n );\n const aliases = strings(\n record(vulnerability[\"spec\"] ?? {}, \"Vulnerability spec\")[\"aliases\"],\n );\n const level = text(spec[\"level\"])\n ?.replace(/^FINDING_LEVEL_/u, \"\")\n .toLowerCase();\n const severity =\n level && [\"critical\", \"high\", \"medium\", \"low\"].includes(level)\n ? level\n : \"unknown\";\n // A recommended version can refer to an introducing dependency; retain it in source_data.\n const packages = name\n ? (paths.length ? paths : [null]).map((path) => ({\n name,\n ecosystem:\n text(spec[\"ecosystem\"])\n ?.replace(/^ECOSYSTEM_/u, \"\")\n .toLowerCase() ?? null,\n installed_version: text(spec[\"target_dependency_version\"]),\n manifest_path: path,\n fixed_versions: [],\n }))\n : [];\n const context = record(finding[\"context\"] ?? {}, \"Endor context\");\n const updated = text(meta[\"update_time\"]);\n return validateExternalEvidence(\n {\n title: requiredText(meta[\"name\"], \"Endor finding title\"),\n description:\n [\n text(spec[\"summary\"]),\n text(spec[\"explanation\"]),\n text(spec[\"remediation\"]),\n ]\n .filter(Boolean)\n .join(\"\\n\\n\") || text(meta[\"description\"]),\n severity,\n branch:\n context[\"type\"] === \"CONTEXT_TYPE_REF\" ? text(context[\"id\"]) : null,\n code_revision: text(\n record(\n spec[\"source_code_version\"] ?? {},\n \"Endor source code version\",\n )[\"sha\"],\n ),\n source_updated_at:\n updated === null ? null : Math.floor(Date.parse(updated) / 1000),\n advisory_ids: [\n ...new Set([...(advisory ? [advisory] : []), ...aliases]),\n ],\n packages,\n locations,\n source_data: structuredClone(finding),\n },\n target,\n );\n },\n (value) =>\n requiredText(\n record(value, \"Endor finding\")[\"uuid\"],\n \"Endor finding uuid\",\n ),\n target,\n );\n}\n\n/** Endor's documented SARIF producer uses properties.finding-uuid, not its rule name. */\nexport function normalizeEndorSarif(\n input: unknown,\n target: ExternalImportTarget = \"cloud\",\n): ExternalFindings {\n const document = record(input, \"Endor SARIF\");\n if (document[\"version\"] !== \"2.1.0\")\n throw new Error(\"Expected Endor SARIF 2.1.0.\");\n const entries = array(document[\"runs\"], \"SARIF runs\").flatMap((value) => {\n const run = record(value, \"SARIF run\");\n const tool = record(run[\"tool\"], \"SARIF tool\");\n const driver = record(tool[\"driver\"], \"SARIF driver\");\n if (driver[\"name\"] !== \"endorctl\")\n throw new Error(\"Expected the endorctl SARIF producer.\");\n if (\n hasSarifExternalPropertyReferences(run[\"externalPropertyFileReferences\"])\n )\n throw new Error(\"Use a self-contained Endor SARIF report.\");\n return sarifRunResults(document, run, tool, driver, \"Endor\");\n });\n return normalizeRecords(\n entries,\n ({ result: value, context }) => {\n const result = record(value, \"Endor result\");\n const properties = record(\n result[\"properties\"],\n \"Endor result properties\",\n );\n requiredText(properties[\"project-uuid\"], \"Endor project-uuid\");\n const ruleId = requiredText(result[\"ruleId\"], \"Endor ruleId\");\n const selectedRule = context.rulesById.get(ruleId);\n if (!selectedRule)\n throw new Error(\n \"Endor result must reference exactly one rule in its run.\",\n );\n const { rule } = selectedRule;\n validateSarifRuleReference(result, ruleId, selectedRule, \"Endor\");\n const message = record(result[\"message\"], \"Endor message\");\n const short = record(\n rule[\"shortDescription\"] ?? {},\n \"Endor shortDescription\",\n );\n const full = record(\n rule[\"fullDescription\"] ?? {},\n \"Endor fullDescription\",\n );\n const help = record(rule[\"help\"] ?? {}, \"Endor help\");\n const hasCodeLocations = strings(properties[\"categories\"]).some(\n (category) => category === \"SAST\" || category === \"SECRETS\",\n );\n const locations = array(\n result[\"locations\"] ?? [],\n \"Endor locations\",\n ).flatMap((v) => {\n const physical = record(\n record(v, \"Endor location\")[\"physicalLocation\"] ?? {},\n \"Physical location\",\n );\n const artifact = record(\n physical[\"artifactLocation\"] ?? {},\n \"Artifact location\",\n );\n if (\n artifact[\"index\"] !== undefined ||\n artifact[\"uriBaseId\"] !== undefined\n )\n return [];\n const uri = text(artifact[\"uri\"]);\n if (uri === null || /^[A-Za-z][A-Za-z0-9+.-]*:/u.test(uri)) return [];\n let path: string | null;\n try {\n path = relativePath(decodeURIComponent(uri));\n } catch {\n return [];\n }\n if (path === null) return [];\n const line = hasCodeLocations\n ? record(physical[\"region\"] ?? {}, \"Endor region\")[\"startLine\"]\n : null;\n return [\n {\n path,\n line:\n typeof line === \"number\" && Number.isSafeInteger(line) && line > 0\n ? line\n : null,\n },\n ];\n });\n return validateExternalEvidence(\n {\n title: text(short[\"text\"]) ?? text(rule[\"name\"]) ?? ruleId,\n url: text(properties[\"finding-url\"]),\n description: [\n text(message[\"markdown\"]) ?? text(message[\"text\"]),\n text(full[\"text\"]),\n text(help[\"markdown\"]) ?? text(help[\"text\"]),\n ]\n .filter(Boolean)\n .join(\"\\n\\n\"),\n // Diagnostic level and CVSS are not Endor's finding severity. Keep both as source evidence.\n severity: \"unknown\",\n locations: [\n ...new Map(\n locations.map((location) => [JSON.stringify(location), location]),\n ).values(),\n ],\n source_data: context.sourceData(result, rule),\n },\n target,\n );\n },\n ({ result }) =>\n requiredText(\n record(\n record(result, \"Endor result\")[\"properties\"],\n \"Endor result properties\",\n )[\"finding-uuid\"],\n \"Endor finding-uuid\",\n ),\n target,\n );\n}\n\nexport async function readEndorFindings(\n path: string,\n target: ExternalImportTarget = \"cloud\",\n): Promise<ExternalFindings> {\n return normalizeEndorFindings(await readScannerJson(path), target);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"endor-findings.js","sourceRoot":"","sources":["../src/endor-findings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAEL,gCAAgC,EAChC,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EACL,KAAK,EACL,gBAAgB,EAChB,eAAe,EACf,MAAM,EACN,YAAY,EACZ,yBAAyB,EACzB,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,OAAO,EACP,aAAa,EACb,IAAI,EACJ,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAE7B,oFAAoF;AACpF,MAAM,UAAU,mBAAmB,CACjC,UAAmB,EACnB,gBAAgB,GAAG,KAAK;IAExB,MAAM,GAAG,GAAG,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC;IACjD,IAAI,GAAG,IAAI,IAAI;QAAE,OAAO,EAAE,CAAC;IAC3B,IAAI,gBAAgB,EAAE,CAAC;QACrB,iFAAiF;QACjF,MAAM,OAAO,GAAG,QAAQ,CAA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AAC,YAAY,CAAC,EAC5C,yBAAyB,CAC1B,CAAC,cAAc,CAAC,EACjB,oBAAoB,CACrB,EACH,MAAM,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAY,EACZ,MAAM,GAAyB,OAAO;IAEtC,OAAO,sBAAsB,CAAC,MAAM,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;AACrE,CAAC","sourcesContent":["import { markPreviousCloudProjection } from \"./reader-selection.js\";\nimport {\n type ExternalImportTarget,\n validateEnrichedExternalEvidence,\n validateExternalEvidence,\n} from \"./external-import-contract.js\";\nimport type { ExternalFindings } from \"./external-findings.js\";\nimport { asRecord } from \"./record.js\";\nimport {\n array,\n normalizeRecords,\n readScannerJson,\n record,\n relativePath,\n reportableScannerSeverity,\n requiredText,\n sarifRunRepositories,\n sarifRunResults,\n strings,\n readSarifRuns,\n text,\n validateSarifRuleReference,\n} from \"./scanner-import.js\";\n\n/** @internal Repository claims retained in the adapter's original SARIF context. */\nexport function endorRepositoryUrls(\n sourceData: unknown,\n retainedUrlsOnly = false,\n): string[] {\n const run = asRecord(sourceData)?.[\"runContext\"];\n if (run == null) return [];\n if (retainedUrlsOnly) {\n // Historical projections can retain opaque run metadata alongside explicit URLs.\n const entries = asRecord(run)?.[\"versionControlProvenance\"];\n if (!Array.isArray(entries)) return [];\n return entries\n .map((entry) => asRecord(entry)?.[\"repositoryUri\"])\n .filter((url) => typeof url === \"string\");\n }\n return sarifRunRepositories(run, \"Endor\").map((ref) => ref.url);\n}\n\nfunction positiveCount(value: unknown): boolean {\n return (\n (typeof value === \"number\" || typeof value === \"string\") &&\n Number(value) > 0\n );\n}\n\nfunction endorListObjects(root: Record<string, unknown>): unknown[] {\n const list = record(root[\"list\"], \"Endor list\");\n const response = record(list[\"response\"] ?? {}, \"Endor list response\");\n const {\n next_page_id: nextId,\n next_page_token: token,\n total_size: total,\n } = response;\n if (nextId != null && typeof nextId !== \"string\")\n throw new Error(\"Endor next_page_id must be a string.\");\n if (\n text(nextId) ||\n (token != null && token !== 0 && token !== \"0\" && token !== \"\")\n )\n throw new Error(\n \"The Endor list response has another page. Supply a complete export or an explicitly selected array.\",\n );\n const values = array(list[\"objects\"] ?? [], \"Endor list.objects\");\n if (values.length) return values;\n\n // Protobuf can omit an empty repeated field. Recognize only its known\n // pagination envelope; don't mistake an unrecognized payload for no matches.\n if (\n positiveCount(total) ||\n (list[\"objects\"] == null &&\n (Object.keys(list).some(\n (key) => key !== \"response\" && key !== \"objects\",\n ) ||\n Object.keys(response).some(\n (key) =>\n ![\"next_page_token\", \"next_page_id\"].includes(key) &&\n !(key === \"total_size\" && (total === 0 || total === \"0\")),\n )))\n )\n throw new Error(\"Expected Endor list.objects in the finding export.\");\n\n const { count } = record(\n root[\"count_response\"] ?? {},\n \"Endor count response\",\n );\n const { groups } = record(\n root[\"group_response\"] ?? {},\n \"Endor group response\",\n );\n if (\n positiveCount(count) ||\n (groups != null && Object.keys(record(groups, \"Endor groups\")).length)\n )\n throw new Error(\n \"The Endor report contains a summary without finding objects. Supply the complete finding export.\",\n );\n return values;\n}\n\n/** Saved Endor Finding objects, an array, or an unmasked ListFindingsResponse. */\nexport function normalizeEndorFindings(\n input: unknown,\n target: ExternalImportTarget = \"cloud\",\n): ExternalFindings {\n return normalizeReport(input, target, false);\n}\n\nconst reducedReports = new WeakSet<ExternalFindings>();\n\n/** A native upload would ask the worker to reconstruct fields that Cloud could not accept. */\nexport function requiresStructuredEndorReport(findings: ExternalFindings) {\n return reducedReports.has(findings);\n}\n\n/** @internal Reproduce the selection from before malware and fully qualified package mapping. */\nexport function normalizePreviousEndorFindings(\n input: unknown,\n target: ExternalImportTarget = \"cloud\",\n): ExternalFindings {\n return normalizeReport(input, target, true);\n}\n\nfunction normalizeReport(\n input: unknown,\n target: ExternalImportTarget,\n previous: boolean,\n): ExternalFindings {\n const root = Array.isArray(input) ? null : record(input, \"Endor report\");\n if (root?.[\"version\"] === \"2.1.0\" && root[\"runs\"] !== undefined)\n return normalizeEndorSarif(root, target);\n const values =\n root?.[\"list\"] !== undefined\n ? endorListObjects(root)\n : Array.isArray(input)\n ? input\n : [input];\n let changed = false;\n let reduced = false;\n const result = normalizeRecords(\n values,\n (value) => {\n const finding = record(value, \"Endor finding\");\n const meta = record(finding[\"meta\"], \"Endor meta\");\n const spec = record(finding[\"spec\"], \"Endor spec\");\n requiredText(spec[\"project_uuid\"], \"Endor project_uuid\");\n const bareName = text(spec[\"target_dependency_name\"]);\n const name =\n bareName ??\n (previous ? null : text(spec[\"target_dependency_package_name\"]));\n const paths = [\n ...new Set(\n strings(spec[\"dependency_file_paths\"])\n .map(relativePath)\n .filter((p): p is string => p !== null),\n ),\n ];\n const metadata = record(\n spec[\"finding_metadata\"] ?? {},\n \"Endor finding_metadata\",\n );\n const codeLocations = [\"sast_data\", \"ai_sast_data\"].flatMap((field) => {\n const data = record(metadata[field] ?? {}, `Endor ${field}`);\n const location = record(\n data[\"location\"] ?? {},\n `Endor ${field} location`,\n );\n const path = relativePath(location[\"relative_path\"]);\n if (path === null) return [];\n const line = location[\"start_line\"];\n return [\n {\n path,\n line:\n typeof line === \"number\" && Number.isSafeInteger(line) && line > 0\n ? line\n : null,\n },\n ];\n });\n const locations = [\n ...paths\n .filter(\n (path) => !codeLocations.some((location) => location.path === path),\n )\n .map((path) => ({ path })),\n ...new Map(\n codeLocations.map((location) => [JSON.stringify(location), location]),\n ).values(),\n ];\n const vulnerability = record(\n metadata[\"vulnerability\"] ?? {},\n \"Endor vulnerability\",\n );\n const advisory = text(\n record(vulnerability[\"meta\"] ?? {}, \"Vulnerability meta\")[\"name\"],\n );\n const aliases = strings(\n record(vulnerability[\"spec\"] ?? {}, \"Vulnerability spec\")[\"aliases\"],\n );\n const vulnerabilityIds = [\n ...new Set([...(advisory ? [advisory] : []), ...aliases]),\n ];\n const malware = previous ? undefined : asRecord(metadata[\"malware\"]);\n const advisories = new Set([\n ...vulnerabilityIds,\n ...strings([asRecord(malware?.[\"meta\"])?.[\"name\"]]),\n ...strings(asRecord(malware?.[\"spec\"])?.[\"aliases\"]),\n ]);\n // A recommended version can refer to an introducing dependency; retain it in source_data.\n const packages = name\n ? (paths.length ? paths : [null]).map((path) => ({\n name,\n ecosystem:\n text(spec[\"ecosystem\"])\n ?.replace(/^ECOSYSTEM_/u, \"\")\n .toLowerCase() ?? null,\n installed_version: text(spec[\"target_dependency_version\"]),\n manifest_path: path,\n fixed_versions: [],\n }))\n : [];\n const context = record(finding[\"context\"] ?? {}, \"Endor context\");\n const updated = text(meta[\"update_time\"]);\n const malwareIds =\n advisories.size > vulnerabilityIds.length\n ? { advisory_ids: [...advisories] }\n : undefined;\n const fallbackPackage = name !== bareName ? { packages } : undefined;\n const evidence = validateEnrichedExternalEvidence(\n {\n title: requiredText(meta[\"name\"], \"Endor finding title\"),\n description:\n [\n text(spec[\"summary\"]),\n text(spec[\"explanation\"]),\n text(spec[\"remediation\"]),\n ]\n .filter(Boolean)\n .join(\"\\n\\n\") || text(meta[\"description\"]),\n severity: reportableScannerSeverity(\n text(spec[\"level\"])?.replace(/^FINDING_LEVEL_/u, \"\"),\n ),\n branch:\n context[\"type\"] === \"CONTEXT_TYPE_REF\" ? text(context[\"id\"]) : null,\n code_revision: text(\n record(\n spec[\"source_code_version\"] ?? {},\n \"Endor source code version\",\n )[\"sha\"],\n ),\n source_updated_at:\n updated === null ? null : Math.floor(Date.parse(updated) / 1000),\n advisory_ids: vulnerabilityIds,\n packages: bareName ? packages : [],\n locations,\n source_data: structuredClone(finding),\n },\n target,\n malwareIds && fallbackPackage && { ...malwareIds, ...fallbackPackage },\n malwareIds,\n fallbackPackage,\n );\n const acceptedIds = evidence.advisory_ids!.length;\n const acceptedPackages = evidence.packages!.length;\n changed ||=\n acceptedIds > vulnerabilityIds.length ||\n (!bareName && acceptedPackages > 0);\n reduced ||=\n acceptedIds < advisories.size || acceptedPackages < packages.length;\n return evidence;\n },\n (value) =>\n requiredText(\n record(value, \"Endor finding\")[\"uuid\"],\n \"Endor finding uuid\",\n ),\n target,\n );\n if (target === \"cloud\") {\n if (changed) markPreviousCloudProjection(result);\n if (reduced) reducedReports.add(result);\n }\n return result;\n}\n\n/** Endor's documented SARIF producer uses properties.finding-uuid, not its rule name. */\nexport function normalizeEndorSarif(\n input: unknown,\n target: ExternalImportTarget = \"cloud\",\n): ExternalFindings {\n const entries = readSarifRuns(input, \"Endor\", (context) => {\n if (context.driver[\"name\"] !== \"endorctl\")\n throw new Error(\"Expected the endorctl SARIF producer.\");\n return sarifRunResults(context, \"Endor\");\n });\n return normalizeRecords(\n entries,\n ({ result: value, context }) => {\n const result = record(value, \"Endor result\");\n const properties = record(\n result[\"properties\"],\n \"Endor result properties\",\n );\n requiredText(properties[\"project-uuid\"], \"Endor project-uuid\");\n const ruleId = requiredText(result[\"ruleId\"], \"Endor ruleId\");\n const selectedRule = context.rulesById.get(ruleId);\n if (!selectedRule)\n throw new Error(\n \"Endor result must reference exactly one rule in its run.\",\n );\n const { rule } = selectedRule;\n validateSarifRuleReference(result, ruleId, selectedRule, \"Endor\");\n const message = record(result[\"message\"], \"Endor message\");\n const short = record(\n rule[\"shortDescription\"] ?? {},\n \"Endor shortDescription\",\n );\n const full = record(\n rule[\"fullDescription\"] ?? {},\n \"Endor fullDescription\",\n );\n const help = record(rule[\"help\"] ?? {}, \"Endor help\");\n const hasCodeLocations = strings(properties[\"categories\"]).some(\n (category) => category === \"SAST\" || category === \"SECRETS\",\n );\n const locations = array(\n result[\"locations\"] ?? [],\n \"Endor locations\",\n ).flatMap((v) => {\n const physical = record(\n record(v, \"Endor location\")[\"physicalLocation\"] ?? {},\n \"Physical location\",\n );\n const artifact = record(\n physical[\"artifactLocation\"] ?? {},\n \"Artifact location\",\n );\n if (\n artifact[\"index\"] !== undefined ||\n artifact[\"uriBaseId\"] !== undefined\n )\n return [];\n const uri = text(artifact[\"uri\"]);\n if (uri === null || /^[A-Za-z][A-Za-z0-9+.-]*:/u.test(uri)) return [];\n let path: string | null;\n try {\n path = relativePath(decodeURIComponent(uri));\n } catch {\n return [];\n }\n if (path === null) return [];\n const line = hasCodeLocations\n ? record(physical[\"region\"] ?? {}, \"Endor region\")[\"startLine\"]\n : null;\n return [\n {\n path,\n line:\n typeof line === \"number\" && Number.isSafeInteger(line) && line > 0\n ? line\n : null,\n },\n ];\n });\n return validateExternalEvidence(\n {\n title: text(short[\"text\"]) ?? text(rule[\"name\"]) ?? ruleId,\n url: text(properties[\"finding-url\"]),\n description: [\n text(message[\"markdown\"]) ?? text(message[\"text\"]),\n text(full[\"text\"]),\n text(help[\"markdown\"]) ?? text(help[\"text\"]),\n ]\n .filter(Boolean)\n .join(\"\\n\\n\"),\n // Diagnostic level and CVSS are not Endor's finding severity. Keep both as source evidence.\n severity: \"unknown\",\n locations: [\n ...new Map(\n locations.map((location) => [JSON.stringify(location), location]),\n ).values(),\n ],\n source_data: context.sourceData(result, rule),\n },\n target,\n );\n },\n ({ result }) =>\n requiredText(\n record(\n record(result, \"Endor result\")[\"properties\"],\n \"Endor result properties\",\n )[\"finding-uuid\"],\n \"Endor finding-uuid\",\n ),\n target,\n );\n}\n\nexport async function readEndorFindings(\n path: string,\n target: ExternalImportTarget = \"cloud\",\n): Promise<ExternalFindings> {\n return normalizeEndorFindings(await readScannerJson(path), target);\n}\n"]}
|
package/dist/errors.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export declare class OutputDirectoryNotEmptyError extends OutputDirectoryError {
|
|
|
39
39
|
readonly directory: string;
|
|
40
40
|
constructor(directory: string, operation?: "scan" | "policy");
|
|
41
41
|
}
|
|
42
|
-
export type ProtectedScanPathKind = "output" | "temporary" | "runtime";
|
|
42
|
+
export type ProtectedScanPathKind = "output" | "state" | "temporary" | "runtime";
|
|
43
43
|
export declare class OutputInsideProtectedRootError extends OutputDirectoryError {
|
|
44
44
|
readonly outputDirectory: string;
|
|
45
45
|
readonly protectedRoot: string;
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -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tectedRootError extends OutputDirectoryError {
|
|
|
51
51
|
protectedRoot;
|
|
52
52
|
pathKind;
|
|
53
53
|
constructor(outputDirectory, protectedRoot, pathKind = "output") {
|
|
54
|
-
super(
|
|
54
|
+
super(pathKind === "state"
|
|
55
|
+
? [
|
|
56
|
+
"Codex Security state directory must be outside the protected scan root and cannot contain it.",
|
|
57
|
+
` Resolved path: ${outputDirectory}`,
|
|
58
|
+
` Protected root: ${protectedRoot}`,
|
|
59
|
+
"Set CODEX_SECURITY_STATE_DIR to a private directory that does not overlap the protected root. For hosted scans, set stateDirectory on the request.",
|
|
60
|
+
].join("\n")
|
|
61
|
+
: `Scan ${pathKind} directory must be outside the protected scan root: ${outputDirectory}`);
|
|
55
62
|
this.outputDirectory = outputDirectory;
|
|
56
63
|
this.protectedRoot = protectedRoot;
|
|
57
64
|
this.pathKind = pathKind;
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAiB,MAAM,iBAAiB,CAAC;AAE3E,wEAAwE;AACxE,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAmB;IAC7C,OAAO,CACL,MAAM,CAAC,MAAM;QACb,IAAI,YAAY,CAAC,4BAA4B,EAAE,YAAY,CAAC,CAC7D,CAAC;AACJ,CAAC;AAED,kDAAkD;AAClD,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAmB,OAAe,EAAE,OAAsB;QACxD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC;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;IAH1B,YACkB,eAAuB,EACvB,aAAqB,EACrB,QAAQ,GAA0B,QAAQ;QAE1D,KAAK,CACH,QAAQ,KAAK,OAAO;YAClB,CAAC,CAAC;gBACE,+FAA+F;gBAC/F,qBAAqB,eAAe,EAAE;gBACtC,qBAAqB,aAAa,EAAE;gBACpC,oJAAoJ;aACrJ,CAAC,IAAI,CAAC,IAAI,CAAC;YACd,CAAC,CAAC,QAAQ,QAAQ,uDAAuD,eAAe,EAAE,CAC7F,CAAC;+BAbc,eAAe;6BACf,aAAa;wBACb,QAAQ;IAY1B,CAAC;CACF;AACD,MAAM,OAAO,mBAAoB,SAAQ,kBAAkB;CAAG;AAC9D,MAAM,OAAO,uBAAwB,SAAQ,kBAAkB;CAAG;AAClE,MAAM,OAAO,oBAAqB,SAAQ,kBAAkB;IAC1C,OAAO,CAAS;IAEhC,YAAmB,OAAe,EAAE,OAAe,EAAE,OAAsB;QACzE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED,MAAM,OAAO,0BAA2B,SAAQ,oBAAoB;IAClD,UAAU,CAAS;IACnB,IAAI,CAAqB;IAEzC,YACE,UAAkB,EAClB,IAAwB,EACxB,OAAe;QAEf,KAAK,CACH,+CAA+C,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,iBAAiB,SAAS,CAAC,UAAU,CAAC,0BAA0B,cAAc,CAAC,IAAI,CAAC,4BAA4B,OAAO,GAAG,EACrM,OAAO,CACR,CAAC;QACF,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { formatScanCost, formatUsd, type ScanCost } from \"./cost-model.js\";\n\n/** Returns the original error message without altering its contents. */\nexport function errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nexport function abortReason(signal: AbortSignal): unknown {\n return (\n signal.reason ??\n new DOMException(\"The operation was aborted.\", \"AbortError\")\n );\n}\n\n/** Base error for Codex Security SDK failures. */\nexport class CodexSecurityError extends Error {\n public constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = new.target.name;\n }\n}\n\nexport type DeduplicationReviewStage = \"screening\" | \"pair-review\";\nexport type DeduplicationReviewFailureCategory =\n \"validation\" | \"no-submission\" | \"model\" | \"transport\" | \"refusal\";\n\nexport interface DeduplicationReviewFailureMetadata {\n stage: DeduplicationReviewStage;\n model: string;\n category: DeduplicationReviewFailureCategory;\n attempts: number;\n reason: string;\n}\n\nexport class DeduplicationReviewError extends CodexSecurityError {\n public constructor(\n public readonly metadata: Readonly<DeduplicationReviewFailureMetadata>,\n displayReason: string = metadata.reason,\n ) {\n super(\n `Codex did not complete a validated deduplication review. Findings are unchanged; retry the command. Reason: ${displayReason}`,\n );\n }\n}\n\nexport class ConfigurationError extends CodexSecurityError {}\nexport class AuthenticationRequiredError extends CodexSecurityError {}\nexport class PluginBootstrapError extends CodexSecurityError {}\nexport class LocalPluginBootstrapError extends PluginBootstrapError {}\nexport class PluginPythonUnavailableError extends PluginBootstrapError {}\nexport class SandboxUnavailableError extends CodexSecurityError {}\nexport class InvalidTargetError extends CodexSecurityError {}\nexport class OutputDirectoryError extends CodexSecurityError {}\nexport class OutputDirectoryNotEmptyError extends OutputDirectoryError {\n public constructor(\n public readonly directory: string,\n operation: \"scan\" | \"policy\" = \"scan\",\n ) {\n super(\n operation === \"policy\"\n ? `Policy output directory is not empty: ${directory}. Choose a new or empty directory.`\n : `Scan output directory is not empty: ${directory}. To keep the existing results and start a new scan, add --archive-existing.`,\n );\n }\n}\nexport type ProtectedScanPathKind =\n \"output\" | \"state\" | \"temporary\" | \"runtime\";\n\nexport class OutputInsideProtectedRootError extends OutputDirectoryError {\n public constructor(\n public readonly outputDirectory: string,\n public readonly protectedRoot: string,\n public readonly pathKind: ProtectedScanPathKind = \"output\",\n ) {\n super(\n pathKind === \"state\"\n ? [\n \"Codex Security state directory must be outside the protected scan root and cannot contain it.\",\n ` Resolved path: ${outputDirectory}`,\n ` Protected root: ${protectedRoot}`,\n \"Set CODEX_SECURITY_STATE_DIR to a private directory that does not overlap the protected root. For hosted scans, set stateDirectory on the request.\",\n ].join(\"\\n\")\n : `Scan ${pathKind} directory must be outside the protected scan root: ${outputDirectory}`,\n );\n }\n}\nexport class IncompleteScanError extends CodexSecurityError {}\nexport class ContractValidationError extends CodexSecurityError {}\nexport class ScanInterruptedError extends CodexSecurityError {\n public readonly scanDir: string;\n\n public constructor(message: string, scanDir: string, options?: ErrorOptions) {\n super(message, options);\n this.scanDir = scanDir;\n }\n}\n\nexport class ScanCostLimitExceededError extends ScanInterruptedError {\n public readonly maxCostUsd: number;\n public readonly cost: Readonly<ScanCost>;\n\n public constructor(\n maxCostUsd: number,\n cost: Readonly<ScanCost>,\n scanDir: string,\n ) {\n super(\n `Scan stopped: short-context budget baseline ${formatUsd(cost.estimatedUsd)} exceeded the ${formatUsd(maxCostUsd)} limit; estimated cost ${formatScanCost(cost)}; scan output directory: ${scanDir}.`,\n scanDir,\n );\n this.maxCostUsd = maxCostUsd;\n this.cost = cost;\n }\n}\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { type LocalExternalImportDependencies } from "./external-findings-local.js";
|
|
1
|
+
import { type ExternalFindingsReaderOptions } from "./external-findings-read.js";
|
|
2
|
+
import { type LocalExternalImportDependencies, type NormalizedLocalImportOptions } from "./external-findings-local.js";
|
|
3
|
+
export interface LocalExternalImportOptions extends Omit<NormalizedLocalImportOptions, "provider">, ExternalFindingsReaderOptions {
|
|
4
|
+
}
|
|
3
5
|
/** Read an installed vendor format and prepare it for the local workbench. */
|
|
4
|
-
export declare function prepareLocalExternalImport(path: string, options:
|
|
6
|
+
export declare function prepareLocalExternalImport(path: string, options: LocalExternalImportOptions, dependencies?: LocalExternalImportDependencies): Promise<import("./external-findings-local.js").PreparedLocalExternalImport>;
|
|
5
7
|
//# sourceMappingURL=external-findings-import.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-findings-import.d.ts","sourceRoot":"","sources":["../src/external-findings-import.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"external-findings-import.d.ts","sourceRoot":"","sources":["../src/external-findings-import.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,6BAA6B,EAEnC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAGL,KAAK,+BAA+B,EACpC,KAAK,4BAA4B,EAClC,MAAM,8BAA8B,CAAC;AAOtC,MAAM,WAAW,0BACf,SACE,IAAI,CAAC,4BAA4B,EAAE,UAAU,CAAC,EAC9C,6BAA6B;CAAG;AAEpC,8EAA8E;AAC9E,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,0BAA0B,EACnC,YAAY,GAAE,+BAAoC,+EAsDnD"}
|
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import { cloudRepositoryUrlKey, repositoryUrlKey, } from "./external-import-contract.js";
|
|
2
2
|
import { EXTERNAL_FINDINGS_PROVIDERS, readExternalFindings, } from "./external-findings-read.js";
|
|
3
|
-
import { prepareLocalImport, } from "./external-findings-local.js";
|
|
3
|
+
import { distinctSourceRepositories, prepareLocalImport, } from "./external-findings-local.js";
|
|
4
4
|
import { snapshotImportOptions, snapshotSourceRepositories, } from "./external-findings.js";
|
|
5
5
|
import { abortable } from "./targets.js";
|
|
6
|
-
import { requireExternalImports } from "./external-imports-feature.js";
|
|
7
6
|
/** Read an installed vendor format and prepare it for the local workbench. */
|
|
8
7
|
export async function prepareLocalExternalImport(path, options, dependencies = {}) {
|
|
9
8
|
dependencies.signal?.throwIfAborted();
|
|
10
|
-
requireExternalImports(dependencies.environment);
|
|
11
9
|
const settings = snapshotImportOptions(options);
|
|
12
|
-
const readerSources = snapshotSourceRepositories(dependencies.sourceRepositories);
|
|
13
|
-
const parsed = await abortable(() => readExternalFindings(path, settings, "local"), dependencies.signal);
|
|
10
|
+
const readerSources = distinctSourceRepositories(snapshotSourceRepositories(dependencies.sourceRepositories));
|
|
11
|
+
const parsed = await abortable(() => readExternalFindings(path, settings, "local", readerSources), dependencies.signal);
|
|
14
12
|
const normalizedOptions = {
|
|
15
13
|
...settings,
|
|
16
14
|
provider: EXTERNAL_FINDINGS_PROVIDERS[settings.provider],
|
|
17
15
|
};
|
|
18
16
|
let sourceRepositories = parsed.sourceRepositories ?? [];
|
|
19
|
-
if (normalizedOptions.provider === "semgrep"
|
|
17
|
+
if (normalizedOptions.provider === "semgrep" &&
|
|
18
|
+
parsed.sourceRepositories &&
|
|
19
|
+
settings.sourceRepositoryUrl) {
|
|
20
20
|
// The Cloud reader allows custom GitHub casing. Local provenance must also
|
|
21
21
|
// agree with the caller's source URL when the checkout has no remote.
|
|
22
22
|
const source = settings.sourceRepositoryUrl;
|
|
23
23
|
const knownGitHub = readerSources.some(({ url, platform }) => platform === "github" &&
|
|
24
24
|
cloudRepositoryUrlKey(url) === cloudRepositoryUrlKey(source));
|
|
25
25
|
const key = knownGitHub ? cloudRepositoryUrlKey : repositoryUrlKey;
|
|
26
|
+
sourceRepositories = distinctSourceRepositories(sourceRepositories);
|
|
26
27
|
for (const reference of sourceRepositories) {
|
|
27
28
|
if (key(reference.url) !== key(source))
|
|
28
29
|
throw new Error("SARIF source repository does not match the declared source repository URL.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-findings-import.js","sourceRoot":"","sources":["../src/external-findings-import.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"external-findings-import.js","sourceRoot":"","sources":["../src/external-findings-import.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,2BAA2B,EAE3B,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,0BAA0B,EAC1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AAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,gBAAgB,CAAC;QACnE,kBAAkB,GAAG,0BAA0B,CAAC,kBAAkB,CAAC,CAAC;QACpE,KAAK,MAAM,SAAS,IAAI,kBAAkB,EAAE,CAAC;YAC3C,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC;gBACpC,MAAM,IAAI,KAAK,CACb,4EAA4E,CAC7E,CAAC;QACN,CAAC;QACD,IAAI,WAAW;YACb,kBAAkB,GAAG;gBACnB,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE;gBACnC,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;oBACxC,GAAG,SAAS;oBACZ,QAAQ,EAAE,QAAiB;iBAC5B,CAAC,CAAC;aACJ,CAAC;IACN,CAAC;IACD,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC;IAC3D,OAAO,kBAAkB,CACvB,MAAM,CAAC,QAAQ,EACf,iBAAiB,EACjB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,EACrC,aAAa,EACb,kBAAkB,CACnB,CAAC;AACJ,CAAC","sourcesContent":["import {\n cloudRepositoryUrlKey,\n repositoryUrlKey,\n} from \"./external-import-contract.js\";\nimport {\n EXTERNAL_FINDINGS_PROVIDERS,\n type ExternalFindingsReaderOptions,\n readExternalFindings,\n} from \"./external-findings-read.js\";\nimport {\n distinctSourceRepositories,\n prepareLocalImport,\n type LocalExternalImportDependencies,\n type NormalizedLocalImportOptions,\n} from \"./external-findings-local.js\";\nimport {\n snapshotImportOptions,\n snapshotSourceRepositories,\n} from \"./external-findings.js\";\nimport { abortable } from \"./targets.js\";\n\nexport interface LocalExternalImportOptions\n extends\n Omit<NormalizedLocalImportOptions, \"provider\">,\n ExternalFindingsReaderOptions {}\n\n/** Read an installed vendor format and prepare it for the local workbench. */\nexport async function prepareLocalExternalImport(\n path: string,\n options: LocalExternalImportOptions,\n dependencies: LocalExternalImportDependencies = {},\n) {\n dependencies.signal?.throwIfAborted();\n const settings = snapshotImportOptions(options);\n const readerSources = distinctSourceRepositories(\n snapshotSourceRepositories(dependencies.sourceRepositories),\n );\n const parsed = await abortable(\n () => readExternalFindings(path, settings, \"local\", readerSources),\n dependencies.signal,\n );\n const normalizedOptions = {\n ...settings,\n provider: EXTERNAL_FINDINGS_PROVIDERS[settings.provider],\n };\n let sourceRepositories = parsed.sourceRepositories ?? [];\n if (\n normalizedOptions.provider === \"semgrep\" &&\n parsed.sourceRepositories &&\n settings.sourceRepositoryUrl\n ) {\n // The Cloud reader allows custom GitHub casing. Local provenance must also\n // agree with the caller's source URL when the checkout has no remote.\n const source = settings.sourceRepositoryUrl;\n const knownGitHub = readerSources.some(\n ({ url, platform }) =>\n platform === \"github\" &&\n cloudRepositoryUrlKey(url) === cloudRepositoryUrlKey(source),\n );\n const key = knownGitHub ? cloudRepositoryUrlKey : repositoryUrlKey;\n sourceRepositories = distinctSourceRepositories(sourceRepositories);\n for (const reference of sourceRepositories) {\n if (key(reference.url) !== key(source))\n throw new Error(\n \"SARIF source repository does not match the declared source repository URL.\",\n );\n }\n if (knownGitHub)\n sourceRepositories = [\n { url: source, platform: \"github\" },\n ...sourceRepositories.map((reference) => ({\n ...reference,\n platform: \"github\" as const,\n })),\n ];\n }\n const { environment, runWorkbench, signal } = dependencies;\n return prepareLocalImport(\n parsed.findings,\n normalizedOptions,\n { environment, runWorkbench, signal },\n readerSources,\n sourceRepositories,\n );\n}\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type ExternalFindings, type ExternalSourceRepository } from "./external-findings.js";
|
|
2
|
-
import type { ExternalFindingEvidence
|
|
2
|
+
import type { ExternalFindingEvidence } from "./external-import-models.js";
|
|
3
|
+
import { type LocalFindingProvider } from "./external-findings-read.js";
|
|
3
4
|
import { runWorkbench } from "./runtime.js";
|
|
4
5
|
/** A scanner source record, independent of a Codex assessment or completed scan. */
|
|
5
6
|
export interface StoredExternalFinding {
|
|
6
7
|
id: string;
|
|
7
8
|
repository: string;
|
|
8
|
-
provider:
|
|
9
|
+
provider: LocalFindingProvider;
|
|
9
10
|
sourceKey: string;
|
|
10
11
|
sourceFindingId: string;
|
|
11
12
|
evidence: ExternalFindingEvidence;
|
|
@@ -19,10 +20,10 @@ export interface StoredExternalFinding {
|
|
|
19
20
|
export interface NormalizedLocalImportOptions {
|
|
20
21
|
/** Local checkout or source directory to associate with these records. */
|
|
21
22
|
repository: string;
|
|
22
|
-
provider:
|
|
23
|
+
provider: LocalFindingProvider;
|
|
23
24
|
/** Stable scanner organization/project/branch namespace across imports. */
|
|
24
25
|
sourceKey: string;
|
|
25
|
-
/**
|
|
26
|
+
/** Verified Git repository URL for readers that bind a finding to a checkout. */
|
|
26
27
|
sourceRepositoryUrl?: string;
|
|
27
28
|
/** Full Inspector project ARNs mapped to independently verified repository URLs. */
|
|
28
29
|
inspectorProjectMap?: ReadonlyMap<string, string>;
|
|
@@ -37,7 +38,7 @@ export interface LocalExternalImportDependencies {
|
|
|
37
38
|
export interface LocalExternalImportPreview extends ExternalFindings {
|
|
38
39
|
repository: string;
|
|
39
40
|
source: {
|
|
40
|
-
provider:
|
|
41
|
+
provider: LocalFindingProvider;
|
|
41
42
|
source_key: string;
|
|
42
43
|
};
|
|
43
44
|
}
|
|
@@ -67,6 +68,7 @@ export declare function boundSonarWorktree(repository: string, protectedRoots: s
|
|
|
67
68
|
export declare function sonarCheckoutMatchesSource(repository: string, url: string, protectedRoots: readonly string[], environment: NodeJS.ProcessEnv, signal?: AbortSignal): Promise<boolean>;
|
|
68
69
|
/** Prepare scanner evidence without writing state or performing a security assessment. */
|
|
69
70
|
export declare function prepareNormalizedLocalImport(input: ExternalFindings, options: NormalizedLocalImportOptions, dependencies?: LocalExternalImportDependencies): Promise<PreparedLocalExternalImport>;
|
|
71
|
+
export declare function distinctSourceRepositories(sources: readonly ExternalSourceRepository[]): ExternalSourceRepository[];
|
|
70
72
|
/** Read imported source records, including evidence that has not been assessed by Codex. */
|
|
71
73
|
export declare function listLocalExternalFindings(selection: {
|
|
72
74
|
repository: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-findings-local.d.ts","sourceRoot":"","sources":["../src/external-findings-local.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"external-findings-local.d.ts","sourceRoot":"","sources":["../src/external-findings-local.ts"],"names":[],"mappings":"AAyBA,OAAO,EAOL,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC9B,MAAM,wBAAwB,CAAC;AAOhC,OAAO,KAAK,EACV,uBAAuB,EAExB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,6BAA6B,CAAC;AAuCrC,OAAO,EAML,YAAY,EAGb,MAAM,cAAc,CAAC;AAQtB,oFAAoF;AACpF,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,uBAAuB,CAAC;IAClC,UAAU,EAAE;QAAE,KAAK,EAAE,cAAc,CAAA;KAAE,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,4BAA4B;IAC3C,0EAA0E;IAC1E,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,2EAA2E;IAC3E,SAAS,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,oFAAoF;IACpF,mBAAmB,CAAC,EAAE,WAAW,CAAC,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