@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"windows-path.d.ts","sourceRoot":"","sources":["../src/windows-path.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"windows-path.d.ts","sourceRoot":"","sources":["../src/windows-path.ts"],"names":[],"mappings":"AAMA,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA6BnD;AAMD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAMnE;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAK3E"}
|
package/dist/windows-path.js
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
/* Generated from plugin windows-path.ts. Run `pnpm generate:models`. */
|
|
2
|
-
import { parse } from "node:path";
|
|
2
|
+
import { parse, toNamespacedPath } from "node:path";
|
|
3
|
+
// SQLite's default win32 VFS allows MAX_PATH * 4 UTF-8 bytes, including room for "-journal".
|
|
4
|
+
const SQLITE_WINDOWS_MAX_FILENAME_BYTES = 260 * 4 - 8;
|
|
5
|
+
export function sqliteFilename(path) {
|
|
6
|
+
// Ordinary paths also preserve Win32 handling of device names and trailing spaces or dots.
|
|
7
|
+
if (process.platform !== "win32" ||
|
|
8
|
+
path.length + 8 < 260 ||
|
|
9
|
+
path.includes("\0"))
|
|
10
|
+
return path;
|
|
11
|
+
const root = parse(path).root;
|
|
12
|
+
// Root-relative names (including ambiguous UNC spellings) must not move to the current drive.
|
|
13
|
+
if (root.length < 3)
|
|
14
|
+
return path;
|
|
15
|
+
// Keep device prefixes, dot segments, and incomplete UNC roots as supplied.
|
|
16
|
+
// Repeated separators below a complete root still identify the same file.
|
|
17
|
+
const isDrivePath = root[1] === ":";
|
|
18
|
+
const components = path.slice(isDrivePath ? root.length : 2).split(/[\\/]/u);
|
|
19
|
+
if ((!isDrivePath && (!components[0] || !components[1])) ||
|
|
20
|
+
components.some((part) => part === "." || isWindowsUnsafePathComponent(part)))
|
|
21
|
+
return path;
|
|
22
|
+
const namespaced = toNamespacedPath(path);
|
|
23
|
+
if (namespaced !== path &&
|
|
24
|
+
Buffer.byteLength(namespaced) > SQLITE_WINDOWS_MAX_FILENAME_BYTES)
|
|
25
|
+
return path;
|
|
26
|
+
return namespaced;
|
|
27
|
+
}
|
|
3
28
|
const UNSAFE_COMPONENT = /[<>:"|?*\u0000-\u001f]|[ .]$/u;
|
|
4
29
|
const RESERVED_COMPONENT = /^(?:con|prn|aux|nul|conin\$|conout\$|com[1-9¹²³]|lpt[1-9¹²³])(?:\..*)?$/iu;
|
|
5
30
|
export function isWindowsUnsafePathComponent(value) {
|
package/dist/windows-path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"windows-path.js","sourceRoot":"","sources":["../src/windows-path.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"windows-path.js","sourceRoot":"","sources":["../src/windows-path.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAEpD,6FAA6F;AAC7F,MAAM,iCAAiC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;AAEtD,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,2FAA2F;IAC3F,IACE,OAAO,CAAC,QAAQ,KAAK,OAAO;QAC5B,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,GAAG;QACrB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAEnB,OAAO,IAAI,CAAC;IACd,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;IAC9B,8FAA8F;IAC9F,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACjC,4EAA4E;IAC5E,0EAA0E;IAC1E,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;IACpC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC7E,IACE,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,UAAU,CAAC,IAAI,CACb,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,IAAI,4BAA4B,CAAC,IAAI,CAAC,CAC7D;QAED,OAAO,IAAI,CAAC;IACd,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC1C,IACE,UAAU,KAAK,IAAI;QACnB,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,iCAAiC;QAEjE,OAAO,IAAI,CAAC;IACd,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,gBAAgB,GAAG,+BAA+B,CAAC;AACzD,MAAM,kBAAkB,GACtB,2EAA2E,CAAC;AAE9E,MAAM,UAAU,4BAA4B,CAAC,KAAa;IACxD,OAAO,CACL,KAAK,KAAK,EAAE;QACZ,KAAK,KAAK,GAAG;QACb,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CACjE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,IAAY;IACrD,OAAO,IAAI;SACR,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;SAC9B,KAAK,CAAC,QAAQ,CAAC;SACf,IAAI,CAAC,4BAA4B,CAAC,CAAC;AACxC,CAAC","sourcesContent":["/* Generated from plugin windows-path.ts. Run `pnpm generate:models`. */\nimport { parse, toNamespacedPath } from \"node:path\";\n\n// SQLite's default win32 VFS allows MAX_PATH * 4 UTF-8 bytes, including room for \"-journal\".\nconst SQLITE_WINDOWS_MAX_FILENAME_BYTES = 260 * 4 - 8;\n\nexport function sqliteFilename(path: string): string {\n // Ordinary paths also preserve Win32 handling of device names and trailing spaces or dots.\n if (\n process.platform !== \"win32\" ||\n path.length + 8 < 260 ||\n path.includes(\"\\0\")\n )\n return path;\n const root = parse(path).root;\n // Root-relative names (including ambiguous UNC spellings) must not move to the current drive.\n if (root.length < 3) return path;\n // Keep device prefixes, dot segments, and incomplete UNC roots as supplied.\n // Repeated separators below a complete root still identify the same file.\n const isDrivePath = root[1] === \":\";\n const components = path.slice(isDrivePath ? root.length : 2).split(/[\\\\/]/u);\n if (\n (!isDrivePath && (!components[0] || !components[1])) ||\n components.some(\n (part) => part === \".\" || isWindowsUnsafePathComponent(part),\n )\n )\n return path;\n const namespaced = toNamespacedPath(path);\n if (\n namespaced !== path &&\n Buffer.byteLength(namespaced) > SQLITE_WINDOWS_MAX_FILENAME_BYTES\n )\n return path;\n return namespaced;\n}\n\nconst UNSAFE_COMPONENT = /[<>:\"|?*\\u0000-\\u001f]|[ .]$/u;\nconst RESERVED_COMPONENT =\n /^(?:con|prn|aux|nul|conin\\$|conout\\$|com[1-9¹²³]|lpt[1-9¹²³])(?:\\..*)?$/iu;\n\nexport function isWindowsUnsafePathComponent(value: string): boolean {\n return (\n value !== \"\" &&\n value !== \".\" &&\n (UNSAFE_COMPONENT.test(value) || RESERVED_COMPONENT.test(value))\n );\n}\n\nexport function windowsUnsafePathComponent(path: string): string | undefined {\n return path\n .slice(parse(path).root.length)\n .split(/[\\\\/]/u)\n .find(isWindowsUnsafePathComponent);\n}\n"]}
|
package/dist/wiz-findings.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type ExternalImportTarget } from "./external-import-contract.js";
|
|
2
2
|
import type { ExternalFinding as VendorFinding, ExternalFindings as VendorFindings, ExternalSourceRepository } from "./external-findings.js";
|
|
3
|
+
/** Distinguish original Wiz package records from opaque SDK asset metadata. */
|
|
4
|
+
export declare function isWizPackageFinding(data: VendorFinding["evidence"]["source_data"]): boolean;
|
|
3
5
|
/** The source repository retained by a Wiz package finding or CSV row. */
|
|
4
6
|
export declare function wizFindingRepository(evidence: VendorFinding["evidence"], target?: ExternalImportTarget): ExternalSourceRepository | undefined;
|
|
5
7
|
export declare function readVendorFindings(path: string, target?: ExternalImportTarget): Promise<VendorFindings>;
|
|
@@ -10,4 +12,6 @@ export declare function readLocalWizFindings(path: string): Promise<{
|
|
|
10
12
|
platform: "github";
|
|
11
13
|
}[];
|
|
12
14
|
}>;
|
|
15
|
+
/** Apply Wiz's own reader to an occurrence that also retains another scanner's fields. */
|
|
16
|
+
export declare function isWizOccurrence(finding: VendorFinding, target: ExternalImportTarget): boolean;
|
|
13
17
|
//# sourceMappingURL=wiz-findings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wiz-findings.d.ts","sourceRoot":"","sources":["../src/wiz-findings.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,+BAA+B,CAAC;AAKvC,OAAO,KAAK,EACV,eAAe,IAAI,aAAa,EAChC,gBAAgB,IAAI,cAAc,EAClC,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"wiz-findings.d.ts","sourceRoot":"","sources":["../src/wiz-findings.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,+BAA+B,CAAC;AAKvC,OAAO,KAAK,EACV,eAAe,IAAI,aAAa,EAChC,gBAAgB,IAAI,cAAc,EAClC,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAiBhC,+EAA+E;AAC/E,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC,aAAa,CAAC,GAC7C,OAAO,CAST;AA4aD,0EAA0E;AAC1E,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,EACnC,MAAM,GAAE,oBAA8B,GACrC,wBAAwB,GAAG,SAAS,CA2BtC;AAED,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,oBAA8B,GACrC,OAAO,CAAC,cAAc,CAAC,CAEzB;AAiBD,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,MAAM;;;;kBALb,QAAQ;;GASjD;AAsFD,0FAA0F;AAC1F,wBAAgB,eAAe,CAC7B,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAoCT"}
|
package/dist/wiz-findings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CodexSecurityError } from "./errors.js";
|
|
2
2
|
import { repositoryUrlKey, validateExternalEvidence, } from "./external-import-contract.js";
|
|
3
|
-
import { asRecord } from "./record.js";
|
|
3
|
+
import { asRecord, canonicalJson } from "./record.js";
|
|
4
4
|
import { parseJsonOrJsonl, readScannerText, text } from "./scanner-import.js";
|
|
5
5
|
import { isGitHubCloudHost } from "./git-remote.js";
|
|
6
6
|
import { readWizCsv, wizCsvFinding, wizCsvRepositoryUrl } from "./wiz-csv.js";
|
|
@@ -14,6 +14,15 @@ function sourceFindingId(value, target) {
|
|
|
14
14
|
: "Source finding id must be nonempty and contain no NUL characters.");
|
|
15
15
|
return id;
|
|
16
16
|
}
|
|
17
|
+
/** Distinguish original Wiz package records from opaque SDK asset metadata. */
|
|
18
|
+
export function isWizPackageFinding(data) {
|
|
19
|
+
return Boolean(data &&
|
|
20
|
+
data["detectionMethod"] !== "EXTERNAL_NETWORK_SCAN" &&
|
|
21
|
+
text(data["id"]) &&
|
|
22
|
+
text(data["name"]) &&
|
|
23
|
+
text(data["detailedName"]) &&
|
|
24
|
+
text(asRecord(data["vulnerableAsset"])?.["id"]));
|
|
25
|
+
}
|
|
17
26
|
/** Keep a Wiz vulnerability occurrence intact; advisory names are not identities. */
|
|
18
27
|
function wizFinding(record, target) {
|
|
19
28
|
if (record["detectionMethod"] === "EXTERNAL_NETWORK_SCAN")
|
|
@@ -305,18 +314,26 @@ function records(payload) {
|
|
|
305
314
|
};
|
|
306
315
|
const selected = [];
|
|
307
316
|
let found = false;
|
|
317
|
+
let countedCollection;
|
|
308
318
|
for (const [root, kind] of Object.entries(collections)) {
|
|
319
|
+
if (!(root in data))
|
|
320
|
+
continue;
|
|
309
321
|
const collection = asRecord(data[root]);
|
|
310
322
|
if (!collection)
|
|
311
|
-
|
|
323
|
+
throw new Error(`Wiz ${root} must be an object with a nodes array.`);
|
|
312
324
|
found = true;
|
|
313
325
|
if (!Array.isArray(collection["nodes"]))
|
|
314
326
|
throw new Error(`Wiz ${root}.nodes must be an array.`);
|
|
315
327
|
if (asRecord(collection["pageInfo"])?.["hasNextPage"] === true)
|
|
316
328
|
throw new Error("Wiz response has another page. Complete the requested pages or save the explicitly selected records in their named collection before publishing.");
|
|
329
|
+
const total = collection["totalCount"];
|
|
330
|
+
if (typeof total === "number" && total > 0)
|
|
331
|
+
countedCollection = root;
|
|
317
332
|
for (const value of collection["nodes"])
|
|
318
333
|
selected.push({ value, kind });
|
|
319
334
|
}
|
|
335
|
+
if (!selected.length && countedCollection)
|
|
336
|
+
throw new Error(`Wiz ${countedCollection}.totalCount reports findings, but the export contains no finding nodes.`);
|
|
320
337
|
if (found)
|
|
321
338
|
return {
|
|
322
339
|
records: selected,
|
|
@@ -337,7 +354,9 @@ export function wizFindingRepository(evidence, target = "local") {
|
|
|
337
354
|
if (!url)
|
|
338
355
|
return;
|
|
339
356
|
const github = asset["nativeType"] === "github#repositoryBranch" ||
|
|
340
|
-
(asset["type"] === "REPOSITORY_BRANCH" &&
|
|
357
|
+
(asset["type"] === "REPOSITORY_BRANCH" &&
|
|
358
|
+
(text(asset["cloudPlatform"])?.toLowerCase() === "github" ||
|
|
359
|
+
isGitHubCloudHost(url.hostname)));
|
|
341
360
|
if (!github)
|
|
342
361
|
return asset["type"] === "REPOSITORY_BRANCH"
|
|
343
362
|
? { url: asset["cloudProviderURL"] }
|
|
@@ -439,6 +458,41 @@ async function readFindingInput(path) {
|
|
|
439
458
|
throw new CodexSecurityError(`Could not read vendor findings as UTF-8 JSON, JSONL, or Wiz CSV: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
|
|
440
459
|
}
|
|
441
460
|
}
|
|
461
|
+
/** Apply Wiz's own reader to an occurrence that also retains another scanner's fields. */
|
|
462
|
+
export function isWizOccurrence(finding, target) {
|
|
463
|
+
const { source_data: data, details } = finding.evidence;
|
|
464
|
+
if (!data || typeof data["id"] !== "string")
|
|
465
|
+
return false;
|
|
466
|
+
const kind = details?.kind;
|
|
467
|
+
const scoped = kind === "sast" || kind === "iac" || kind === "secret";
|
|
468
|
+
if (finding.source_finding_id !==
|
|
469
|
+
(scoped ? `${kind}:${data["id"]}` : data["id"]))
|
|
470
|
+
return false;
|
|
471
|
+
const input = {
|
|
472
|
+
records: [{ value: data, kind: scoped ? kind : "sca" }],
|
|
473
|
+
repositories: new Map(),
|
|
474
|
+
};
|
|
475
|
+
const repository = details?.repository;
|
|
476
|
+
if (scoped && repository?.id)
|
|
477
|
+
input.repositories.set(repository.id, {
|
|
478
|
+
id: repository.id,
|
|
479
|
+
name: repository.name ?? null,
|
|
480
|
+
url: repository.url,
|
|
481
|
+
platform: null,
|
|
482
|
+
});
|
|
483
|
+
// The raw record is the same. Check that Wiz produced the selected evidence,
|
|
484
|
+
// including its own repository binding, before treating upstream fields as opaque.
|
|
485
|
+
const selected = canonicalJson({
|
|
486
|
+
...validateExternalEvidence(finding.evidence, target),
|
|
487
|
+
source_data: undefined,
|
|
488
|
+
});
|
|
489
|
+
const matches = (legacy) => {
|
|
490
|
+
const [row] = normalizeFindings(input, target, undefined, legacy).findings;
|
|
491
|
+
return (row !== undefined &&
|
|
492
|
+
canonicalJson({ ...row.evidence, source_data: undefined }) === selected);
|
|
493
|
+
};
|
|
494
|
+
return matches(false) || (scoped && matches(true));
|
|
495
|
+
}
|
|
442
496
|
function normalizeFindings(input, target, normalized, legacy = false) {
|
|
443
497
|
const result = {
|
|
444
498
|
read: input.records.length,
|
package/dist/wiz-findings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wiz-findings.js","sourceRoot":"","sources":["../src/wiz-findings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,gBAAgB,EAChB,wBAAwB,GAEzB,MAAM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idence,\n type ExternalImportTarget,\n} from \"./external-import-contract.js\";\nimport { asRecord } from \"./record.js\";\nimport { parseJsonOrJsonl, readScannerText, text } from \"./scanner-import.js\";\nimport { isGitHubCloudHost } from \"./git-remote.js\";\nimport { readWizCsv, wizCsvFinding, wizCsvRepositoryUrl } from \"./wiz-csv.js\";\nimport type {\n ExternalFinding as VendorFinding,\n ExternalFindings as VendorFindings,\n ExternalSourceRepository,\n} from \"./external-findings.js\";\n\nfunction sourceFindingId(value: unknown, target: ExternalImportTarget): string {\n const id = text(value);\n if (\n !id ||\n id.includes(\"\\0\") ||\n (target === \"cloud\" && Buffer.byteLength(id) > 512)\n )\n throw new Error(\n target === \"cloud\"\n ? \"Source finding id must contain 1–512 UTF-8 bytes and no NUL characters.\"\n : \"Source finding id must be nonempty and contain no NUL characters.\",\n );\n return id;\n}\n\n/** Keep a Wiz vulnerability occurrence intact; advisory names are not identities. */\nfunction wizFinding(\n record: Record<string, unknown>,\n target: ExternalImportTarget,\n): VendorFinding {\n if (record[\"detectionMethod\"] === \"EXTERNAL_NETWORK_SCAN\")\n throw new Error(\n \"Wiz external network findings are not supported by the package vulnerability mapping.\",\n );\n const id = sourceFindingId(record[\"id\"], target);\n const name = text(record[\"name\"]);\n const packageName = text(record[\"detailedName\"]);\n const version = text(record[\"version\"]);\n const severity = (\n text(record[\"vendorSeverity\"]) ?? text(record[\"severity\"])\n )?.toLowerCase();\n const asset = asRecord(record[\"vulnerableAsset\"]);\n const artifact = asRecord(record[\"artifactType\"]);\n if (!name || !packageName || !text(asset?.[\"id\"])) {\n throw new Error(\n \"Expected a Wiz package vulnerability finding with name, detailedName, and vulnerableAsset.id. Other finding classes need a separate mapping.\",\n );\n }\n const assetType = text(asset?.[\"type\"]);\n const repositoryAsset =\n assetType === \"REPOSITORY_BRANCH\" ||\n asset?.[\"nativeType\"] === \"github#repositoryBranch\";\n // Wiz repository reports prefix root-relative paths with '/'. Workload paths\n // are not source locations and must remain only in the original evidence.\n const locationPath = text(record[\"locationPath\"]);\n const repositoryPath =\n repositoryAsset && locationPath ? locationPath.replace(/^\\/+/, \"\") : null;\n const digest =\n text(asset?.[\"imageDigest\"]) ??\n text(record[\"imageDigest\"]) ??\n (assetType === null ||\n assetType === \"CONTAINER_IMAGE\" ||\n assetType === \"CONTAINER\"\n ? (text(asset?.[\"imageId\"]) ??\n text(asset?.[\"containerImageId\"]) ??\n text(asset?.[\"ImageExternalId\"]))\n : null);\n // lastDetectedAt is not proof that the entire vendor record was updated.\n const evidence = {\n title:\n text(record[\"title\"]) ??\n [packageName, version, name].filter(Boolean).join(\" \"),\n description: text(record[\"description\"]),\n severity: severity === \"none\" ? \"unknown\" : severity,\n url: text(record[\"portalUrl\"]),\n advisory_ids: [text(record[\"vulnerabilityExternalId\"]) ?? name],\n packages: [\n {\n name: packageName,\n ecosystem:\n text(record[\"packageManager\"]) ??\n text(artifact?.[\"osPackageManager\"]) ??\n text(artifact?.[\"codeLibraryLanguage\"]) ??\n text(record[\"codeLibraryLanguage\"]),\n installed_version: version,\n manifest_path: repositoryPath,\n fixed_versions: text(record[\"fixedVersion\"])\n ? [record[\"fixedVersion\"]]\n : [],\n },\n ],\n locations: repositoryPath ? [{ path: repositoryPath }] : [],\n branch: null,\n code_revision: null,\n source_scan_id: null,\n image_digests: digest ? [digest] : [],\n source_updated_at: updatedAt(record[\"updatedAt\"], \"updatedAt\"),\n source_data: record,\n };\n return {\n source_finding_id: id,\n evidence: validateExternalEvidence(evidence, target),\n };\n}\n\ntype RepositoryFindingKind = \"sast\" | \"secret\" | \"iac\";\n\ntype InputRecord = {\n value: unknown;\n kind?: \"sca\" | \"sca_csv\" | RepositoryFindingKind | \"cloud_configuration\";\n};\n\ntype RepositoryMetadata = {\n id: string | null;\n name: string | null;\n url: string;\n};\n\ntype FindingInput = {\n records: InputRecord[];\n repositories: Map<string, RepositoryMetadata & { platform: string | null }>;\n legacyRepositories?: FindingInput[\"repositories\"];\n};\n\n// Wiz's documented inventory platform establishes custom GitHub host semantics.\n// Keep this context separate from the repository metadata published as evidence.\nfunction inventoryRepositoryUrlKey(\n value: string,\n platform: string | null | undefined,\n): string {\n const key = repositoryUrlKey(value);\n return platform === \"GITHUB\" ? key.toLowerCase() : key;\n}\n\nfunction sourceRepository(\n repository: Record<string, unknown> | undefined,\n repositories: FindingInput[\"repositories\"],\n): RepositoryMetadata {\n const id = text(repository?.[\"id\"]);\n const inventory = id ? repositories.get(id) : undefined;\n const suppliedUrl = text(repository?.[\"url\"]);\n if (\n suppliedUrl &&\n inventory &&\n inventoryRepositoryUrlKey(suppliedUrl, inventory.platform) !==\n inventoryRepositoryUrlKey(inventory.url, inventory.platform)\n )\n throw new Error(\n \"The finding and repository inventory have conflicting repository URLs.\",\n );\n const url = suppliedUrl ?? inventory?.url;\n if (!url)\n throw new Error(\n \"A verified source repository URL is required. Include repository.url or the matching repository.id and repository.url from data.versionControlResources.nodes; names and Wiz IDs are not Cloud repository IDs.\",\n );\n return {\n id,\n name: text(repository?.[\"name\"]) ?? inventory?.name ?? null,\n url,\n };\n}\n\nfunction sourceBranch(\n branch: Record<string, unknown> | undefined,\n repository: RepositoryMetadata,\n legacy = false,\n): string | null {\n const name = text(branch?.[\"name\"]);\n if (!name) return null;\n // Repository names and URL paths can both be literal branch prefixes. Keep\n // the old mapping only for an already approved publication checkpoint.\n if (!legacy) return name;\n const qualifiers = repository.name ? [repository.name] : [];\n\n // Include the URL qualifier before selecting the longest repository prefix.\n // Keep URL normalization and the branch suffix's original case and slashes.\n const repositoryKey = repositoryUrlKey(repository.url).toLowerCase();\n const url = /^(https?:\\/\\/[^/?#]+)\\/([^?#]+)$/iu.exec(repositoryKey);\n if (url) {\n const prefixParts = url[2]!.split(\"/\").length;\n const parts = name.split(\"/\");\n const qualifier = parts.slice(0, prefixParts).join(\"/\");\n if (\n parts.length > prefixParts &&\n repositoryUrlKey(url[1] + \"/\" + qualifier).toLowerCase() === repositoryKey\n )\n qualifiers.push(qualifier);\n }\n for (const qualifier of qualifiers.sort(\n (left, right) => right.length - left.length,\n )) {\n const prefix = qualifier + \"/\";\n if (name.toLowerCase().startsWith(prefix.toLowerCase()))\n return name.slice(prefix.length) || null;\n }\n return url || repository.name ? name : null;\n}\n\nfunction updatedAt(value: unknown, field: string): number | null {\n const timestamp = text(value);\n if (!timestamp) return null;\n const seconds = Date.parse(timestamp) / 1000;\n if (!Number.isFinite(seconds) || seconds < 0)\n throw new Error(`Wiz ${field} is not a valid timestamp.`);\n return Math.floor(seconds);\n}\n\n// Empty code and configuration strings are meaningful vendor evidence.\nfunction content(value: unknown): string | null {\n return typeof value === \"string\" ? value : null;\n}\n\n/** Map only explicitly identified repository finding collections. */\nfunction repositoryFinding(\n kind: RepositoryFindingKind,\n record: Record<string, unknown>,\n repositories: FindingInput[\"repositories\"],\n legacy = false,\n target: ExternalImportTarget = \"cloud\",\n): VendorFinding {\n const id = sourceFindingId(record[\"id\"], target);\n const resource = asRecord(record[\"resource\"]);\n if (kind === \"secret\" && resource?.[\"type\"] !== \"REPOSITORY_BRANCH\")\n throw new Error(\n \"Only repository-branch secret findings can be published to a repository. Workload secrets require a resource-scoped import and are not supported.\",\n );\n const suppliedRepository =\n kind === \"secret\"\n ? asRecord(asRecord(resource?.[\"typedProperties\"])?.[\"repository\"])\n : asRecord(record[\"repository\"]);\n const repository = sourceRepository(suppliedRepository, repositories);\n const branch =\n kind === \"secret\"\n ? resource\n : asRecord(record[kind === \"sast\" ? \"repositoryBranch\" : \"branch\"]);\n const rule = asRecord(record[\"rule\"]);\n const path = text(record[kind === \"secret\" ? \"path\" : \"filePath\"]);\n const line = record[kind === \"secret\" ? \"lineNumber\" : \"startLine\"];\n const details = {\n kind,\n repository,\n source_status: text(record[\"status\"]),\n scanner_origin: kind === \"sast\" ? text(record[\"origin\"]) : null,\n scanner_verdict:\n kind === \"sast\"\n ? text(asRecord(record[\"aiAnalysis\"])?.[\"verdict\"])\n : null,\n rule: rule\n ? {\n id: text(rule[\"id\"]),\n short_id: text(rule[\"shortId\"]),\n name: text(rule[\"name\"]),\n }\n : null,\n weakness_ids:\n kind === \"sast\" && Array.isArray(record[\"weaknesses\"])\n ? record[\"weaknesses\"].map((weakness) => asRecord(weakness)?.[\"id\"])\n : [],\n remediation_instructions:\n text(record[\"remediationInstructions\"]) ??\n text(rule?.[\"remediationInstructions\"]),\n code:\n path && kind !== \"secret\"\n ? {\n end_line: record[\"endLine\"] ?? null,\n snippet: content(\n record[kind === \"sast\" ? \"snippet\" : \"matchContent\"],\n ),\n }\n : null,\n secret:\n kind === \"secret\"\n ? {\n type: text(record[\"type\"]),\n confidence: text(record[\"confidence\"]),\n validation_status: text(record[\"validationStatus\"]),\n is_encrypted: record[\"isEncrypted\"] ?? null,\n is_managed: record[\"isManaged\"] ?? null,\n introduced_commit: text(\n asRecord(record[\"vcsDetails\"])?.[\"initialCommitHash\"],\n ),\n }\n : null,\n configuration:\n kind === \"iac\"\n ? {\n platform: text(record[\"platform\"]),\n cloud_platform: text(record[\"cloudPlatform\"]),\n expected: content(record[\"expectedContent\"]),\n actual: content(record[\"foundContent\"]),\n }\n : null,\n file_url: text(record[\"fileURL\"]),\n };\n return {\n // Existing package occurrence IDs remain unchanged. New families cannot\n // collide with one another when the same tenant source key is used.\n source_finding_id: sourceFindingId(`${kind}:${id}`, target),\n evidence: validateExternalEvidence(\n {\n title: text(record[\"name\"]) ?? text(rule?.[\"name\"]),\n severity: text(record[\"severity\"])?.toLowerCase(),\n description: text(record[\"description\"]) ?? text(rule?.[\"description\"]),\n url: text(record[\"wizUrl\"]) ?? text(record[\"portalUrl\"]),\n locations: path ? [{ path, line: line ?? null }] : [],\n branch: sourceBranch(branch, repository, legacy),\n code_revision: null,\n source_scan_id: null,\n source_updated_at:\n kind === \"secret\"\n ? updatedAt(record[\"lastUpdatedAt\"], \"lastUpdatedAt\")\n : kind === \"iac\"\n ? updatedAt(record[\"updatedAt\"], \"updatedAt\")\n : null,\n source_data: record,\n details,\n },\n target,\n ),\n };\n}\n\nfunction records(payload: unknown): FindingInput {\n const repositories: FindingInput[\"repositories\"] = new Map();\n const legacyRepositories: FindingInput[\"repositories\"] = new Map();\n if (Array.isArray(payload))\n return { records: payload.map((value) => ({ value })), repositories };\n const envelope = asRecord(payload);\n if (!envelope)\n throw new Error(\n \"Expected finding objects or a named Wiz finding collection.\",\n );\n if (\n asRecord(envelope[\"scannersRunStatuses\"]) &&\n asRecord(envelope[\"codeAnalyzerDetails\"])\n )\n throw new Error(\n \"This is a Wiz Code & Build Scan event, which contains scan metadata rather than vulnerability records. In Vulnerability Findings, filter the repository and selection, then choose Save as → Report with JSON format and Detailed columns. Download that report instead of Raw Event.\",\n );\n if (Array.isArray(envelope[\"errors\"]) && envelope[\"errors\"].length > 0)\n throw new Error(\n \"Wiz returned GraphQL errors. Resolve them before publishing this response.\",\n );\n if (\n envelope[\"source_finding_id\"] !== undefined ||\n envelope[\"id\"] !== undefined\n )\n return { records: [{ value: envelope }], repositories };\n const data = asRecord(envelope[\"data\"]) ?? envelope;\n const inventory = asRecord(data[\"versionControlResources\"]);\n if (asRecord(inventory?.[\"pageInfo\"])?.[\"hasNextPage\"] === true)\n throw new Error(\n \"Wiz repository inventory has another page. Finish the selected inventory before publishing.\",\n );\n if (Array.isArray(inventory?.[\"nodes\"])) {\n const entries = inventory[\"nodes\"].flatMap((entry) => {\n const node = asRecord(entry);\n const repository = asRecord(node?.[\"repository\"]);\n const id = text(repository?.[\"id\"]);\n const url = text(repository?.[\"url\"]);\n return id && url\n ? [\n {\n id,\n name: text(repository?.[\"name\"]),\n url,\n platform: text(node?.[\"platform\"]),\n },\n ]\n : [];\n });\n // Resolve provider hints before comparing URLs, so duplicate row order cannot\n // discard a known platform or reject a case variant before its GITHUB hint.\n for (const entry of entries) {\n const previous = repositories.get(entry.id);\n if (\n previous?.platform &&\n entry.platform &&\n previous.platform !== entry.platform\n )\n throw new Error(\n `Repository inventory contains conflicting platforms for ${JSON.stringify(entry.id)}.`,\n );\n repositories.set(entry.id, {\n ...entry,\n // Equivalent inventory aliases must produce the same evidence when the\n // export reorders its rows. Keep a stable supplied URL and nonempty name.\n url: previous && previous.url < entry.url ? previous.url : entry.url,\n name:\n previous?.name && (!entry.name || previous.name < entry.name)\n ? previous.name\n : entry.name,\n platform: entry.platform ?? previous?.platform ?? null,\n });\n legacyRepositories.set(entry.id, {\n ...entry,\n platform: entry.platform ?? previous?.platform ?? null,\n });\n }\n for (const entry of entries) {\n const resolved = repositories.get(entry.id)!;\n if (\n inventoryRepositoryUrlKey(entry.url, resolved.platform) !==\n inventoryRepositoryUrlKey(resolved.url, resolved.platform)\n )\n throw new Error(\n `Repository inventory contains conflicting URLs for ${JSON.stringify(entry.id)}.`,\n );\n }\n }\n const collections = {\n vulnerabilityFindings: \"sca\",\n sastFindings: \"sast\",\n secretInstances: \"secret\",\n iacFindings: \"iac\",\n configurationFindings: \"cloud_configuration\",\n } as const;\n const selected: InputRecord[] = [];\n let found = false;\n for (const [root, kind] of Object.entries(collections)) {\n const collection = asRecord(data[root]);\n if (!collection) continue;\n found = true;\n if (!Array.isArray(collection[\"nodes\"]))\n throw new Error(`Wiz ${root}.nodes must be an array.`);\n if (asRecord(collection[\"pageInfo\"])?.[\"hasNextPage\"] === true)\n throw new Error(\n \"Wiz response has another page. Complete the requested pages or save the explicitly selected records in their named collection before publishing.\",\n );\n for (const value of collection[\"nodes\"]) selected.push({ value, kind });\n }\n if (found)\n return {\n records: selected,\n repositories,\n legacyRepositories,\n };\n throw new Error(\n \"Unsupported Wiz export. Supply repository vulnerability CSV, vulnerability finding objects, named sastFindings/secretInstances/iacFindings collections, or normalized JSONL. Other CSV reports need an explicit normalized JSONL mapping.\",\n );\n}\n\n/** The source repository retained by a Wiz package finding or CSV row. */\nexport function wizFindingRepository(\n evidence: VendorFinding[\"evidence\"],\n target: ExternalImportTarget = \"local\",\n): ExternalSourceRepository | undefined {\n const csvUrl = wizCsvRepositoryUrl(evidence);\n if (csvUrl) return { url: csvUrl, platform: \"github\" };\n const asset = asRecord(evidence.source_data?.[\"vulnerableAsset\"]);\n if (!asset || typeof asset[\"cloudProviderURL\"] !== \"string\") 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\" && isGitHubCloudHost(url.hostname));\n if (!github)\n return asset[\"type\"] === \"REPOSITORY_BRANCH\"\n ? { url: asset[\"cloudProviderURL\"] }\n : undefined;\n const [, owner, repository] = url.pathname.split(\"/\");\n if (!owner || !repository) return;\n // URL.origin drops explicit default ports, which the Cloud catalog retains.\n const port =\n target === \"cloud\"\n ? /^https?:\\/\\/[^/?#\\\\]*:(\\d+)(?:[/?#]|$)/iu.exec(\n asset[\"cloudProviderURL\"],\n )?.[1]\n : undefined;\n const origin = port ? `${url.protocol}//${url.hostname}:${port}` : url.origin;\n return { url: `${origin}/${owner}/${repository}`, platform: \"github\" };\n}\n\nexport async function readVendorFindings(\n path: string,\n target: ExternalImportTarget = \"cloud\",\n): Promise<VendorFindings> {\n return normalizeFindings(await readFindingInput(path), target);\n}\n\nfunction inventorySources(input: FindingInput, current: VendorFindings) {\n return current.findings.flatMap(({ evidence }) => {\n const repository = evidence.details?.repository;\n const inventory = input.repositories.get(repository?.id ?? \"\");\n // Forward provenance only for selected findings that match the inventory.\n // Use the emitted spelling so typed evidence and reader hints share it.\n return repository &&\n inventory?.platform === \"GITHUB\" &&\n inventoryRepositoryUrlKey(repository.url, inventory.platform) ===\n inventoryRepositoryUrlKey(inventory.url, inventory.platform)\n ? [{ url: repository.url, platform: \"github\" as const }]\n : [];\n });\n}\n\nexport async function readLocalWizFindings(path: string) {\n const input = await readFindingInput(path);\n const current = normalizeFindings(input, \"local\");\n return { current, sourceRepositories: inventorySources(input, current) };\n}\n\n/** @internal Preserve older inventory projections only for saved publication replay. */\nexport async function readVendorFindingsForPublication(\n path: string,\n target: ExternalImportTarget = \"cloud\",\n): Promise<{\n current: VendorFindings;\n legacy: VendorFindings;\n currentIdentity: unknown[];\n legacyIdentity: unknown[];\n sourceRepositories: ExternalSourceRepository[];\n}> {\n const input = await readFindingInput(path);\n const normalized = new WeakSet<VendorFinding>();\n const current = normalizeFindings(input, target, normalized);\n // Only repository finding families use historical inventory and branch mapping.\n const hasRepositoryFindings = input.records.some(\n ({ kind }) => kind === \"sast\" || kind === \"secret\" || kind === \"iac\",\n );\n const legacy = hasRepositoryFindings\n ? normalizeFindings(\n {\n ...input,\n repositories: input.legacyRepositories ?? input.repositories,\n },\n target,\n normalized,\n true,\n )\n : current;\n const identity = (parsed: VendorFindings) =>\n parsed.findings.map((finding) => {\n if (normalized.has(finding)) return finding;\n const repository = finding.evidence.details?.repository;\n return {\n source_finding_id: finding.source_finding_id,\n evidence: {\n // Raw vendor records retain every original branch/ref and source field.\n // Inventory display aliases must not change an outstanding request's identity.\n source_data: finding.evidence.source_data,\n repository: repository\n ? {\n id: repository.id,\n // Publication targets use Cloud's GitHub URL semantics. Input\n // joins above still require provenance for custom-host folding.\n url: repositoryUrlKey(repository.url).toLowerCase(),\n }\n : null,\n },\n };\n });\n const currentIdentity = identity(current);\n return {\n current,\n legacy,\n currentIdentity,\n legacyIdentity: legacy === current ? currentIdentity : identity(legacy),\n sourceRepositories: inventorySources(input, current),\n };\n}\n\nasync function readFindingInput(path: string): Promise<FindingInput> {\n try {\n const contents = await readScannerText(path);\n let payload: unknown;\n try {\n payload = JSON.parse(contents);\n } catch {\n const csv = readWizCsv(contents);\n if (csv)\n return {\n records: csv.map((value) => ({ value, kind: \"sca_csv\" })),\n repositories: new Map(),\n };\n payload = parseJsonOrJsonl(contents);\n }\n return records(payload);\n } catch (cause) {\n throw new CodexSecurityError(\n `Could not read vendor findings as UTF-8 JSON, JSONL, or Wiz CSV: ${cause instanceof Error ? cause.message : String(cause)}`,\n { cause },\n );\n }\n}\n\nfunction normalizeFindings(\n input: FindingInput,\n target: ExternalImportTarget,\n normalized?: WeakSet<VendorFinding>,\n legacy = false,\n): VendorFindings {\n const result: VendorFindings = {\n read: input.records.length,\n findings: [],\n excluded: [],\n };\n const identities = new Set<string>();\n for (const [index, item] of input.records.entries()) {\n const record = asRecord(item.value);\n try {\n if (!record) throw new Error(\"Finding must be an object.\");\n let finding: VendorFinding;\n if (item.kind === \"sca_csv\") {\n finding = wizCsvFinding(\n record,\n sourceFindingId(record[\"ID\"], target),\n target,\n );\n } else if (\"source_finding_id\" in record) {\n if (\n Object.keys(record).some(\n (key) => ![\"source_finding_id\", \"evidence\"].includes(key),\n )\n ) {\n throw new Error(\n \"Normalized input permits only source_finding_id and evidence.\",\n );\n }\n finding = {\n source_finding_id: sourceFindingId(\n record[\"source_finding_id\"],\n target,\n ),\n evidence: validateExternalEvidence(record[\"evidence\"], target),\n };\n } else if (item.kind === \"cloud_configuration\") {\n throw new Error(\n \"Cloud configuration findings require a resource-scoped import and cannot be published to a repository.\",\n );\n } else if (item.kind && item.kind !== \"sca\") {\n finding = repositoryFinding(\n item.kind,\n record,\n input.repositories,\n legacy,\n target,\n );\n } else {\n if (\n !item.kind &&\n (asRecord(record[\"repository\"]) ||\n asRecord(record[\"repositoryBranch\"]) ||\n asRecord(record[\"resource\"]))\n )\n throw new Error(\n \"Raw SAST, secret, and IaC records require their named sastFindings, secretInstances, or iacFindings collection. Bare arrays do not identify the finding family; use normalized JSONL for an explicit mapping.\",\n );\n finding = wizFinding(record, target);\n }\n if (identities.has(finding.source_finding_id)) {\n throw new CodexSecurityError(\n `Duplicate source finding id ${JSON.stringify(finding.source_finding_id)}. Select each vendor occurrence once.`,\n );\n }\n identities.add(finding.source_finding_id);\n result.findings.push(finding);\n if (item.kind !== \"sca_csv\" && \"source_finding_id\" in record)\n normalized?.add(finding);\n } catch (error) {\n if (error instanceof CodexSecurityError) throw error;\n result.excluded.push({\n position: index + 1,\n source_finding_id:\n item.kind === \"sca_csv\"\n ? text(record?.[\"ID\"])\n : (text(record?.[\"source_finding_id\"]) ?? text(record?.[\"id\"])),\n reason: error instanceof Error ? error.message : String(error),\n });\n }\n }\n return result;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"wiz-findings.js","sourceRoot":"","sources":["../src/wiz-findings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,gBAAgB,EAChB,wBAAwB,GAEzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAO9E,SAAS,eAAe,CAAC,KAAc,EAAE,MAA4B;IACnE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IACvB,IACE,CAAC,EAAE;QACH,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;QACjB,CAAC,MAAM,KAAK,OAAO,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;QAEnD,MAAM,IAAI,KAAK,CACb,MAAM,KAAK,OAAO;YAChB,CAAC,CAAC,yEAAyE;YAC3E,CAAC,CAAC,mEAAmE,CACxE,CAAC;IACJ,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,mBAAmB,CACjC,IAA8C;IAE9C,OAAO,OAAO,CACZ,IAAI;QACJ,IAAI,CAAC,iBAAiB,CAAC,KAAK,uBAAuB;QACnD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC1B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,iB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CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,mBAAmB,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;gBACnE,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC/D,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { CodexSecurityError } from \"./errors.js\";\nimport {\n repositoryUrlKey,\n validateExternalEvidence,\n type ExternalImportTarget,\n} from \"./external-import-contract.js\";\nimport { asRecord, canonicalJson } from \"./record.js\";\nimport { parseJsonOrJsonl, readScannerText, text } from \"./scanner-import.js\";\nimport { isGitHubCloudHost } from \"./git-remote.js\";\nimport { readWizCsv, wizCsvFinding, wizCsvRepositoryUrl } from \"./wiz-csv.js\";\nimport type {\n ExternalFinding as VendorFinding,\n ExternalFindings as VendorFindings,\n ExternalSourceRepository,\n} from \"./external-findings.js\";\n\nfunction sourceFindingId(value: unknown, target: ExternalImportTarget): string {\n const id = text(value);\n if (\n !id ||\n id.includes(\"\\0\") ||\n (target === \"cloud\" && Buffer.byteLength(id) > 512)\n )\n throw new Error(\n target === \"cloud\"\n ? \"Source finding id must contain 1–512 UTF-8 bytes and no NUL characters.\"\n : \"Source finding id must be nonempty and contain no NUL characters.\",\n );\n return id;\n}\n\n/** Distinguish original Wiz package records from opaque SDK asset metadata. */\nexport function isWizPackageFinding(\n data: VendorFinding[\"evidence\"][\"source_data\"],\n): boolean {\n return Boolean(\n data &&\n data[\"detectionMethod\"] !== \"EXTERNAL_NETWORK_SCAN\" &&\n text(data[\"id\"]) &&\n text(data[\"name\"]) &&\n text(data[\"detailedName\"]) &&\n text(asRecord(data[\"vulnerableAsset\"])?.[\"id\"]),\n );\n}\n\n/** Keep a Wiz vulnerability occurrence intact; advisory names are not identities. */\nfunction wizFinding(\n record: Record<string, unknown>,\n target: ExternalImportTarget,\n): VendorFinding {\n if (record[\"detectionMethod\"] === \"EXTERNAL_NETWORK_SCAN\")\n throw new Error(\n \"Wiz external network findings are not supported by the package vulnerability mapping.\",\n );\n const id = sourceFindingId(record[\"id\"], target);\n const name = text(record[\"name\"]);\n const packageName = text(record[\"detailedName\"]);\n const version = text(record[\"version\"]);\n const severity = (\n text(record[\"vendorSeverity\"]) ?? text(record[\"severity\"])\n )?.toLowerCase();\n const asset = asRecord(record[\"vulnerableAsset\"]);\n const artifact = asRecord(record[\"artifactType\"]);\n if (!name || !packageName || !text(asset?.[\"id\"])) {\n throw new Error(\n \"Expected a Wiz package vulnerability finding with name, detailedName, and vulnerableAsset.id. Other finding classes need a separate mapping.\",\n );\n }\n const assetType = text(asset?.[\"type\"]);\n const repositoryAsset =\n assetType === \"REPOSITORY_BRANCH\" ||\n asset?.[\"nativeType\"] === \"github#repositoryBranch\";\n // Wiz repository reports prefix root-relative paths with '/'. Workload paths\n // are not source locations and must remain only in the original evidence.\n const locationPath = text(record[\"locationPath\"]);\n const repositoryPath =\n repositoryAsset && locationPath ? locationPath.replace(/^\\/+/, \"\") : null;\n const digest =\n text(asset?.[\"imageDigest\"]) ??\n text(record[\"imageDigest\"]) ??\n (assetType === null ||\n assetType === \"CONTAINER_IMAGE\" ||\n assetType === \"CONTAINER\"\n ? (text(asset?.[\"imageId\"]) ??\n text(asset?.[\"containerImageId\"]) ??\n text(asset?.[\"ImageExternalId\"]))\n : null);\n // lastDetectedAt is not proof that the entire vendor record was updated.\n const evidence = {\n title:\n text(record[\"title\"]) ??\n [packageName, version, name].filter(Boolean).join(\" \"),\n description: text(record[\"description\"]),\n severity: severity === \"none\" ? \"unknown\" : severity,\n url: text(record[\"portalUrl\"]),\n advisory_ids: [text(record[\"vulnerabilityExternalId\"]) ?? name],\n packages: [\n {\n name: packageName,\n ecosystem:\n text(record[\"packageManager\"]) ??\n text(artifact?.[\"osPackageManager\"]) ??\n text(artifact?.[\"codeLibraryLanguage\"]) ??\n text(record[\"codeLibraryLanguage\"]),\n installed_version: version,\n manifest_path: repositoryPath,\n fixed_versions: text(record[\"fixedVersion\"])\n ? [record[\"fixedVersion\"]]\n : [],\n },\n ],\n locations: repositoryPath ? [{ path: repositoryPath }] : [],\n branch: null,\n code_revision: null,\n source_scan_id: null,\n image_digests: digest ? [digest] : [],\n source_updated_at: updatedAt(record[\"updatedAt\"], \"updatedAt\"),\n source_data: record,\n };\n return {\n source_finding_id: id,\n evidence: validateExternalEvidence(evidence, target),\n };\n}\n\ntype RepositoryFindingKind = \"sast\" | \"secret\" | \"iac\";\n\ntype InputRecord = {\n value: unknown;\n kind?: \"sca\" | \"sca_csv\" | RepositoryFindingKind | \"cloud_configuration\";\n};\n\ntype RepositoryMetadata = {\n id: string | null;\n name: string | null;\n url: string;\n};\n\ntype FindingInput = {\n records: InputRecord[];\n repositories: Map<string, RepositoryMetadata & { platform: string | null }>;\n legacyRepositories?: FindingInput[\"repositories\"];\n};\n\n// Wiz's documented inventory platform establishes custom GitHub host semantics.\n// Keep this context separate from the repository metadata published as evidence.\nfunction inventoryRepositoryUrlKey(\n value: string,\n platform: string | null | undefined,\n): string {\n const key = repositoryUrlKey(value);\n return platform === \"GITHUB\" ? key.toLowerCase() : key;\n}\n\nfunction sourceRepository(\n repository: Record<string, unknown> | undefined,\n repositories: FindingInput[\"repositories\"],\n): RepositoryMetadata {\n const id = text(repository?.[\"id\"]);\n const inventory = id ? repositories.get(id) : undefined;\n const suppliedUrl = text(repository?.[\"url\"]);\n if (\n suppliedUrl &&\n inventory &&\n inventoryRepositoryUrlKey(suppliedUrl, inventory.platform) !==\n inventoryRepositoryUrlKey(inventory.url, inventory.platform)\n )\n throw new Error(\n \"The finding and repository inventory have conflicting repository URLs.\",\n );\n const url = suppliedUrl ?? inventory?.url;\n if (!url)\n throw new Error(\n \"A verified source repository URL is required. Include repository.url or the matching repository.id and repository.url from data.versionControlResources.nodes; names and Wiz IDs are not Cloud repository IDs.\",\n );\n return {\n id,\n name: text(repository?.[\"name\"]) ?? inventory?.name ?? null,\n url,\n };\n}\n\nfunction sourceBranch(\n branch: Record<string, unknown> | undefined,\n repository: RepositoryMetadata,\n legacy = false,\n): string | null {\n const name = text(branch?.[\"name\"]);\n if (!name) return null;\n // Repository names and URL paths can both be literal branch prefixes. Keep\n // the old mapping only for an already approved publication checkpoint.\n if (!legacy) return name;\n const qualifiers = repository.name ? [repository.name] : [];\n\n // Include the URL qualifier before selecting the longest repository prefix.\n // Keep URL normalization and the branch suffix's original case and slashes.\n const repositoryKey = repositoryUrlKey(repository.url).toLowerCase();\n const url = /^(https?:\\/\\/[^/?#]+)\\/([^?#]+)$/iu.exec(repositoryKey);\n if (url) {\n const prefixParts = url[2]!.split(\"/\").length;\n const parts = name.split(\"/\");\n const qualifier = parts.slice(0, prefixParts).join(\"/\");\n if (\n parts.length > prefixParts &&\n repositoryUrlKey(url[1] + \"/\" + qualifier).toLowerCase() === repositoryKey\n )\n qualifiers.push(qualifier);\n }\n for (const qualifier of qualifiers.sort(\n (left, right) => right.length - left.length,\n )) {\n const prefix = qualifier + \"/\";\n if (name.toLowerCase().startsWith(prefix.toLowerCase()))\n return name.slice(prefix.length) || null;\n }\n return url || repository.name ? name : null;\n}\n\nfunction updatedAt(value: unknown, field: string): number | null {\n const timestamp = text(value);\n if (!timestamp) return null;\n const seconds = Date.parse(timestamp) / 1000;\n if (!Number.isFinite(seconds) || seconds < 0)\n throw new Error(`Wiz ${field} is not a valid timestamp.`);\n return Math.floor(seconds);\n}\n\n// Empty code and configuration strings are meaningful vendor evidence.\nfunction content(value: unknown): string | null {\n return typeof value === \"string\" ? value : null;\n}\n\n/** Map only explicitly identified repository finding collections. */\nfunction repositoryFinding(\n kind: RepositoryFindingKind,\n record: Record<string, unknown>,\n repositories: FindingInput[\"repositories\"],\n legacy = false,\n target: ExternalImportTarget = \"cloud\",\n): VendorFinding {\n const id = sourceFindingId(record[\"id\"], target);\n const resource = asRecord(record[\"resource\"]);\n if (kind === \"secret\" && resource?.[\"type\"] !== \"REPOSITORY_BRANCH\")\n throw new Error(\n \"Only repository-branch secret findings can be published to a repository. Workload secrets require a resource-scoped import and are not supported.\",\n );\n const suppliedRepository =\n kind === \"secret\"\n ? asRecord(asRecord(resource?.[\"typedProperties\"])?.[\"repository\"])\n : asRecord(record[\"repository\"]);\n const repository = sourceRepository(suppliedRepository, repositories);\n const branch =\n kind === \"secret\"\n ? resource\n : asRecord(record[kind === \"sast\" ? \"repositoryBranch\" : \"branch\"]);\n const rule = asRecord(record[\"rule\"]);\n const path = text(record[kind === \"secret\" ? \"path\" : \"filePath\"]);\n const line = record[kind === \"secret\" ? \"lineNumber\" : \"startLine\"];\n const details = {\n kind,\n repository,\n source_status: text(record[\"status\"]),\n scanner_origin: kind === \"sast\" ? text(record[\"origin\"]) : null,\n scanner_verdict:\n kind === \"sast\"\n ? text(asRecord(record[\"aiAnalysis\"])?.[\"verdict\"])\n : null,\n rule: rule\n ? {\n id: text(rule[\"id\"]),\n short_id: text(rule[\"shortId\"]),\n name: text(rule[\"name\"]),\n }\n : null,\n weakness_ids:\n kind === \"sast\" && Array.isArray(record[\"weaknesses\"])\n ? record[\"weaknesses\"].map((weakness) => asRecord(weakness)?.[\"id\"])\n : [],\n remediation_instructions:\n text(record[\"remediationInstructions\"]) ??\n text(rule?.[\"remediationInstructions\"]),\n code:\n path && kind !== \"secret\"\n ? {\n end_line: record[\"endLine\"] ?? null,\n snippet: content(\n record[kind === \"sast\" ? \"snippet\" : \"matchContent\"],\n ),\n }\n : null,\n secret:\n kind === \"secret\"\n ? {\n type: text(record[\"type\"]),\n confidence: text(record[\"confidence\"]),\n validation_status: text(record[\"validationStatus\"]),\n is_encrypted: record[\"isEncrypted\"] ?? null,\n is_managed: record[\"isManaged\"] ?? null,\n introduced_commit: text(\n asRecord(record[\"vcsDetails\"])?.[\"initialCommitHash\"],\n ),\n }\n : null,\n configuration:\n kind === \"iac\"\n ? {\n platform: text(record[\"platform\"]),\n cloud_platform: text(record[\"cloudPlatform\"]),\n expected: content(record[\"expectedContent\"]),\n actual: content(record[\"foundContent\"]),\n }\n : null,\n file_url: text(record[\"fileURL\"]),\n };\n return {\n // Existing package occurrence IDs remain unchanged. New families cannot\n // collide with one another when the same tenant source key is used.\n source_finding_id: sourceFindingId(`${kind}:${id}`, target),\n evidence: validateExternalEvidence(\n {\n title: text(record[\"name\"]) ?? text(rule?.[\"name\"]),\n severity: text(record[\"severity\"])?.toLowerCase(),\n description: text(record[\"description\"]) ?? text(rule?.[\"description\"]),\n url: text(record[\"wizUrl\"]) ?? text(record[\"portalUrl\"]),\n locations: path ? [{ path, line: line ?? null }] : [],\n branch: sourceBranch(branch, repository, legacy),\n code_revision: null,\n source_scan_id: null,\n source_updated_at:\n kind === \"secret\"\n ? updatedAt(record[\"lastUpdatedAt\"], \"lastUpdatedAt\")\n : kind === \"iac\"\n ? updatedAt(record[\"updatedAt\"], \"updatedAt\")\n : null,\n source_data: record,\n details,\n },\n target,\n ),\n };\n}\n\nfunction records(payload: unknown): FindingInput {\n const repositories: FindingInput[\"repositories\"] = new Map();\n const legacyRepositories: FindingInput[\"repositories\"] = new Map();\n if (Array.isArray(payload))\n return { records: payload.map((value) => ({ value })), repositories };\n const envelope = asRecord(payload);\n if (!envelope)\n throw new Error(\n \"Expected finding objects or a named Wiz finding collection.\",\n );\n if (\n asRecord(envelope[\"scannersRunStatuses\"]) &&\n asRecord(envelope[\"codeAnalyzerDetails\"])\n )\n throw new Error(\n \"This is a Wiz Code & Build Scan event, which contains scan metadata rather than vulnerability records. In Vulnerability Findings, filter the repository and selection, then choose Save as → Report with JSON format and Detailed columns. Download that report instead of Raw Event.\",\n );\n if (Array.isArray(envelope[\"errors\"]) && envelope[\"errors\"].length > 0)\n throw new Error(\n \"Wiz returned GraphQL errors. Resolve them before publishing this response.\",\n );\n if (\n envelope[\"source_finding_id\"] !== undefined ||\n envelope[\"id\"] !== undefined\n )\n return { records: [{ value: envelope }], repositories };\n const data = asRecord(envelope[\"data\"]) ?? envelope;\n const inventory = asRecord(data[\"versionControlResources\"]);\n if (asRecord(inventory?.[\"pageInfo\"])?.[\"hasNextPage\"] === true)\n throw new Error(\n \"Wiz repository inventory has another page. Finish the selected inventory before publishing.\",\n );\n if (Array.isArray(inventory?.[\"nodes\"])) {\n const entries = inventory[\"nodes\"].flatMap((entry) => {\n const node = asRecord(entry);\n const repository = asRecord(node?.[\"repository\"]);\n const id = text(repository?.[\"id\"]);\n const url = text(repository?.[\"url\"]);\n return id && url\n ? [\n {\n id,\n name: text(repository?.[\"name\"]),\n url,\n platform: text(node?.[\"platform\"]),\n },\n ]\n : [];\n });\n // Resolve provider hints before comparing URLs, so duplicate row order cannot\n // discard a known platform or reject a case variant before its GITHUB hint.\n for (const entry of entries) {\n const previous = repositories.get(entry.id);\n if (\n previous?.platform &&\n entry.platform &&\n previous.platform !== entry.platform\n )\n throw new Error(\n `Repository inventory contains conflicting platforms for ${JSON.stringify(entry.id)}.`,\n );\n repositories.set(entry.id, {\n ...entry,\n // Equivalent inventory aliases must produce the same evidence when the\n // export reorders its rows. Keep a stable supplied URL and nonempty name.\n url: previous && previous.url < entry.url ? previous.url : entry.url,\n name:\n previous?.name && (!entry.name || previous.name < entry.name)\n ? previous.name\n : entry.name,\n platform: entry.platform ?? previous?.platform ?? null,\n });\n legacyRepositories.set(entry.id, {\n ...entry,\n platform: entry.platform ?? previous?.platform ?? null,\n });\n }\n for (const entry of entries) {\n const resolved = repositories.get(entry.id)!;\n if (\n inventoryRepositoryUrlKey(entry.url, resolved.platform) !==\n inventoryRepositoryUrlKey(resolved.url, resolved.platform)\n )\n throw new Error(\n `Repository inventory contains conflicting URLs for ${JSON.stringify(entry.id)}.`,\n );\n }\n }\n const collections = {\n vulnerabilityFindings: \"sca\",\n sastFindings: \"sast\",\n secretInstances: \"secret\",\n iacFindings: \"iac\",\n configurationFindings: \"cloud_configuration\",\n } as const;\n const selected: InputRecord[] = [];\n let found = false;\n let countedCollection: string | undefined;\n for (const [root, kind] of Object.entries(collections)) {\n if (!(root in data)) continue;\n const collection = asRecord(data[root]);\n if (!collection)\n throw new Error(`Wiz ${root} must be an object with a nodes array.`);\n found = true;\n if (!Array.isArray(collection[\"nodes\"]))\n throw new Error(`Wiz ${root}.nodes must be an array.`);\n if (asRecord(collection[\"pageInfo\"])?.[\"hasNextPage\"] === true)\n throw new Error(\n \"Wiz response has another page. Complete the requested pages or save the explicitly selected records in their named collection before publishing.\",\n );\n const total = collection[\"totalCount\"];\n if (typeof total === \"number\" && total > 0) countedCollection = root;\n for (const value of collection[\"nodes\"]) selected.push({ value, kind });\n }\n if (!selected.length && countedCollection)\n throw new Error(\n `Wiz ${countedCollection}.totalCount reports findings, but the export contains no finding nodes.`,\n );\n if (found)\n return {\n records: selected,\n repositories,\n legacyRepositories,\n };\n throw new Error(\n \"Unsupported Wiz export. Supply repository vulnerability CSV, vulnerability finding objects, named sastFindings/secretInstances/iacFindings collections, or normalized JSONL. Other CSV reports need an explicit normalized JSONL mapping.\",\n );\n}\n\n/** The source repository retained by a Wiz package finding or CSV row. */\nexport function wizFindingRepository(\n evidence: VendorFinding[\"evidence\"],\n target: ExternalImportTarget = \"local\",\n): ExternalSourceRepository | undefined {\n const csvUrl = wizCsvRepositoryUrl(evidence);\n if (csvUrl) return { url: csvUrl, platform: \"github\" };\n const asset = asRecord(evidence.source_data?.[\"vulnerableAsset\"]);\n if (!asset || typeof asset[\"cloudProviderURL\"] !== \"string\") 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 (text(asset[\"cloudPlatform\"])?.toLowerCase() === \"github\" ||\n isGitHubCloudHost(url.hostname)));\n if (!github)\n return asset[\"type\"] === \"REPOSITORY_BRANCH\"\n ? { url: asset[\"cloudProviderURL\"] }\n : undefined;\n const [, owner, repository] = url.pathname.split(\"/\");\n if (!owner || !repository) return;\n // URL.origin drops explicit default ports, which the Cloud catalog retains.\n const port =\n target === \"cloud\"\n ? /^https?:\\/\\/[^/?#\\\\]*:(\\d+)(?:[/?#]|$)/iu.exec(\n asset[\"cloudProviderURL\"],\n )?.[1]\n : undefined;\n const origin = port ? `${url.protocol}//${url.hostname}:${port}` : url.origin;\n return { url: `${origin}/${owner}/${repository}`, platform: \"github\" };\n}\n\nexport async function readVendorFindings(\n path: string,\n target: ExternalImportTarget = \"cloud\",\n): Promise<VendorFindings> {\n return normalizeFindings(await readFindingInput(path), target);\n}\n\nfunction inventorySources(input: FindingInput, current: VendorFindings) {\n return current.findings.flatMap(({ evidence }) => {\n const repository = evidence.details?.repository;\n const inventory = input.repositories.get(repository?.id ?? \"\");\n // Forward provenance only for selected findings that match the inventory.\n // Use the emitted spelling so typed evidence and reader hints share it.\n return repository &&\n inventory?.platform === \"GITHUB\" &&\n inventoryRepositoryUrlKey(repository.url, inventory.platform) ===\n inventoryRepositoryUrlKey(inventory.url, inventory.platform)\n ? [{ url: repository.url, platform: \"github\" as const }]\n : [];\n });\n}\n\nexport async function readLocalWizFindings(path: string) {\n const input = await readFindingInput(path);\n const current = normalizeFindings(input, \"local\");\n return { current, sourceRepositories: inventorySources(input, current) };\n}\n\n/** @internal Preserve older inventory projections only for saved publication replay. */\nexport async function readVendorFindingsForPublication(\n path: string,\n target: ExternalImportTarget = \"cloud\",\n): Promise<{\n current: VendorFindings;\n legacy: VendorFindings;\n currentIdentity: unknown[];\n legacyIdentity: unknown[];\n sourceRepositories: ExternalSourceRepository[];\n}> {\n const input = await readFindingInput(path);\n const normalized = new WeakSet<VendorFinding>();\n const current = normalizeFindings(input, target, normalized);\n // Only repository finding families use historical inventory and branch mapping.\n const hasRepositoryFindings = input.records.some(\n ({ kind }) => kind === \"sast\" || kind === \"secret\" || kind === \"iac\",\n );\n const legacy = hasRepositoryFindings\n ? normalizeFindings(\n {\n ...input,\n repositories: input.legacyRepositories ?? input.repositories,\n },\n target,\n normalized,\n true,\n )\n : current;\n const identity = (parsed: VendorFindings) =>\n parsed.findings.map((finding) => {\n if (normalized.has(finding)) return finding;\n const repository = finding.evidence.details?.repository;\n return {\n source_finding_id: finding.source_finding_id,\n evidence: {\n // Raw vendor records retain every original branch/ref and source field.\n // Inventory display aliases must not change an outstanding request's identity.\n source_data: finding.evidence.source_data,\n repository: repository\n ? {\n id: repository.id,\n // Publication targets use Cloud's GitHub URL semantics. Input\n // joins above still require provenance for custom-host folding.\n url: repositoryUrlKey(repository.url).toLowerCase(),\n }\n : null,\n },\n };\n });\n const currentIdentity = identity(current);\n return {\n current,\n legacy,\n currentIdentity,\n legacyIdentity: legacy === current ? currentIdentity : identity(legacy),\n sourceRepositories: inventorySources(input, current),\n };\n}\n\nasync function readFindingInput(path: string): Promise<FindingInput> {\n try {\n const contents = await readScannerText(path);\n let payload: unknown;\n try {\n payload = JSON.parse(contents);\n } catch {\n const csv = readWizCsv(contents);\n if (csv)\n return {\n records: csv.map((value) => ({ value, kind: \"sca_csv\" })),\n repositories: new Map(),\n };\n payload = parseJsonOrJsonl(contents);\n }\n return records(payload);\n } catch (cause) {\n throw new CodexSecurityError(\n `Could not read vendor findings as UTF-8 JSON, JSONL, or Wiz CSV: ${cause instanceof Error ? cause.message : String(cause)}`,\n { cause },\n );\n }\n}\n\n/** Apply Wiz's own reader to an occurrence that also retains another scanner's fields. */\nexport function isWizOccurrence(\n finding: VendorFinding,\n target: ExternalImportTarget,\n): boolean {\n const { source_data: data, details } = finding.evidence;\n if (!data || typeof data[\"id\"] !== \"string\") return false;\n const kind = details?.kind;\n const scoped = kind === \"sast\" || kind === \"iac\" || kind === \"secret\";\n if (\n finding.source_finding_id !==\n (scoped ? `${kind}:${data[\"id\"]}` : data[\"id\"])\n )\n return false;\n const input: FindingInput = {\n records: [{ value: data, kind: scoped ? kind : \"sca\" }],\n repositories: new Map(),\n };\n const repository = details?.repository;\n if (scoped && repository?.id)\n input.repositories.set(repository.id, {\n id: repository.id,\n name: repository.name ?? null,\n url: repository.url,\n platform: null,\n });\n // The raw record is the same. Check that Wiz produced the selected evidence,\n // including its own repository binding, before treating upstream fields as opaque.\n const selected = canonicalJson({\n ...validateExternalEvidence(finding.evidence, target),\n source_data: undefined,\n });\n const matches = (legacy: boolean) => {\n const [row] = normalizeFindings(input, target, undefined, legacy).findings;\n return (\n row !== undefined &&\n canonicalJson({ ...row.evidence, source_data: undefined }) === selected\n );\n };\n return matches(false) || (scoped && matches(true));\n}\n\nfunction normalizeFindings(\n input: FindingInput,\n target: ExternalImportTarget,\n normalized?: WeakSet<VendorFinding>,\n legacy = false,\n): VendorFindings {\n const result: VendorFindings = {\n read: input.records.length,\n findings: [],\n excluded: [],\n };\n const identities = new Set<string>();\n for (const [index, item] of input.records.entries()) {\n const record = asRecord(item.value);\n try {\n if (!record) throw new Error(\"Finding must be an object.\");\n let finding: VendorFinding;\n if (item.kind === \"sca_csv\") {\n finding = wizCsvFinding(\n record,\n sourceFindingId(record[\"ID\"], target),\n target,\n );\n } else if (\"source_finding_id\" in record) {\n if (\n Object.keys(record).some(\n (key) => ![\"source_finding_id\", \"evidence\"].includes(key),\n )\n ) {\n throw new Error(\n \"Normalized input permits only source_finding_id and evidence.\",\n );\n }\n finding = {\n source_finding_id: sourceFindingId(\n record[\"source_finding_id\"],\n target,\n ),\n evidence: validateExternalEvidence(record[\"evidence\"], target),\n };\n } else if (item.kind === \"cloud_configuration\") {\n throw new Error(\n \"Cloud configuration findings require a resource-scoped import and cannot be published to a repository.\",\n );\n } else if (item.kind && item.kind !== \"sca\") {\n finding = repositoryFinding(\n item.kind,\n record,\n input.repositories,\n legacy,\n target,\n );\n } else {\n if (\n !item.kind &&\n (asRecord(record[\"repository\"]) ||\n asRecord(record[\"repositoryBranch\"]) ||\n asRecord(record[\"resource\"]))\n )\n throw new Error(\n \"Raw SAST, secret, and IaC records require their named sastFindings, secretInstances, or iacFindings collection. Bare arrays do not identify the finding family; use normalized JSONL for an explicit mapping.\",\n );\n finding = wizFinding(record, target);\n }\n if (identities.has(finding.source_finding_id)) {\n throw new CodexSecurityError(\n `Duplicate source finding id ${JSON.stringify(finding.source_finding_id)}. Select each vendor occurrence once.`,\n );\n }\n identities.add(finding.source_finding_id);\n result.findings.push(finding);\n if (item.kind !== \"sca_csv\" && \"source_finding_id\" in record)\n normalized?.add(finding);\n } catch (error) {\n if (error instanceof CodexSecurityError) throw error;\n result.excluded.push({\n position: index + 1,\n source_finding_id:\n item.kind === \"sca_csv\"\n ? text(record?.[\"ID\"])\n : (text(record?.[\"source_finding_id\"]) ?? text(record?.[\"id\"])),\n reason: error instanceof Error ? error.message : String(error),\n });\n }\n }\n return result;\n}\n"]}
|
|
@@ -6,28 +6,42 @@ state. It uses the same bidirectional JSON-RPC transport as [record deduplicatio
|
|
|
6
6
|
Use `--records` alone or with `--runs N`; model execution remains host-provided.
|
|
7
7
|
|
|
8
8
|
The SDK exports `classifySeverityRecords`, `classifySeverityRecordsInputSchema`,
|
|
9
|
-
and their input, result, and review-request types. The protocol and input
|
|
10
|
-
version `1`. Before using the protocol, confirm that your installed CLI lists
|
|
11
|
-
`--records` in `classify-severity --help`.
|
|
9
|
+
and their input, result, and review-request types. The protocol and input use version `1`.
|
|
12
10
|
|
|
13
11
|
## Immutable inputs
|
|
14
12
|
|
|
15
|
-
Send one
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
Send one JSON-RPC `run` request. This Node.js example prints the complete
|
|
14
|
+
request as one line of JSON. Replace the model name with one your host
|
|
15
|
+
authorizes. Write that line to the CLI's stdin and keep the pipe open to
|
|
16
|
+
[reply to each review](#host-execution-contract).
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
import { createHash } from "node:crypto";
|
|
20
|
+
|
|
21
|
+
const id = "canonical-one";
|
|
22
|
+
const findingJson = JSON.stringify({
|
|
23
|
+
findingId: id,
|
|
24
|
+
title: "Missing tenant filter",
|
|
25
|
+
summary: "The invoice lookup omits the tenant ID.",
|
|
26
|
+
});
|
|
27
|
+
const inputSha256 = createHash("sha256")
|
|
28
|
+
.update(findingJson, "utf8")
|
|
29
|
+
.digest("hex");
|
|
30
|
+
const params = {
|
|
19
31
|
version: 1,
|
|
20
|
-
rubric: { revision: 4, markdown: rubricMarkdown, sha256: rubricSha256 },
|
|
21
32
|
model: "your-authorized-model",
|
|
22
33
|
effort: "high",
|
|
23
|
-
records: [{ id
|
|
24
|
-
}
|
|
34
|
+
records: [{ id, revision: 7, findingJson, inputSha256 }],
|
|
35
|
+
};
|
|
36
|
+
console.log(
|
|
37
|
+
JSON.stringify({ jsonrpc: "2.0", id: "run-1", method: "run", params }),
|
|
38
|
+
);
|
|
25
39
|
```
|
|
26
40
|
|
|
27
41
|
The `rubric` field is optional. Omit it to classify with the
|
|
28
42
|
[built-in severity rubric](https://github.com/openai/codex-security/blob/main/plugins/codex-security/references/default-severity-rubric.md), using the same configured
|
|
29
43
|
independent host reviews and usage accounting. The result echoes its built-in
|
|
30
|
-
revision
|
|
44
|
+
revision and exact Markdown SHA-256. Supplying a custom rubric
|
|
31
45
|
replaces the default completely and preserves the supplied revision/hash binding.
|
|
32
46
|
Do not reuse cached results across differing rubric hashes; preserve the default
|
|
33
47
|
snapshot from the review prompt alongside its returned binding. Default revisions
|
|
@@ -58,7 +72,8 @@ an integer from 1 through 10 (default: 3), validated before any host work.
|
|
|
58
72
|
For each record the CLI emits that many sequential `method: "review.run"` requests,
|
|
59
73
|
each with a unique request ID and params containing `requestId`, `stage: "severity-classification"`, explicit
|
|
60
74
|
`model` and `effort`, `trustedInstructions`, untrusted report/rubric `prompt`, and
|
|
61
|
-
an output JSON `schema`. The
|
|
75
|
+
an output JSON `schema`. The SDK and CLI forward the `effort` string unchanged.
|
|
76
|
+
The host must authorize the requested model and effort,
|
|
62
77
|
create a fresh independent review context, preserve the instruction/data boundary,
|
|
63
78
|
and disable tools, repository access, browsing, and source inspection.
|
|
64
79
|
A managed-agent host can execute this request directly in its existing session
|