@openai/codex-security 0.8.3 → 0.10.0
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 +36 -746
- package/_bundled_plugin/.codex-plugin/plugin.json +2 -0
- package/_bundled_plugin/.mcp.json +7 -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/artifact-storage.md +1 -1
- package/_bundled_plugin/references/baseline-auditor.md +18 -0
- package/_bundled_plugin/references/core-scan.md +5 -42
- package/_bundled_plugin/references/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/focused-investigator.md +13 -0
- package/_bundled_plugin/references/sarif-adapter.md +8 -2
- package/_bundled_plugin/references/scan-artifacts.md +21 -12
- package/_bundled_plugin/references/scan-contract.md +27 -33
- package/_bundled_plugin/references/scan-prologue.md +2 -2
- package/_bundled_plugin/references/scan-runtime.md +4 -2
- package/_bundled_plugin/references/security-guidance.md +14 -1
- package/_bundled_plugin/references/validate-scan-findings.md +3 -0
- package/_bundled_plugin/schemas/tools/scan-draft.schema.json +2 -2
- package/_bundled_plugin/scripts/check_deep_scan_target.py +97 -0
- package/_bundled_plugin/scripts/codex_profile.mjs +7 -1
- package/_bundled_plugin/scripts/deep_scan_config.py +20 -1
- package/_bundled_plugin/scripts/deep_scan_workbench.py +192 -352
- package/_bundled_plugin/scripts/dispatch_inventory_tool +7 -0
- package/_bundled_plugin/scripts/filesystem_identity.py +1 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +182 -230
- package/_bundled_plugin/scripts/finding_preview.py +20 -0
- package/_bundled_plugin/scripts/launch_codex_security_mcp +55 -16
- package/_bundled_plugin/scripts/legacy_findings.py +148 -0
- package/_bundled_plugin/scripts/posix_scan_local_files.py +37 -1
- 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 +9 -2
- 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 +582 -20
- package/_bundled_plugin/scripts/workbench/__init__.py +1 -1
- package/_bundled_plugin/scripts/workbench/handoff.py +100 -23
- 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 +91 -7
- package/_bundled_plugin/scripts/workbench_cli.py +54 -14
- package/_bundled_plugin/scripts/workbench_constants.py +12 -0
- package/_bundled_plugin/scripts/workbench_coverage_receipts.py +3 -3
- package/_bundled_plugin/scripts/workbench_db.py +562 -303
- package/_bundled_plugin/scripts/workbench_feedback.py +57 -11
- 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 +238 -41
- package/_bundled_plugin/scripts/workbench_progress.py +169 -4
- package/_bundled_plugin/scripts/workbench_publication.py +16 -13
- package/_bundled_plugin/scripts/workbench_remediation.py +155 -2
- package/_bundled_plugin/scripts/workbench_saved_results.py +176 -81
- package/_bundled_plugin/scripts/workbench_scan_history.py +398 -174
- package/_bundled_plugin/scripts/workbench_scan_start.py +224 -31
- package/_bundled_plugin/scripts/workbench_scan_usage.py +675 -73
- package/_bundled_plugin/scripts/workbench_schema.py +258 -63
- package/_bundled_plugin/scripts/workbench_setup.py +14 -2
- 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 +594 -136
- package/_bundled_plugin/scripts/workbench_target_state.py +1110 -21
- package/_bundled_plugin/scripts/workbench_validation.py +43 -3
- package/_bundled_plugin/shared/workbench-history-repairs.json +77 -35
- package/_bundled_plugin/shared/workbench-migrations.json +100 -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 +2 -1
- package/_bundled_plugin/skills/publish-findings/SKILL.md +24 -153
- package/_bundled_plugin/skills/publish-findings/agents/openai.yaml +2 -2
- 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 +409 -0
- package/_bundled_plugin/skills/publish-findings/scripts/collect_continuum.py +224 -0
- package/_bundled_plugin/skills/publish-findings/scripts/collector_paths.py +63 -0
- package/_bundled_plugin/skills/security-scan/SKILL.md +9 -46
- package/_bundled_plugin/skills/security-scan/agents/openai.yaml +2 -2
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +3 -21
- package/_bundled_plugin/skills/security-scan/references/managed-scan.md +11 -0
- package/_bundled_plugin/skills/security-scan/references/scan-results.md +15 -0
- package/_bundled_plugin/skills/security-scan/references/scoped-paths.md +23 -0
- package/_bundled_plugin/skills/security-scan/references/sdk-files.md +24 -0
- package/_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/bin/codex-security.mjs +2 -2
- package/dist/api.d.ts +45 -5
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +1192 -427
- package/dist/api.js.map +1 -1
- package/dist/armorcode-findings.d.ts +9 -0
- package/dist/armorcode-findings.d.ts.map +1 -0
- package/dist/armorcode-findings.js +145 -0
- package/dist/armorcode-findings.js.map +1 -0
- package/dist/artifact-export.d.ts +2 -0
- package/dist/artifact-export.d.ts.map +1 -1
- package/dist/artifact-export.js +29 -13
- package/dist/artifact-export.js.map +1 -1
- package/dist/auth.d.ts +6 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +37 -18
- package/dist/auth.js.map +1 -1
- package/dist/batch-cost.d.ts +18 -0
- package/dist/batch-cost.d.ts.map +1 -0
- package/dist/batch-cost.js +41 -0
- package/dist/batch-cost.js.map +1 -0
- package/dist/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 +1 -1
- package/dist/blackduck-findings.d.ts.map +1 -1
- package/dist/blackduck-findings.js +24 -22
- 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/bundled-plugin.d.ts +4 -0
- package/dist/bundled-plugin.d.ts.map +1 -0
- package/dist/bundled-plugin.js +23 -0
- package/dist/bundled-plugin.js.map +1 -0
- package/dist/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-scan-severity.d.ts +1 -1
- package/dist/classify-scan-severity.d.ts.map +1 -1
- package/dist/classify-scan-severity.js +11 -3
- package/dist/classify-scan-severity.js.map +1 -1
- package/dist/classify-severity-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 +11 -10
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-argument.d.ts +4 -0
- package/dist/cli-argument.d.ts.map +1 -0
- package/dist/cli-argument.js +17 -0
- package/dist/cli-argument.js.map +1 -0
- package/dist/cli-help.d.ts +1 -1
- package/dist/cli-help.d.ts.map +1 -1
- package/dist/cli-help.js +71 -29
- package/dist/cli-help.js.map +1 -1
- package/dist/cli-hook.d.ts +3 -0
- package/dist/cli-hook.d.ts.map +1 -0
- package/dist/cli-hook.js +87 -0
- package/dist/cli-hook.js.map +1 -0
- package/dist/cli-integrations.d.ts +13 -0
- package/dist/cli-integrations.d.ts.map +1 -0
- package/dist/cli-integrations.js +333 -0
- package/dist/cli-integrations.js.map +1 -0
- package/dist/cli-mcp.d.ts +15 -0
- package/dist/cli-mcp.d.ts.map +1 -0
- package/dist/cli-mcp.js +178 -0
- package/dist/cli-mcp.js.map +1 -0
- package/dist/cli-token-view.d.ts +10 -0
- package/dist/cli-token-view.d.ts.map +1 -0
- package/dist/cli-token-view.js +41 -0
- package/dist/cli-token-view.js.map +1 -0
- package/dist/cli.d.ts +16 -8
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +3382 -2017
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +35 -33
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codex-sdk-environment.d.ts +6 -0
- package/dist/codex-sdk-environment.d.ts.map +1 -1
- package/dist/codex-sdk-environment.js +19 -0
- package/dist/codex-sdk-environment.js.map +1 -1
- package/dist/command-words.d.ts +3 -0
- package/dist/command-words.d.ts.map +1 -0
- package/dist/command-words.js +46 -0
- package/dist/command-words.js.map +1 -0
- package/dist/component-scan.d.ts +19 -4
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +67 -9
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +130 -67
- package/dist/config.js.map +1 -1
- package/dist/continuum-findings.d.ts +1 -1
- package/dist/continuum-findings.d.ts.map +1 -1
- package/dist/continuum-findings.js +149 -19
- 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 +484 -149
- package/dist/cost.js.map +1 -1
- package/dist/custom-publish.d.ts +4 -0
- package/dist/custom-publish.d.ts.map +1 -1
- package/dist/custom-publish.js +40 -3
- package/dist/custom-publish.js.map +1 -1
- package/dist/custom-validation-prompt.d.ts +1 -1
- package/dist/custom-validation-prompt.d.ts.map +1 -1
- package/dist/custom-validation-prompt.js +29 -19
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/deduplication/local.d.ts +4 -2
- package/dist/deduplication/local.d.ts.map +1 -1
- package/dist/deduplication/local.js +9 -2
- package/dist/deduplication/local.js.map +1 -1
- package/dist/deduplication/refusal.d.ts.map +1 -1
- package/dist/deduplication/refusal.js +26 -5
- package/dist/deduplication/refusal.js.map +1 -1
- package/dist/deduplication/scan.d.ts +5 -0
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +24 -7
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-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 +44 -19
- 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 +86 -45
- package/dist/endor-findings.js.map +1 -1
- package/dist/errors.d.ts +4 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +15 -4
- package/dist/errors.js.map +1 -1
- package/dist/executable-path.d.ts +3 -0
- package/dist/executable-path.d.ts.map +1 -1
- package/dist/executable-path.js +26 -0
- package/dist/executable-path.js.map +1 -1
- package/dist/external-findings-import.d.ts +5 -3
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +19 -7
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts +69 -5
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +537 -108
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +13 -6
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +895 -1142
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +21 -2
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +130 -68
- 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 +54 -2
- package/dist/external-findings.js.map +1 -1
- package/dist/external-import-contract.d.ts +8 -12
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +51 -184
- 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 +18 -8
- 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 +73 -316
- 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-remediation.d.ts +1 -0
- package/dist/hosted-remediation.d.ts.map +1 -1
- package/dist/hosted-remediation.js +23 -3
- package/dist/hosted-remediation.js.map +1 -1
- package/dist/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/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 +21 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/inspector-findings.d.ts.map +1 -1
- package/dist/inspector-findings.js +52 -86
- package/dist/inspector-findings.js.map +1 -1
- package/dist/knowledge-base.d.ts +1 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +102 -32
- package/dist/knowledge-base.js.map +1 -1
- package/dist/linear.d.ts +11 -0
- package/dist/linear.d.ts.map +1 -1
- package/dist/linear.js.map +1 -1
- package/dist/local-git-metadata.d.ts +5 -2
- package/dist/local-git-metadata.d.ts.map +1 -1
- package/dist/local-git-metadata.js +8 -5
- package/dist/local-git-metadata.js.map +1 -1
- package/dist/multiscan.d.ts +10 -4
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +217 -102
- 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 +5 -2
- package/dist/opengrep-findings.d.ts.map +1 -1
- package/dist/opengrep-findings.js +54 -33
- 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 +99 -9
- package/dist/private-finding-import.d.ts.map +1 -1
- package/dist/private-finding-import.js +116 -152
- package/dist/private-finding-import.js.map +1 -1
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +53 -13
- package/dist/project-config.js.map +1 -1
- package/dist/prompt-files.d.ts +7 -2
- package/dist/prompt-files.d.ts.map +1 -1
- package/dist/prompt-files.js +42 -20
- package/dist/prompt-files.js.map +1 -1
- package/dist/provider-profile.d.ts +1 -1
- package/dist/provider-profile.d.ts.map +1 -1
- package/dist/provider-profile.js +12 -10
- package/dist/provider-profile.js.map +1 -1
- package/dist/publication-telemetry.d.ts +45 -0
- package/dist/publication-telemetry.d.ts.map +1 -0
- package/dist/publication-telemetry.js +50 -0
- package/dist/publication-telemetry.js.map +1 -0
- package/dist/publication.d.ts +1 -1
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts +4 -0
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +42 -2
- package/dist/publish.js.map +1 -1
- package/dist/record.d.ts +1 -5
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +3 -51
- package/dist/record.js.map +1 -1
- package/dist/remediation.d.ts +1 -4
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +6 -8
- 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 +54 -6
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +1084 -256
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan-bootstrap.d.ts +7 -1
- package/dist/saved-scan-bootstrap.d.ts.map +1 -1
- package/dist/saved-scan-bootstrap.js +269 -114
- 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-archive-path.d.ts +2 -0
- package/dist/scan-archive-path.d.ts.map +1 -0
- package/dist/scan-archive-path.js +5 -0
- package/dist/scan-archive-path.js.map +1 -0
- package/dist/scan-comparison.d.ts +10 -5
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +66 -17
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +7 -6
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +92 -43
- 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 +24 -2
- package/dist/scan-executor.js.map +1 -1
- package/dist/scan-history-renderer.d.ts +1 -0
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +34 -28
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts +12 -0
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +131 -78
- 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 +25 -13
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +216 -97
- 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 +26 -6
- 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 +72 -42
- 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 +157 -6
- package/dist/semgrep-platform-findings.d.ts.map +1 -1
- package/dist/semgrep-platform-findings.js +766 -103
- package/dist/semgrep-platform-findings.js.map +1 -1
- 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 +9 -2
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +90 -70
- package/dist/snyk-findings.js.map +1 -1
- package/dist/snyk-rest-findings.d.ts +59 -0
- package/dist/snyk-rest-findings.d.ts.map +1 -0
- package/dist/snyk-rest-findings.js +879 -0
- package/dist/snyk-rest-findings.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-findings.d.ts +1 -1
- package/dist/sonar-findings.d.ts.map +1 -1
- package/dist/sonar-findings.js +2 -4
- package/dist/sonar-findings.js.map +1 -1
- package/dist/sonar-import.d.ts +3 -0
- package/dist/sonar-import.d.ts.map +1 -1
- package/dist/sonar-import.js +30 -34
- package/dist/sonar-import.js.map +1 -1
- package/dist/stored-finding-projection.d.ts +6 -0
- package/dist/stored-finding-projection.d.ts.map +1 -0
- package/dist/stored-finding-projection.js +104 -0
- package/dist/stored-finding-projection.js.map +1 -0
- package/dist/stored-findings-publication.d.ts +23 -0
- package/dist/stored-findings-publication.d.ts.map +1 -0
- package/dist/stored-findings-publication.js +169 -0
- package/dist/stored-findings-publication.js.map +1 -0
- package/dist/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 +8 -1
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +131 -42
- package/dist/targets.js.map +1 -1
- package/dist/tenable-findings.d.ts +6 -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 +424 -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/trusted-executable.d.ts +6 -0
- package/dist/trusted-executable.d.ts.map +1 -1
- package/dist/trusted-executable.js +140 -37
- package/dist/trusted-executable.js.map +1 -1
- package/dist/validation-records.js +1 -1
- package/dist/validation-records.js.map +1 -1
- package/dist/veracode-findings.d.ts +1 -1
- package/dist/veracode-findings.d.ts.map +1 -1
- package/dist/veracode-findings.js +19 -6
- package/dist/veracode-findings.js.map +1 -1
- package/dist/version.d.ts +3 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +184 -32
- package/dist/version.js.map +1 -1
- package/dist/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 +6 -2
- package/dist/wiz-findings.d.ts.map +1 -1
- package/dist/wiz-findings.js +65 -89
- package/dist/wiz-findings.js.map +1 -1
- package/docs/classify-severity-records.md +27 -12
- package/docs/cli.md +853 -639
- package/docs/dedupe-records.md +44 -24
- package/docs/findings-service.md +84 -44
- package/docs/hosted-remediation.md +27 -11
- package/docs/hosted-scans.md +50 -42
- package/docs/sdk.md +903 -0
- package/docs/telemetry.md +236 -0
- package/docs/validate-records.md +78 -44
- package/package.json +23 -16
- package/schemas/external-findings.schema.json +4 -1
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
- package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +0 -96
- package/dist/external-imports-feature.d.ts +0 -6
- package/dist/external-imports-feature.d.ts.map +0 -1
- package/dist/external-imports-feature.js +0 -51
- package/dist/external-imports-feature.js.map +0 -1
- package/dist/finding-normalization.d.ts +0 -5
- package/dist/finding-normalization.d.ts.map +0 -1
- package/dist/finding-normalization.js +0 -155
- package/dist/finding-normalization.js.map +0 -1
- package/dist/reader-selection.d.ts +0 -13
- package/dist/reader-selection.d.ts.map +0 -1
- package/dist/reader-selection.js +0 -81
- package/dist/reader-selection.js.map +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Standard MaaS prices in nanodollars per token. Google lists one price
|
|
2
|
+
// across each model's 131,072-token context window. Only 20B discounts
|
|
3
|
+
// implicit cache hits. Keep its rates for scans made before its retirement.
|
|
4
|
+
const rates = new Map([
|
|
5
|
+
["gpt-oss-20b-maas", [70, 7, 70, 250]],
|
|
6
|
+
["gpt-oss-120b-maas", [90, 90, 90, 360]],
|
|
7
|
+
]);
|
|
8
|
+
export function vertexModelPricing(model) {
|
|
9
|
+
const price = rates.get(model.replace(/^openai\//, ""));
|
|
10
|
+
if (!price)
|
|
11
|
+
return undefined;
|
|
12
|
+
return {
|
|
13
|
+
short: price,
|
|
14
|
+
long: price,
|
|
15
|
+
unitsPerUsd: 1_000_000_000,
|
|
16
|
+
source: "https://cloud.google.com/model-garden/partner-models/pricing",
|
|
17
|
+
asOf: "2026-11-05",
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=vertex-pricing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vertex-pricing.js","sourceRoot":"","sources":["../src/vertex-pricing.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,uEAAuE;AACvE,4EAA4E;AAC5E,MAAM,KAAK,GAAG,IAAI,GAAG,CAQnB;IACA,CAAC,kBAAkB,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;IACtC,CAAC,mBAAmB,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;CACzC,CAAC,CAAC;AAEH,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC;IACxD,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,OAAO;QACL,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,aAAa;QAC1B,MAAM,EAAE,8DAA8D;QACtE,IAAI,EAAE,YAAY;KACnB,CAAC;AACJ,CAAC","sourcesContent":["// Standard MaaS prices in nanodollars per token. Google lists one price\n// across each model's 131,072-token context window. Only 20B discounts\n// implicit cache hits. Keep its rates for scans made before its retirement.\nconst rates = new Map<\n string,\n readonly [\n input: number,\n cacheRead: number,\n cacheWrite: number,\n output: number,\n ]\n>([\n [\"gpt-oss-20b-maas\", [70, 7, 70, 250]],\n [\"gpt-oss-120b-maas\", [90, 90, 90, 360]],\n]);\n\nexport function vertexModelPricing(model: string) {\n const price = rates.get(model.replace(/^openai\\//, \"\"));\n if (!price) return undefined;\n return {\n short: price,\n long: price,\n unitsPerUsd: 1_000_000_000,\n source: \"https://cloud.google.com/model-garden/partner-models/pricing\",\n asOf: \"2026-11-05\",\n };\n}\n"]}
|
package/dist/windows-path.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare function sqliteFilename(path: string): string;
|
|
1
2
|
export declare function isWindowsUnsafePathComponent(value: string): boolean;
|
|
2
3
|
export declare function windowsUnsafePathComponent(path: string): string | undefined;
|
|
3
4
|
//# sourceMappingURL=windows-path.d.ts.map
|
|
@@ -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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AAC,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,13 +1,17 @@
|
|
|
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>;
|
|
6
|
-
export declare function
|
|
7
|
-
|
|
8
|
+
export declare function readWizSelection(path: string, target: ExternalImportTarget): Promise<{
|
|
9
|
+
findings: VendorFindings;
|
|
8
10
|
sourceRepositories: {
|
|
9
11
|
url: string;
|
|
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;AAgYD,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;AAyBD,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,oBAAoB;;;;kBAPY,QAAQ;;GAYjD;AA0BD,0FAA0F;AAC1F,wBAAgB,eAAe,CAC7B,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAiCT"}
|
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")
|
|
@@ -103,34 +112,6 @@ function sourceRepository(repository, repositories) {
|
|
|
103
112
|
url,
|
|
104
113
|
};
|
|
105
114
|
}
|
|
106
|
-
function sourceBranch(branch, repository, legacy = false) {
|
|
107
|
-
const name = text(branch?.["name"]);
|
|
108
|
-
if (!name)
|
|
109
|
-
return null;
|
|
110
|
-
// Repository names and URL paths can both be literal branch prefixes. Keep
|
|
111
|
-
// the old mapping only for an already approved publication checkpoint.
|
|
112
|
-
if (!legacy)
|
|
113
|
-
return name;
|
|
114
|
-
const qualifiers = repository.name ? [repository.name] : [];
|
|
115
|
-
// Include the URL qualifier before selecting the longest repository prefix.
|
|
116
|
-
// Keep URL normalization and the branch suffix's original case and slashes.
|
|
117
|
-
const repositoryKey = repositoryUrlKey(repository.url).toLowerCase();
|
|
118
|
-
const url = /^(https?:\/\/[^/?#]+)\/([^?#]+)$/iu.exec(repositoryKey);
|
|
119
|
-
if (url) {
|
|
120
|
-
const prefixParts = url[2].split("/").length;
|
|
121
|
-
const parts = name.split("/");
|
|
122
|
-
const qualifier = parts.slice(0, prefixParts).join("/");
|
|
123
|
-
if (parts.length > prefixParts &&
|
|
124
|
-
repositoryUrlKey(url[1] + "/" + qualifier).toLowerCase() === repositoryKey)
|
|
125
|
-
qualifiers.push(qualifier);
|
|
126
|
-
}
|
|
127
|
-
for (const qualifier of qualifiers.sort((left, right) => right.length - left.length)) {
|
|
128
|
-
const prefix = qualifier + "/";
|
|
129
|
-
if (name.toLowerCase().startsWith(prefix.toLowerCase()))
|
|
130
|
-
return name.slice(prefix.length) || null;
|
|
131
|
-
}
|
|
132
|
-
return url || repository.name ? name : null;
|
|
133
|
-
}
|
|
134
115
|
function updatedAt(value, field) {
|
|
135
116
|
const timestamp = text(value);
|
|
136
117
|
if (!timestamp)
|
|
@@ -145,7 +126,7 @@ function content(value) {
|
|
|
145
126
|
return typeof value === "string" ? value : null;
|
|
146
127
|
}
|
|
147
128
|
/** Map only explicitly identified repository finding collections. */
|
|
148
|
-
function repositoryFinding(kind, record, repositories,
|
|
129
|
+
function repositoryFinding(kind, record, repositories, target = "cloud") {
|
|
149
130
|
const id = sourceFindingId(record["id"], target);
|
|
150
131
|
const resource = asRecord(record["resource"]);
|
|
151
132
|
if (kind === "secret" && resource?.["type"] !== "REPOSITORY_BRANCH")
|
|
@@ -216,7 +197,7 @@ function repositoryFinding(kind, record, repositories, legacy = false, target =
|
|
|
216
197
|
description: text(record["description"]) ?? text(rule?.["description"]),
|
|
217
198
|
url: text(record["wizUrl"]) ?? text(record["portalUrl"]),
|
|
218
199
|
locations: path ? [{ path, line: line ?? null }] : [],
|
|
219
|
-
branch:
|
|
200
|
+
branch: text(branch?.["name"]),
|
|
220
201
|
code_revision: null,
|
|
221
202
|
source_scan_id: null,
|
|
222
203
|
source_updated_at: kind === "secret"
|
|
@@ -231,7 +212,6 @@ function repositoryFinding(kind, record, repositories, legacy = false, target =
|
|
|
231
212
|
}
|
|
232
213
|
function records(payload) {
|
|
233
214
|
const repositories = new Map();
|
|
234
|
-
const legacyRepositories = new Map();
|
|
235
215
|
if (Array.isArray(payload))
|
|
236
216
|
return { records: payload.map((value) => ({ value })), repositories };
|
|
237
217
|
const envelope = asRecord(payload);
|
|
@@ -284,10 +264,6 @@ function records(payload) {
|
|
|
284
264
|
: entry.name,
|
|
285
265
|
platform: entry.platform ?? previous?.platform ?? null,
|
|
286
266
|
});
|
|
287
|
-
legacyRepositories.set(entry.id, {
|
|
288
|
-
...entry,
|
|
289
|
-
platform: entry.platform ?? previous?.platform ?? null,
|
|
290
|
-
});
|
|
291
267
|
}
|
|
292
268
|
for (const entry of entries) {
|
|
293
269
|
const resolved = repositories.get(entry.id);
|
|
@@ -305,23 +281,30 @@ function records(payload) {
|
|
|
305
281
|
};
|
|
306
282
|
const selected = [];
|
|
307
283
|
let found = false;
|
|
284
|
+
let countedCollection;
|
|
308
285
|
for (const [root, kind] of Object.entries(collections)) {
|
|
286
|
+
if (!(root in data))
|
|
287
|
+
continue;
|
|
309
288
|
const collection = asRecord(data[root]);
|
|
310
289
|
if (!collection)
|
|
311
|
-
|
|
290
|
+
throw new Error(`Wiz ${root} must be an object with a nodes array.`);
|
|
312
291
|
found = true;
|
|
313
292
|
if (!Array.isArray(collection["nodes"]))
|
|
314
293
|
throw new Error(`Wiz ${root}.nodes must be an array.`);
|
|
315
294
|
if (asRecord(collection["pageInfo"])?.["hasNextPage"] === true)
|
|
316
295
|
throw new Error("Wiz response has another page. Complete the requested pages or save the explicitly selected records in their named collection before publishing.");
|
|
296
|
+
const total = collection["totalCount"];
|
|
297
|
+
if (typeof total === "number" && total > 0)
|
|
298
|
+
countedCollection = root;
|
|
317
299
|
for (const value of collection["nodes"])
|
|
318
300
|
selected.push({ value, kind });
|
|
319
301
|
}
|
|
302
|
+
if (!selected.length && countedCollection)
|
|
303
|
+
throw new Error(`Wiz ${countedCollection}.totalCount reports findings, but the export contains no finding nodes.`);
|
|
320
304
|
if (found)
|
|
321
305
|
return {
|
|
322
306
|
records: selected,
|
|
323
307
|
repositories,
|
|
324
|
-
legacyRepositories,
|
|
325
308
|
};
|
|
326
309
|
throw new Error("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.");
|
|
327
310
|
}
|
|
@@ -337,7 +320,9 @@ export function wizFindingRepository(evidence, target = "local") {
|
|
|
337
320
|
if (!url)
|
|
338
321
|
return;
|
|
339
322
|
const github = asset["nativeType"] === "github#repositoryBranch" ||
|
|
340
|
-
(asset["type"] === "REPOSITORY_BRANCH" &&
|
|
323
|
+
(asset["type"] === "REPOSITORY_BRANCH" &&
|
|
324
|
+
(text(asset["cloudPlatform"])?.toLowerCase() === "github" ||
|
|
325
|
+
isGitHubCloudHost(url.hostname)));
|
|
341
326
|
if (!github)
|
|
342
327
|
return asset["type"] === "REPOSITORY_BRANCH"
|
|
343
328
|
? { url: asset["cloudProviderURL"] }
|
|
@@ -355,6 +340,10 @@ export function wizFindingRepository(evidence, target = "local") {
|
|
|
355
340
|
export async function readVendorFindings(path, target = "cloud") {
|
|
356
341
|
return normalizeFindings(await readFindingInput(path), target);
|
|
357
342
|
}
|
|
343
|
+
/** @internal Reopen a native JSON selection with the same rules as a Wiz file. */
|
|
344
|
+
export function normalizeWizJson(payload, target) {
|
|
345
|
+
return normalizeFindings(records(payload), target);
|
|
346
|
+
}
|
|
358
347
|
function inventorySources(input, current) {
|
|
359
348
|
return current.findings.flatMap(({ evidence }) => {
|
|
360
349
|
const repository = evidence.details?.repository;
|
|
@@ -369,53 +358,10 @@ function inventorySources(input, current) {
|
|
|
369
358
|
: [];
|
|
370
359
|
});
|
|
371
360
|
}
|
|
372
|
-
export async function
|
|
373
|
-
const input = await readFindingInput(path);
|
|
374
|
-
const current = normalizeFindings(input, "local");
|
|
375
|
-
return { current, sourceRepositories: inventorySources(input, current) };
|
|
376
|
-
}
|
|
377
|
-
/** @internal Preserve older inventory projections only for saved publication replay. */
|
|
378
|
-
export async function readVendorFindingsForPublication(path, target = "cloud") {
|
|
361
|
+
export async function readWizSelection(path, target) {
|
|
379
362
|
const input = await readFindingInput(path);
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
// Only repository finding families use historical inventory and branch mapping.
|
|
383
|
-
const hasRepositoryFindings = input.records.some(({ kind }) => kind === "sast" || kind === "secret" || kind === "iac");
|
|
384
|
-
const legacy = hasRepositoryFindings
|
|
385
|
-
? normalizeFindings({
|
|
386
|
-
...input,
|
|
387
|
-
repositories: input.legacyRepositories ?? input.repositories,
|
|
388
|
-
}, target, normalized, true)
|
|
389
|
-
: current;
|
|
390
|
-
const identity = (parsed) => parsed.findings.map((finding) => {
|
|
391
|
-
if (normalized.has(finding))
|
|
392
|
-
return finding;
|
|
393
|
-
const repository = finding.evidence.details?.repository;
|
|
394
|
-
return {
|
|
395
|
-
source_finding_id: finding.source_finding_id,
|
|
396
|
-
evidence: {
|
|
397
|
-
// Raw vendor records retain every original branch/ref and source field.
|
|
398
|
-
// Inventory display aliases must not change an outstanding request's identity.
|
|
399
|
-
source_data: finding.evidence.source_data,
|
|
400
|
-
repository: repository
|
|
401
|
-
? {
|
|
402
|
-
id: repository.id,
|
|
403
|
-
// Publication targets use Cloud's GitHub URL semantics. Input
|
|
404
|
-
// joins above still require provenance for custom-host folding.
|
|
405
|
-
url: repositoryUrlKey(repository.url).toLowerCase(),
|
|
406
|
-
}
|
|
407
|
-
: null,
|
|
408
|
-
},
|
|
409
|
-
};
|
|
410
|
-
});
|
|
411
|
-
const currentIdentity = identity(current);
|
|
412
|
-
return {
|
|
413
|
-
current,
|
|
414
|
-
legacy,
|
|
415
|
-
currentIdentity,
|
|
416
|
-
legacyIdentity: legacy === current ? currentIdentity : identity(legacy),
|
|
417
|
-
sourceRepositories: inventorySources(input, current),
|
|
418
|
-
};
|
|
363
|
+
const findings = normalizeFindings(input, target);
|
|
364
|
+
return { findings, sourceRepositories: inventorySources(input, findings) };
|
|
419
365
|
}
|
|
420
366
|
async function readFindingInput(path) {
|
|
421
367
|
try {
|
|
@@ -439,7 +385,39 @@ async function readFindingInput(path) {
|
|
|
439
385
|
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
386
|
}
|
|
441
387
|
}
|
|
442
|
-
|
|
388
|
+
/** Apply Wiz's own reader to an occurrence that also retains another scanner's fields. */
|
|
389
|
+
export function isWizOccurrence(finding, target) {
|
|
390
|
+
const { source_data: data, details } = finding.evidence;
|
|
391
|
+
if (!data || typeof data["id"] !== "string")
|
|
392
|
+
return false;
|
|
393
|
+
const kind = details?.kind;
|
|
394
|
+
const scoped = kind === "sast" || kind === "iac" || kind === "secret";
|
|
395
|
+
if (finding.source_finding_id !==
|
|
396
|
+
(scoped ? `${kind}:${data["id"]}` : data["id"]))
|
|
397
|
+
return false;
|
|
398
|
+
const input = {
|
|
399
|
+
records: [{ value: data, kind: scoped ? kind : "sca" }],
|
|
400
|
+
repositories: new Map(),
|
|
401
|
+
};
|
|
402
|
+
const repository = details?.repository;
|
|
403
|
+
if (scoped && repository?.id)
|
|
404
|
+
input.repositories.set(repository.id, {
|
|
405
|
+
id: repository.id,
|
|
406
|
+
name: repository.name ?? null,
|
|
407
|
+
url: repository.url,
|
|
408
|
+
platform: null,
|
|
409
|
+
});
|
|
410
|
+
// The raw record is the same. Check that Wiz produced the selected evidence,
|
|
411
|
+
// including its own repository binding, before treating upstream fields as opaque.
|
|
412
|
+
const selected = canonicalJson({
|
|
413
|
+
...validateExternalEvidence(finding.evidence, target),
|
|
414
|
+
source_data: undefined,
|
|
415
|
+
});
|
|
416
|
+
const [row] = normalizeFindings(input, target).findings;
|
|
417
|
+
return (row !== undefined &&
|
|
418
|
+
canonicalJson({ ...row.evidence, source_data: undefined }) === selected);
|
|
419
|
+
}
|
|
420
|
+
function normalizeFindings(input, target) {
|
|
443
421
|
const result = {
|
|
444
422
|
read: input.records.length,
|
|
445
423
|
findings: [],
|
|
@@ -468,7 +446,7 @@ function normalizeFindings(input, target, normalized, legacy = false) {
|
|
|
468
446
|
throw new Error("Cloud configuration findings require a resource-scoped import and cannot be published to a repository.");
|
|
469
447
|
}
|
|
470
448
|
else if (item.kind && item.kind !== "sca") {
|
|
471
|
-
finding = repositoryFinding(item.kind, record, input.repositories,
|
|
449
|
+
finding = repositoryFinding(item.kind, record, input.repositories, target);
|
|
472
450
|
}
|
|
473
451
|
else {
|
|
474
452
|
if (!item.kind &&
|
|
@@ -483,8 +461,6 @@ function normalizeFindings(input, target, normalized, legacy = false) {
|
|
|
483
461
|
}
|
|
484
462
|
identities.add(finding.source_finding_id);
|
|
485
463
|
result.findings.push(finding);
|
|
486
|
-
if (item.kind !== "sca_csv" && "source_finding_id" in record)
|
|
487
|
-
normalized?.add(finding);
|
|
488
464
|
}
|
|
489
465
|
catch (error) {
|
|
490
466
|
if (error instanceof CodexSecurityError)
|
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,+BAA+B,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,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,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BAAkB;gBAAE,MAAM,KAAK,CAAC;YACrD,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACnB,QAAQ,EAAE,KAAK,GAAG,CAAC;gBACnB,iBAAiB,EACf,IAAI,CAAC,IAAI,KAAK,SAAS;oBACrB,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;oBACtB,CAAC,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 } 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;IACv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IAAI,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;gBAC9C,MAAM,IAAI,kBAAkB,CAC1B,+BAA+B,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,iBAAiB,CAAC,uCAAuC,CAChH,CAAC;YACJ,CAAC;YACD,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;YAC1C,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,kBAAkB;gBAAE,MAAM,KAAK,CAAC;YACrD,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACnB,QAAQ,EAAE,KAAK,GAAG,CAAC;gBACnB,iBAAiB,EACf,IAAI,CAAC,IAAI,KAAK,SAAS;oBACrB,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;oBACtB,CAAC,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};\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 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 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: text(branch?.[\"name\"]),\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 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 }\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 };\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\n/** @internal Reopen a native JSON selection with the same rules as a Wiz file. */\nexport function normalizeWizJson(\n payload: unknown,\n target: ExternalImportTarget,\n) {\n return normalizeFindings(records(payload), 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 readWizSelection(\n path: string,\n target: ExternalImportTarget,\n) {\n const input = await readFindingInput(path);\n const findings = normalizeFindings(input, target);\n return { findings, sourceRepositories: inventorySources(input, findings) };\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 [row] = normalizeFindings(input, target).findings;\n return (\n row !== undefined &&\n canonicalJson({ ...row.evidence, source_data: undefined }) === selected\n );\n}\n\nfunction normalizeFindings(\n input: FindingInput,\n target: ExternalImportTarget,\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 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 } 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"]}
|