@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-sessions.js","sourceRoot":"","sources":["../src/scan-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,UAAU,gBAAgB,CAAC,SAAkB;IACjD,MAAM,SAAS,GACb,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IACrE,OAAO,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,OAA8D,EAC9D,OAA0C;IAE1C,sFAAsF;IACtF,MAAM,W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AAW,CAAC,CAAC;IACnD,IAAI,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAE9D,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;IACxD,IAAI,QAAQ,CAAC,aAAa,EAAE,gBAAgB,CAAC,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAElE,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IACtD,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,OAAO,CACL,CAAC,UAAU,CAAC,SAAS,CAAC;QACtB,UAAU,CAAC,MAAM,KAAK,CAAC;QACvB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;QACtB,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAE,EAAE,QAAQ,CAAC,EAAE,gBAAgB,CAAC,KAAK,EAAE,CAC3E,CAAC;AACJ,CAAC","sourcesContent":["import { isAbsolute, join, relative, sep } from \"node:path\";\nimport { isRecord } from \"./record.js\";\n\nexport function sessionStartedAt(timestamp: unknown): number | null {\n const startedAt =\n typeof timestamp === \"string\" ? Date.parse(timestamp) : Number.NaN;\n return Number.isFinite(startedAt) ? startedAt : null;\n}\n\nexport function sessionOwnsTurn(\n session: { threadId: string | null; startedAt: number | null },\n payload: Readonly<Record<string, unknown>>,\n): boolean {\n // Fresh Codex worker thread/turn IDs share a same-process monotonic UUIDv7 generator.\n const threadOrder = uuid7Order(session.threadId);\n const turnOrder = uuid7Order(payload[\"turn_id\"]);\n return threadOrder === null\n ? typeof payload[\"started_at\"] === \"number\" &&\n session.startedAt !== null &&\n payload[\"started_at\"] >= Math.floor(session.startedAt / 1_000)\n : turnOrder !== null && turnOrder >= threadOrder;\n}\n\nfunction uuid7Order(value: unknown): bigint | null {\n if (\n typeof value !== \"string\" ||\n !/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(\n value,\n )\n ) {\n return null;\n }\n return BigInt(`0x${value.replaceAll(\"-\", \"\")}`);\n}\n\nexport function sessionParentThreadId(\n metadata: Readonly<Record<string, unknown>>,\n): string | null {\n const source = metadata[\"source\"];\n const subagent = isRecord(source) ? source[\"subagent\"] : undefined;\n const spawn = isRecord(subagent) ? subagent[\"thread_spawn\"] : undefined;\n for (const parent of [\n isRecord(spawn) ? spawn[\"parent_thread_id\"] : undefined,\n metadata[\"parent_thread_id\"],\n metadata[\"forked_from_id\"],\n ]) {\n if (typeof parent === \"string\" && parent !== \"\") return parent;\n }\n return null;\n}\n\nexport function isScanArtifactDirectory(\n scanDirectory: string,\n workingDirectory: string,\n): boolean {\n const artifacts = join(scanDirectory, \"artifacts\");\n if (relative(artifacts, workingDirectory) === \"\") return true;\n\n const deepDirectory = join(artifacts, \"deep_discovery\");\n if (relative(deepDirectory, workingDirectory) === \"\") return true;\n\n const workers = join(deepDirectory, \"workers\");\n const directory = relative(workers, workingDirectory);\n const components = directory.split(sep);\n return (\n !isAbsolute(directory) &&\n components.length === 2 &&\n components[0] !== \"..\" &&\n relative(join(workers, components[0]!, \"output\"), workingDirectory) === \"\"\n );\n}\n"]}
|
package/dist/scan-settings.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare const FailureSeveritySchema: z.ZodEnum<{
|
|
|
16
16
|
medium: "medium";
|
|
17
17
|
}>;
|
|
18
18
|
export type FailureSeverity = z.infer<typeof FailureSeveritySchema>;
|
|
19
|
-
export
|
|
19
|
+
export { DEEP_SCAN_SETTINGS } from "./deep-scan-defaults.js";
|
|
20
20
|
export declare const DeepScanSettingsSchema: z.ZodObject<{
|
|
21
21
|
workers: z.ZodOptional<z.ZodNumber>;
|
|
22
22
|
subagents: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-settings.d.ts","sourceRoot":"","sources":["../src/scan-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,eAAO,MAAM,eAAe,YAAI,MAAM,EAAE,SAAS,EAAE,SAAS,CAAU,CAAC;AACvE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAC5D,eAAO,MAAM,iBAAiB,SAAS,CAAC;AACxC,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAC5C,eAAO,MAAM,qBAAqB,YAChC,UAAU,EACV,MAAM,EACN,QAAQ,EACR,KAAK,CACG,CAAC;AACX,eAAO,MAAM,eAAe,iEAGlB,CAAC;AACX,eAAO,MAAM,qBAAqB;;;;;EAAgC,CAAC;AACnE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"scan-settings.d.ts","sourceRoot":"","sources":["../src/scan-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,UA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B;AAED,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,YAAY,EACV,YAAY,GACZ,gBAAgB,GAChB,kBAAkB,GAClB,sBAAsB,GACtB,gBAAgB,GAChB,oBAAoB,CACvB,CAAC;AAEF,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,GAAG,YAAY,CAUrE;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,EAClC,SAAS,EAAE,aAAa,GACvB,OAAO,CAIT;AAED,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,aAAa,GAAG,MAAM,CAQtE"}
|
package/dist/scan-settings.js
CHANGED
|
@@ -16,30 +16,7 @@ export const SCAN_SEVERITIES = [
|
|
|
16
16
|
"informational",
|
|
17
17
|
];
|
|
18
18
|
export const FailureSeveritySchema = z.enum(REPORTABLE_SEVERITIES);
|
|
19
|
-
|
|
20
|
-
export const DEEP_SCAN_SETTINGS = [
|
|
21
|
-
["workers", "workers", "workers", "--workers"],
|
|
22
|
-
["subagents", "subagents", "subagents_per_worker", "--subagents"],
|
|
23
|
-
[
|
|
24
|
-
"stopAfterNoNew",
|
|
25
|
-
"stop_after_no_new",
|
|
26
|
-
"stop_after_no_new",
|
|
27
|
-
"--stop-after-no-new",
|
|
28
|
-
],
|
|
29
|
-
[
|
|
30
|
-
"stopAfterConsecutiveErrors",
|
|
31
|
-
"stop_after_consecutive_errors",
|
|
32
|
-
"stop_after_consecutive_errors",
|
|
33
|
-
null,
|
|
34
|
-
],
|
|
35
|
-
[
|
|
36
|
-
"maxDiscoveryRuns",
|
|
37
|
-
"max_discovery_runs",
|
|
38
|
-
"max_discovery_runs",
|
|
39
|
-
"--max-discovery-runs",
|
|
40
|
-
],
|
|
41
|
-
["maxTimeHours", "max_time_hours", "max_time_hours", "--max-time-hours"],
|
|
42
|
-
];
|
|
19
|
+
export { DEEP_SCAN_SETTINGS } from "./deep-scan-defaults.js";
|
|
43
20
|
const positiveIntegerError = "must be a positive integer";
|
|
44
21
|
const positiveInteger = z
|
|
45
22
|
.number({ error: positiveIntegerError })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-settings.js","sourceRoot":"","sources":["../src/scan-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EAAE,UAAU,EAAiB,MAAM,iBAAiB,CAAC;AAG5D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAU,CAAC;AAEvE,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACxC,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAC5C,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,UAAU;IACV,MAAM;IACN,QAAQ;IACR,KAAK;CACG,CAAC;AACX,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,GAAG,qBAAqB;IACxB,eAAe;CACP,CAAC;AACX,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AAGnE,uEAAuE;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC;IAC9C,CAAC,WAAW,EAAE,WAAW,EAAE,sBAAsB,EAAE,aAAa,CAAC;IACjE;QACE,gBAAgB;QAChB,mBAAmB;QACnB,mBAAmB;QACnB,qBAAqB;KACtB;IACD;QACE,4BAA4B;QAC5B,+BAA+B;QAC/B,+BAA+B;QAC/B,IAAI;KACL;IACD;QACE,kBAAkB;QAClB,oBAAoB;QACpB,oBAAoB;QACpB,sBAAsB;KACvB;IACD,CAAC,cAA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,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACjE,OAAO,QAAQ,IAAI,CAAC,IAAI,QAAQ,IAAI,aAAa,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,SAAwB;IAC5D,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChD,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QACb,MAAM,IAAI,kBAAkB,CAC1B,+BAA+B,MAAM,CAAC,SAAS,CAAC,GAAG,CACpD,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { DEFAULT_DEEP_SCAN_SETTINGS } from \"./deep-scan-defaults.js\";\nimport { ConfigurationError } from \"./errors.js\";\nimport type { Finding, SeverityLevel } from \"./models.js\";\nimport type { AbsolutePath } from \"./config-path.js\";\nimport { SCAN_MODES, type ScanMode } from \"./scan-modes.js\";\nimport type { ScanTarget } from \"./targets.js\";\n\nexport const SCAN_AUTH_MODES = [\"auto\", \"chatgpt\", \"api-key\"] as const;\nexport type ScanAuthMode = (typeof SCAN_AUTH_MODES)[number];\nexport const DEFAULT_SCAN_AUTH = \"auto\";\nexport const DEFAULT_SCAN_MODE = \"standard\";\nexport const REPORTABLE_SEVERITIES = [\n \"critical\",\n \"high\",\n \"medium\",\n \"low\",\n] as const;\nexport const SCAN_SEVERITIES = [\n ...REPORTABLE_SEVERITIES,\n \"informational\",\n] as const;\nexport const FailureSeveritySchema = z.enum(REPORTABLE_SEVERITIES);\nexport type FailureSeverity = z.infer<typeof FailureSeveritySchema>;\n\n// SDK name, legacy TOML key, project key, and CLI flag (when exposed).\nexport const DEEP_SCAN_SETTINGS = [\n [\"workers\", \"workers\", \"workers\", \"--workers\"],\n [\"subagents\", \"subagents\", \"subagents_per_worker\", \"--subagents\"],\n [\n \"stopAfterNoNew\",\n \"stop_after_no_new\",\n \"stop_after_no_new\",\n \"--stop-after-no-new\",\n ],\n [\n \"stopAfterConsecutiveErrors\",\n \"stop_after_consecutive_errors\",\n \"stop_after_consecutive_errors\",\n null,\n ],\n [\n \"maxDiscoveryRuns\",\n \"max_discovery_runs\",\n \"max_discovery_runs\",\n \"--max-discovery-runs\",\n ],\n [\"maxTimeHours\", \"max_time_hours\", \"max_time_hours\", \"--max-time-hours\"],\n] as const;\n\nconst positiveIntegerError = \"must be a positive integer\";\nconst positiveInteger = z\n .number({ error: positiveIntegerError })\n .int({ error: positiveIntegerError })\n .positive({ error: positiveIntegerError });\nconst nonnegativeIntegerError = \"must be a non-negative integer\";\nconst nonnegativeInteger = z\n .number({ error: nonnegativeIntegerError })\n .int({ error: nonnegativeIntegerError })\n .nonnegative({ error: nonnegativeIntegerError });\nconst maximumHours = 96;\nconst hoursError = `must be a positive number no greater than ${maximumHours}`;\n\nexport const DeepScanSettingsSchema = z.strictObject({\n workers: positiveInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.workers,\n description: \"Maximum concurrent deep-scan discovery workers.\",\n }),\n subagents: nonnegativeInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.subagents,\n description: \"Subagents available to each deep-scan worker. Zero is valid.\",\n }),\n stopAfterNoNew: positiveInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.stopAfterNoNew,\n description: \"Stop after this many runs find no new issues.\",\n }),\n stopAfterConsecutiveErrors: positiveInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.stopAfterConsecutiveErrors,\n description: \"Stop after this many consecutive discovery errors.\",\n }),\n maxDiscoveryRuns: positiveInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.maxDiscoveryRuns,\n description: \"Maximum deep-scan discovery runs.\",\n }),\n maxTimeHours: z\n .number({ error: hoursError })\n .positive({ error: hoursError })\n .max(maximumHours, { error: hoursError })\n .optional()\n .meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.maxTimeHours,\n deprecated: true,\n description:\n \"Deprecated Deep-only alias for maxTimeMinutes / --max-time, in hours (default: 96; maximum: 96).\",\n }),\n});\n\nexport type DeepScanOptions = z.infer<typeof DeepScanSettingsSchema>;\n\nconst inputPath = z.string().min(1);\n\nexport const ScanSettingsSchema = DeepScanSettingsSchema.extend({\n auth: z.enum(SCAN_AUTH_MODES).optional().meta({ default: DEFAULT_SCAN_AUTH }),\n cyberAccessProgram: z\n .enum([\"standard\", \"daybreak_blue\", \"daybreak_red\"])\n .optional()\n .describe(\n \"Experimental Cyber access program for scan turns (OpenAI provider only). Omit to preserve Codex defaults.\",\n ),\n mode: z.enum(SCAN_MODES).optional().meta({ default: DEFAULT_SCAN_MODE }),\n maxTimeMinutes: z\n .number()\n .positive()\n .optional()\n .describe(\n \"Investigation minutes: advisory in Standard (default: unset); enforced Deep discovery limit (default and maximum: 5760). Scans may finish early; reporting may run longer.\",\n ),\n knowledgeBasePaths: z.array(inputPath).optional(),\n scanPrompt: z.string().optional(),\n scanPromptFile: inputPath.optional(),\n validationPrompt: z.string().optional(),\n validationPromptFile: inputPath.optional(),\n postScanPrompt: z.string().optional(),\n postScanPromptFile: inputPath.optional(),\n outputDir: inputPath.optional(),\n failureSeverity: z.enum(SCAN_SEVERITIES).optional(),\n maxCostUsd: z.number().positive().optional(),\n ownerSuggestions: z\n .boolean()\n .optional()\n .describe(\n \"Generate optional owner-suggestions.json after a committed scan (default: false).\",\n ),\n});\n\n/** Scan settings shared by SDK calls, CLI flags, and project files. */\nexport interface ScanSettings extends z.infer<typeof ScanSettingsSchema> {\n target?: ScanTarget;\n}\n\nexport interface ResolvedScanSettings extends ScanSettings {\n auth: ScanAuthMode;\n mode: ScanMode;\n target: ScanTarget;\n knowledgeBasePaths: AbsolutePath[];\n scanPromptFile?: AbsolutePath;\n validationPromptFile?: AbsolutePath;\n postScanPromptFile?: AbsolutePath;\n outputDir?: AbsolutePath;\n}\n\nexport type ScanPromptSettings = Pick<\n ScanSettings,\n | \"scanPrompt\"\n | \"scanPromptFile\"\n | \"validationPrompt\"\n | \"validationPromptFile\"\n | \"postScanPrompt\"\n | \"postScanPromptFile\"\n>;\n\n/** Pick defined scan settings without copying callbacks or workflow controls. */\nexport function pickScanSettings(settings: ScanSettings): ScanSettings {\n const keys = [\n \"target\",\n ...Object.keys(ScanSettingsSchema.shape),\n ] as (keyof ScanSettings)[];\n return Object.fromEntries(\n keys\n .filter((key) => settings[key] !== undefined)\n .map((key) => [key, settings[key]]),\n ) as ScanSettings;\n}\n\nexport function meetsSeverity(\n finding: Pick<Finding, \"severity\">,\n threshold: SeverityLevel,\n): boolean {\n const thresholdRank = severityThresholdRank(threshold);\n const severity = SCAN_SEVERITIES.indexOf(finding.severity.level);\n return severity >= 0 && severity <= thresholdRank;\n}\n\nexport function severityThresholdRank(threshold: SeverityLevel): number {\n const rank = SCAN_SEVERITIES.indexOf(threshold);\n if (rank < 0) {\n throw new ConfigurationError(\n `Unknown severity threshold: ${String(threshold)}.`,\n );\n }\n return rank;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scan-settings.js","sourceRoot":"","sources":["../src/scan-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EAAE,UAAU,EAAiB,MAAM,iBAAiB,CAAC;AAG5D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAU,CAAC;AAEvE,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACxC,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAC5C,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,UAAU;IACV,MAAM;IACN,QAAQ;IACR,KAAK;CACG,CAAC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CAAC,CAAC,CACtB,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,OAAkC,EAClC,SAAwB;IAExB,MAAM,aAAa,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACjE,OAAO,QAAQ,IAAI,CAAC,IAAI,QAAQ,IAAI,aAAa,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,SAAwB;IAC5D,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChD,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QACb,MAAM,IAAI,kBAAkB,CAC1B,+BAA+B,MAAM,CAAC,SAAS,CAAC,GAAG,CACpD,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { DEFAULT_DEEP_SCAN_SETTINGS } from \"./deep-scan-defaults.js\";\nimport { ConfigurationError } from \"./errors.js\";\nimport type { Finding, SeverityLevel } from \"./models.js\";\nimport type { AbsolutePath } from \"./config-path.js\";\nimport { SCAN_MODES, type ScanMode } from \"./scan-modes.js\";\nimport type { ScanTarget } from \"./targets.js\";\n\nexport const SCAN_AUTH_MODES = [\"auto\", \"chatgpt\", \"api-key\"] as const;\nexport type ScanAuthMode = (typeof SCAN_AUTH_MODES)[number];\nexport const DEFAULT_SCAN_AUTH = \"auto\";\nexport const DEFAULT_SCAN_MODE = \"standard\";\nexport const REPORTABLE_SEVERITIES = [\n \"critical\",\n \"high\",\n \"medium\",\n \"low\",\n] as const;\nexport const SCAN_SEVERITIES = [\n ...REPORTABLE_SEVERITIES,\n \"informational\",\n] as const;\nexport const FailureSeveritySchema = z.enum(REPORTABLE_SEVERITIES);\nexport type FailureSeverity = z.infer<typeof FailureSeveritySchema>;\n\nexport { DEEP_SCAN_SETTINGS } from \"./deep-scan-defaults.js\";\n\nconst positiveIntegerError = \"must be a positive integer\";\nconst positiveInteger = z\n .number({ error: positiveIntegerError })\n .int({ error: positiveIntegerError })\n .positive({ error: positiveIntegerError });\nconst nonnegativeIntegerError = \"must be a non-negative integer\";\nconst nonnegativeInteger = z\n .number({ error: nonnegativeIntegerError })\n .int({ error: nonnegativeIntegerError })\n .nonnegative({ error: nonnegativeIntegerError });\nconst maximumHours = 96;\nconst hoursError = `must be a positive number no greater than ${maximumHours}`;\n\nexport const DeepScanSettingsSchema = z.strictObject({\n workers: positiveInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.workers,\n description: \"Maximum concurrent deep-scan discovery workers.\",\n }),\n subagents: nonnegativeInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.subagents,\n description: \"Subagents available to each deep-scan worker. Zero is valid.\",\n }),\n stopAfterNoNew: positiveInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.stopAfterNoNew,\n description: \"Stop after this many runs find no new issues.\",\n }),\n stopAfterConsecutiveErrors: positiveInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.stopAfterConsecutiveErrors,\n description: \"Stop after this many consecutive discovery errors.\",\n }),\n maxDiscoveryRuns: positiveInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.maxDiscoveryRuns,\n description: \"Maximum deep-scan discovery runs.\",\n }),\n maxTimeHours: z\n .number({ error: hoursError })\n .positive({ error: hoursError })\n .max(maximumHours, { error: hoursError })\n .optional()\n .meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.maxTimeHours,\n deprecated: true,\n description:\n \"Deprecated Deep-only alias for maxTimeMinutes / --max-time, in hours (default: 96; maximum: 96).\",\n }),\n});\n\nexport type DeepScanOptions = z.infer<typeof DeepScanSettingsSchema>;\n\nconst inputPath = z.string().min(1);\n\nexport const ScanSettingsSchema = DeepScanSettingsSchema.extend({\n auth: z.enum(SCAN_AUTH_MODES).optional().meta({ default: DEFAULT_SCAN_AUTH }),\n cyberAccessProgram: z\n .enum([\"standard\", \"daybreak_blue\", \"daybreak_red\"])\n .optional()\n .describe(\n \"Experimental Cyber access program for scan turns (OpenAI provider only). Omit to preserve Codex defaults.\",\n ),\n mode: z.enum(SCAN_MODES).optional().meta({ default: DEFAULT_SCAN_MODE }),\n maxTimeMinutes: z\n .number()\n .positive()\n .optional()\n .describe(\n \"Investigation minutes: advisory in Standard (default: unset); enforced Deep discovery limit (default and maximum: 5760). Scans may finish early; reporting may run longer.\",\n ),\n knowledgeBasePaths: z.array(inputPath).optional(),\n scanPrompt: z.string().optional(),\n scanPromptFile: inputPath.optional(),\n validationPrompt: z.string().optional(),\n validationPromptFile: inputPath.optional(),\n postScanPrompt: z.string().optional(),\n postScanPromptFile: inputPath.optional(),\n outputDir: inputPath.optional(),\n failureSeverity: z.enum(SCAN_SEVERITIES).optional(),\n maxCostUsd: z.number().positive().optional(),\n ownerSuggestions: z\n .boolean()\n .optional()\n .describe(\n \"Generate optional owner-suggestions.json after a committed scan (default: false).\",\n ),\n});\n\n/** Scan settings shared by SDK calls, CLI flags, and project files. */\nexport interface ScanSettings extends z.infer<typeof ScanSettingsSchema> {\n target?: ScanTarget;\n}\n\nexport interface ResolvedScanSettings extends ScanSettings {\n auth: ScanAuthMode;\n mode: ScanMode;\n target: ScanTarget;\n knowledgeBasePaths: AbsolutePath[];\n scanPromptFile?: AbsolutePath;\n validationPromptFile?: AbsolutePath;\n postScanPromptFile?: AbsolutePath;\n outputDir?: AbsolutePath;\n}\n\nexport type ScanPromptSettings = Pick<\n ScanSettings,\n | \"scanPrompt\"\n | \"scanPromptFile\"\n | \"validationPrompt\"\n | \"validationPromptFile\"\n | \"postScanPrompt\"\n | \"postScanPromptFile\"\n>;\n\n/** Pick defined scan settings without copying callbacks or workflow controls. */\nexport function pickScanSettings(settings: ScanSettings): ScanSettings {\n const keys = [\n \"target\",\n ...Object.keys(ScanSettingsSchema.shape),\n ] as (keyof ScanSettings)[];\n return Object.fromEntries(\n keys\n .filter((key) => settings[key] !== undefined)\n .map((key) => [key, settings[key]]),\n ) as ScanSettings;\n}\n\nexport function meetsSeverity(\n finding: Pick<Finding, \"severity\">,\n threshold: SeverityLevel,\n): boolean {\n const thresholdRank = severityThresholdRank(threshold);\n const severity = SCAN_SEVERITIES.indexOf(finding.severity.level);\n return severity >= 0 && severity <= thresholdRank;\n}\n\nexport function severityThresholdRank(threshold: SeverityLevel): number {\n const rank = SCAN_SEVERITIES.indexOf(threshold);\n if (rank < 0) {\n throw new ConfigurationError(\n `Unknown severity threshold: ${String(threshold)}.`,\n );\n }\n return rank;\n}\n"]}
|
package/dist/scanner-import.d.ts
CHANGED
|
@@ -2,16 +2,33 @@ import { type FileHandle } from "node:fs/promises";
|
|
|
2
2
|
import type { ExternalFinding, ExternalFindings } from "./external-findings.js";
|
|
3
3
|
export declare function record(value: unknown, label: string): Record<string, unknown>;
|
|
4
4
|
export declare function array(value: unknown, label: string): unknown[];
|
|
5
|
+
export declare function optionalArray(value: unknown, label: string): unknown[];
|
|
6
|
+
export declare function validateSarifRun(run: Record<string, unknown>, producer: string): void;
|
|
5
7
|
export declare function text(value: unknown): string | null;
|
|
8
|
+
/** AWS APIs use epoch seconds and AWS CLI exports use timezone-qualified ISO dates. */
|
|
9
|
+
export declare function awsTimestampSeconds(value: unknown): number;
|
|
10
|
+
export declare function concreteVersion(value: unknown, ecosystem: string | null, osPackage: boolean): string | null;
|
|
6
11
|
export declare function requiredText(value: unknown, label: string): string;
|
|
12
|
+
/** SARIF repository claims must be checked even when a run has no results. */
|
|
13
|
+
export declare function sarifRunRepositories(run: unknown, producer: string): {
|
|
14
|
+
url: string;
|
|
15
|
+
branch?: string;
|
|
16
|
+
}[];
|
|
17
|
+
/** Normalize scanners whose reported severities range from low to critical. */
|
|
18
|
+
export declare function reportableScannerSeverity(value: unknown): "critical" | "high" | "low" | "medium" | "unknown";
|
|
19
|
+
export declare function scannerSeverity(value: string | null | undefined): "critical" | "high" | "informational" | "low" | "medium" | "unknown";
|
|
7
20
|
export declare function strings(value: unknown): string[];
|
|
8
21
|
/** Paths that cannot be attributed to a repository stay in original evidence. */
|
|
9
22
|
export declare function relativePath(value: unknown): string | null;
|
|
23
|
+
export declare function hostedRepositoryPath(value: unknown): string | null;
|
|
10
24
|
export declare function repositoryFilePath(value: unknown): string | null;
|
|
11
25
|
export declare function stableId(prefix: string, fields: unknown[]): string;
|
|
26
|
+
export declare function readScannerBytes(path: string | FileHandle): Promise<Buffer>;
|
|
12
27
|
export declare function readScannerText(path: string): Promise<string>;
|
|
13
28
|
export declare function parseJsonOrJsonl(contents: string): unknown;
|
|
14
|
-
|
|
29
|
+
/** Bind a normalized JSON report reader to the SDK's file entrypoint. */
|
|
30
|
+
export declare function scannerJsonReader<Options extends unknown[]>(normalize: (report: unknown, ...options: Options) => ExternalFindings): (path: string, ...options: Options) => Promise<ExternalFindings>;
|
|
31
|
+
export declare function readScannerJson(path: string | FileHandle, parse?: (json: string) => unknown): Promise<unknown>;
|
|
15
32
|
/** Empty reference containers and property-bag metadata do not externalize data. */
|
|
16
33
|
export declare function hasSarifExternalPropertyReferences(value: unknown): boolean;
|
|
17
34
|
/** Keep original artifact indexes; omit only inventory unrelated to this finding. */
|
|
@@ -22,8 +39,11 @@ type IndexedSarifRule = {
|
|
|
22
39
|
};
|
|
23
40
|
/** Duplicate IDs cannot identify a single rule in this run. */
|
|
24
41
|
export declare function indexSarifRules(entries: Iterable<[number, Record<string, unknown>]>): Map<unknown, IndexedSarifRule | null>;
|
|
42
|
+
type SarifRun = Record<"document" | "run" | "tool" | "driver", Record<string, unknown>>;
|
|
43
|
+
/** Unpack the common SARIF envelope; each reader qualifies its own producer. */
|
|
44
|
+
export declare function readSarifRuns<T>(input: unknown, producer: "Semgrep" | "Snyk" | "Endor", read: (context: SarifRun) => T[]): T[];
|
|
25
45
|
/** Pair each result with its shared run context and original evidence. */
|
|
26
|
-
export declare function sarifRunResults(document
|
|
46
|
+
export declare function sarifRunResults({ document, run, tool, driver }: SarifRun, producer: "Endor" | "Semgrep"): {
|
|
27
47
|
result: unknown;
|
|
28
48
|
context: {
|
|
29
49
|
rulesById: Map<unknown, IndexedSarifRule | null>;
|
|
@@ -48,17 +68,9 @@ export declare function sarifRunResults(document: Record<string, unknown>, run:
|
|
|
48
68
|
}[];
|
|
49
69
|
/** The top-level index and nested descriptor must agree with the selected driver rule. */
|
|
50
70
|
export declare function validateSarifRuleReference(result: Record<string, unknown>, ruleId: string, selected: IndexedSarifRule | undefined, producer: "Endor" | "Semgrep" | "Snyk"): void;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export declare function trackReaderSelection(result: ExternalFindings): {
|
|
54
|
-
append: (position: number, id: string, project: () => ExternalFinding["evidence"]) => void;
|
|
55
|
-
finish: (filter?: SelectionFilter) => ExternalFindings;
|
|
56
|
-
uncertainIds: Set<string>;
|
|
57
|
-
};
|
|
71
|
+
/** Append the evidence or its exclusion at the original input position. */
|
|
72
|
+
export declare function appendFinding(result: ExternalFindings, position: number, id: string, project: () => ExternalFinding["evidence"]): void;
|
|
58
73
|
/** Exclude every colliding record: choosing the first could overwrite another occurrence. */
|
|
59
|
-
export declare function normalizeRecords<T>(records: T[], projectEvidence: (record: T, id: string) => ExternalFinding["evidence"], identify: (record: T) => string, target?: "local" | "cloud", options?:
|
|
60
|
-
report?: ExternalFindings["report"];
|
|
61
|
-
filter?: SelectionFilter;
|
|
62
|
-
}): ExternalFindings;
|
|
74
|
+
export declare function normalizeRecords<T>(records: T[], projectEvidence: (record: T, id: string) => ExternalFinding["evidence"], identify: (record: T) => string, target?: "local" | "cloud", options?: Pick<ExternalFindings, "report">): ExternalFindings;
|
|
63
75
|
export {};
|
|
64
76
|
//# sourceMappingURL=scanner-import.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanner-import.d.ts","sourceRoot":"","sources":["../src/scanner-import.ts"],"names":[],"mappings":"AACA,OAA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BAAgB,aAAa,CAC3B,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,eAAe,CAAC,UAAU,CAAC,QAW3C;AAED,6FAA6F;AAC7F,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,OAAO,EAAE,CAAC,EAAE,EACZ,eAAe,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,KAAK,eAAe,CAAC,UAAU,CAAC,EACvE,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,EAC/B,MAAM,GAAE,OAAO,GAAG,OAAiB,EACnC,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAM,GAC7C,gBAAgB,CA8ClB"}
|
package/dist/scanner-import.js
CHANGED
|
@@ -3,10 +3,10 @@ import { readFile } from "node:fs/promises";
|
|
|
3
3
|
import { posix } from "node:path";
|
|
4
4
|
import { promisify } from "node:util";
|
|
5
5
|
import { gunzip } from "node:zlib";
|
|
6
|
+
import validSemver from "semver/functions/valid.js";
|
|
6
7
|
import { CodexSecurityError, errorMessage } from "./errors.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { rememberPreviousSelection } from "./reader-selection.js";
|
|
8
|
+
import { REPORTABLE_SEVERITIES, SCAN_SEVERITIES } from "./scan-settings.js";
|
|
9
|
+
import { asRecord, isRecord } from "./record.js";
|
|
10
10
|
export function record(value, label) {
|
|
11
11
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
12
12
|
throw new Error(`${label} must be an object.`);
|
|
@@ -17,15 +17,172 @@ export function array(value, label) {
|
|
|
17
17
|
throw new Error(`${label} must be an array.`);
|
|
18
18
|
return value;
|
|
19
19
|
}
|
|
20
|
+
export function optionalArray(value, label) {
|
|
21
|
+
return value === undefined ? [] : array(value, label);
|
|
22
|
+
}
|
|
23
|
+
// SARIF uses the same index/GUID/ID references for components and descriptors.
|
|
24
|
+
function sarifReferences(entries, select, first = 0) {
|
|
25
|
+
const refs = new Map();
|
|
26
|
+
entries.forEach((entry, index) => {
|
|
27
|
+
if (!isRecord(entry))
|
|
28
|
+
return;
|
|
29
|
+
const item = select(entry);
|
|
30
|
+
refs.set(index + first, item);
|
|
31
|
+
if (typeof entry["guid"] === "string")
|
|
32
|
+
refs.set("guid:" + entry["guid"].toLowerCase(), item);
|
|
33
|
+
if (typeof entry["id"] === "string")
|
|
34
|
+
refs.set("id:" + entry["id"], item);
|
|
35
|
+
});
|
|
36
|
+
return (ref) => {
|
|
37
|
+
const { index, guid, id } = asRecord(ref) ?? {};
|
|
38
|
+
if (typeof index === "number" && index >= 0)
|
|
39
|
+
return refs.get(index);
|
|
40
|
+
if (typeof guid === "string")
|
|
41
|
+
return refs.get("guid:" + guid.toLowerCase());
|
|
42
|
+
return typeof id === "string" ? refs.get("id:" + id) : refs.get(-1);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function notificationDescriptors(value) {
|
|
46
|
+
const tool = asRecord(value);
|
|
47
|
+
// The driver is the default component (-1); extension indexes start at 0.
|
|
48
|
+
const component = sarifReferences([
|
|
49
|
+
tool?.["driver"],
|
|
50
|
+
...optionalArray(tool?.["extensions"], "SARIF tool extensions"),
|
|
51
|
+
], (owner) => sarifReferences(optionalArray(owner["notifications"], "SARIF notification descriptors"), (entry) => entry), -1);
|
|
52
|
+
return (ref) => component(asRecord(ref)?.["toolComponent"])?.(ref);
|
|
53
|
+
}
|
|
54
|
+
export function validateSarifRun(run, producer) {
|
|
55
|
+
if (hasSarifExternalPropertyReferences(run["externalPropertyFileReferences"]))
|
|
56
|
+
throw new Error(`Use a self-contained ${producer} SARIF report.`);
|
|
57
|
+
function validate(values, tool, strictExecution) {
|
|
58
|
+
let descriptors;
|
|
59
|
+
const resolve = (ref) => isRecord(ref)
|
|
60
|
+
? (descriptors ??= notificationDescriptors(tool))(ref)
|
|
61
|
+
: undefined;
|
|
62
|
+
for (const value of values) {
|
|
63
|
+
const invocation = record(value, `${producer} invocation`);
|
|
64
|
+
const successful = invocation["executionSuccessful"];
|
|
65
|
+
if (typeof successful !== "boolean")
|
|
66
|
+
throw new Error(`${producer} SARIF executionSuccessful must be a boolean.`);
|
|
67
|
+
const list = (key) => optionalArray(invocation[key], `${producer} ${key}`);
|
|
68
|
+
const execution = list("toolExecutionNotifications");
|
|
69
|
+
const notices = execution.concat(list("toolConfigurationNotifications"));
|
|
70
|
+
if (!successful) {
|
|
71
|
+
const details = [
|
|
72
|
+
invocation["processStartFailureMessage"],
|
|
73
|
+
invocation["exitCodeDescription"],
|
|
74
|
+
invocation["exitCode"],
|
|
75
|
+
invocation["exitSignalName"],
|
|
76
|
+
...notices,
|
|
77
|
+
].filter((value) => value !== undefined);
|
|
78
|
+
throw new Error(`${producer} SARIF contains an unsuccessful invocation.${details.length ? " " + JSON.stringify(details) : ""}`);
|
|
79
|
+
}
|
|
80
|
+
if (strictExecution && execution.length)
|
|
81
|
+
throw new Error(`${producer} SARIF contains scan error notifications: ${JSON.stringify(execution)}`);
|
|
82
|
+
const levels = new Map();
|
|
83
|
+
for (const value of list("notificationConfigurationOverrides")) {
|
|
84
|
+
const override = asRecord(value);
|
|
85
|
+
const descriptor = resolve(override?.["descriptor"]);
|
|
86
|
+
const level = asRecord(override?.["configuration"])?.["level"];
|
|
87
|
+
if (descriptor && level !== undefined)
|
|
88
|
+
levels.set(descriptor, level);
|
|
89
|
+
}
|
|
90
|
+
for (const value of notices) {
|
|
91
|
+
const notice = record(value, `${producer} notification`);
|
|
92
|
+
const descriptor = resolve(notice["descriptor"]);
|
|
93
|
+
const level = notice["level"] ??
|
|
94
|
+
(descriptor && levels.get(descriptor)) ??
|
|
95
|
+
asRecord(descriptor?.["defaultConfiguration"])?.["level"];
|
|
96
|
+
if (level === "error")
|
|
97
|
+
throw new Error(`${producer} SARIF contains scan error notifications: ${JSON.stringify(notice)}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Semgrep reports scanner errors as execution notices even below error level.
|
|
102
|
+
validate(optionalArray(run["invocations"], `${producer} invocations`), run["tool"], producer === "Semgrep");
|
|
103
|
+
if (run["conversion"] !== undefined) {
|
|
104
|
+
const conversion = record(run["conversion"], `${producer} conversion`);
|
|
105
|
+
if (conversion["invocation"] !== undefined)
|
|
106
|
+
validate([conversion["invocation"]], conversion["tool"], false);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
20
109
|
export function text(value) {
|
|
21
110
|
return typeof value === "string" && value.trim() ? value : null;
|
|
22
111
|
}
|
|
112
|
+
/** AWS APIs use epoch seconds and AWS CLI exports use timezone-qualified ISO dates. */
|
|
113
|
+
export function awsTimestampSeconds(value) {
|
|
114
|
+
if (typeof value === "number")
|
|
115
|
+
return value;
|
|
116
|
+
if (typeof value === "string" &&
|
|
117
|
+
/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d+)?(?:Z|[+-]\d\d:\d\d)$/u.test(value))
|
|
118
|
+
return Date.parse(value) / 1000;
|
|
119
|
+
return NaN;
|
|
120
|
+
}
|
|
121
|
+
export function concreteVersion(value, ecosystem, osPackage) {
|
|
122
|
+
const version = text(value);
|
|
123
|
+
if (!version)
|
|
124
|
+
return null;
|
|
125
|
+
// Debian versions use internal tildes for prereleases and backports.
|
|
126
|
+
if (osPackage && version.includes("~"))
|
|
127
|
+
return /^(?:\d+:)?\d[a-z\d.+~]*(?:-[a-z\d.+~]+)*$/iu.test(version)
|
|
128
|
+
? version
|
|
129
|
+
: null;
|
|
130
|
+
if (validSemver(version))
|
|
131
|
+
return version;
|
|
132
|
+
if (ecosystem === "npm" || ecosystem === "cargo")
|
|
133
|
+
return null;
|
|
134
|
+
if (ecosystem === "java" || ecosystem === "maven") {
|
|
135
|
+
if (version === "LATEST" ||
|
|
136
|
+
version === "RELEASE" ||
|
|
137
|
+
version.startsWith("latest."))
|
|
138
|
+
return null;
|
|
139
|
+
return /^[a-z\d][\w.+-]*$/iu.test(version) && !version.endsWith("+")
|
|
140
|
+
? version
|
|
141
|
+
: null;
|
|
142
|
+
}
|
|
143
|
+
if (!ecosystem && version.endsWith("+"))
|
|
144
|
+
return null;
|
|
145
|
+
const publicVersion = ecosystem === "pypi" ? version.split("+", 1)[0] : version;
|
|
146
|
+
return /\d/u.test(version) &&
|
|
147
|
+
/^(?:\d+:)?[a-z\d][\w.+!-]*$/iu.test(version) &&
|
|
148
|
+
!/(?:^|\.)x(?:\.|$)/iu.test(publicVersion)
|
|
149
|
+
? version
|
|
150
|
+
: null;
|
|
151
|
+
}
|
|
23
152
|
export function requiredText(value, label) {
|
|
24
153
|
const result = text(value);
|
|
25
154
|
if (!result)
|
|
26
155
|
throw new Error(`${label} must be nonempty text.`);
|
|
27
156
|
return result;
|
|
28
157
|
}
|
|
158
|
+
/** SARIF repository claims must be checked even when a run has no results. */
|
|
159
|
+
export function sarifRunRepositories(run, producer) {
|
|
160
|
+
if (run == null)
|
|
161
|
+
return [];
|
|
162
|
+
return array(record(run, `${producer} run context`)["versionControlProvenance"] ?? [], `${producer} version control provenance`).flatMap((entry) => {
|
|
163
|
+
const ref = record(entry, `${producer} repository provenance`);
|
|
164
|
+
const url = producer === "Semgrep"
|
|
165
|
+
? text(ref["repositoryUri"])
|
|
166
|
+
: requiredText(ref["repositoryUri"], `${producer} repository URI`);
|
|
167
|
+
if (url === null)
|
|
168
|
+
return [];
|
|
169
|
+
const branch = ref["branch"];
|
|
170
|
+
return [
|
|
171
|
+
{
|
|
172
|
+
url,
|
|
173
|
+
...(producer === "Semgrep" && typeof branch === "string" && { branch }),
|
|
174
|
+
},
|
|
175
|
+
];
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/** Normalize scanners whose reported severities range from low to critical. */
|
|
179
|
+
export function reportableScannerSeverity(value) {
|
|
180
|
+
const level = text(value)?.toLowerCase();
|
|
181
|
+
return (REPORTABLE_SEVERITIES.find((severity) => severity === level) ?? "unknown");
|
|
182
|
+
}
|
|
183
|
+
export function scannerSeverity(value) {
|
|
184
|
+
return SCAN_SEVERITIES.find((severity) => severity === value) ?? "unknown";
|
|
185
|
+
}
|
|
29
186
|
export function strings(value) {
|
|
30
187
|
return Array.isArray(value)
|
|
31
188
|
? value.filter((v) => text(v) !== null)
|
|
@@ -42,6 +199,13 @@ export function relativePath(value) {
|
|
|
42
199
|
? path
|
|
43
200
|
: null;
|
|
44
201
|
}
|
|
202
|
+
// Hosted findings do not identify the scanner operating system or its path separator.
|
|
203
|
+
export function hostedRepositoryPath(value) {
|
|
204
|
+
const path = text(value);
|
|
205
|
+
return path && !path.includes("\\") && !path.includes("://")
|
|
206
|
+
? relativePath(path)
|
|
207
|
+
: null;
|
|
208
|
+
}
|
|
45
209
|
export function repositoryFilePath(value) {
|
|
46
210
|
const relative = relativePath(value);
|
|
47
211
|
if (!relative)
|
|
@@ -59,12 +223,25 @@ export function stableId(prefix, fields) {
|
|
|
59
223
|
}
|
|
60
224
|
const strictUtf8 = new TextDecoder("utf-8", { fatal: true });
|
|
61
225
|
const gunzipAsync = promisify(gunzip);
|
|
62
|
-
async function
|
|
226
|
+
async function readScannerInput(path) {
|
|
63
227
|
const bytes = await readFile(path);
|
|
64
|
-
|
|
228
|
+
const gzip = bytes[0] === 0x1f && bytes[1] === 0x8b;
|
|
229
|
+
return { gzip, bytes: gzip ? await gunzipAsync(bytes) : bytes };
|
|
230
|
+
}
|
|
231
|
+
export async function readScannerBytes(path) {
|
|
232
|
+
return (await readScannerInput(path)).bytes;
|
|
65
233
|
}
|
|
66
234
|
export async function readScannerText(path) {
|
|
67
|
-
|
|
235
|
+
const { bytes, gzip } = await readScannerInput(path);
|
|
236
|
+
const contents = strictUtf8.decode(bytes);
|
|
237
|
+
// Empty JSONL is a valid stream of zero records; a blank JSON or CSV document isn't.
|
|
238
|
+
if (!contents.trim()) {
|
|
239
|
+
if (!gzip && /\.gz$/iu.test(path))
|
|
240
|
+
throw new Error("The report is blank and contains no gzip stream.");
|
|
241
|
+
if (/\.(?:json|csv)(?:\.gz)?$/iu.test(path))
|
|
242
|
+
throw new Error("The report is blank.");
|
|
243
|
+
}
|
|
244
|
+
return contents;
|
|
68
245
|
}
|
|
69
246
|
export function parseJsonOrJsonl(contents) {
|
|
70
247
|
try {
|
|
@@ -77,7 +254,11 @@ export function parseJsonOrJsonl(contents) {
|
|
|
77
254
|
.map((line) => JSON.parse(line));
|
|
78
255
|
}
|
|
79
256
|
}
|
|
80
|
-
|
|
257
|
+
/** Bind a normalized JSON report reader to the SDK's file entrypoint. */
|
|
258
|
+
export function scannerJsonReader(normalize) {
|
|
259
|
+
return async (path, ...options) => normalize(await readScannerJson(path), ...options);
|
|
260
|
+
}
|
|
261
|
+
export async function readScannerJson(path, parse = JSON.parse) {
|
|
81
262
|
const bytes = await readScannerBytes(path);
|
|
82
263
|
let decoded;
|
|
83
264
|
try {
|
|
@@ -87,7 +268,7 @@ export async function readScannerJson(path) {
|
|
|
87
268
|
throw new CodexSecurityError(`Scanner report is not valid UTF-8. ${errorMessage(error)}`, { cause: error });
|
|
88
269
|
}
|
|
89
270
|
try {
|
|
90
|
-
return
|
|
271
|
+
return parse(decoded.replace(/^\uFEFF/u, ""));
|
|
91
272
|
}
|
|
92
273
|
catch (error) {
|
|
93
274
|
throw new CodexSecurityError(`Scanner JSON could not be parsed. ${errorMessage(error)}`, { cause: error });
|
|
@@ -196,8 +377,21 @@ export function indexSarifRules(entries) {
|
|
|
196
377
|
}
|
|
197
378
|
return byId;
|
|
198
379
|
}
|
|
380
|
+
/** Unpack the common SARIF envelope; each reader qualifies its own producer. */
|
|
381
|
+
export function readSarifRuns(input, producer, read) {
|
|
382
|
+
const document = record(input, `${producer} SARIF`);
|
|
383
|
+
if (document["version"] !== "2.1.0")
|
|
384
|
+
throw new Error(`Expected ${producer} SARIF 2.1.0.`);
|
|
385
|
+
return array(document["runs"], "SARIF runs").flatMap((value) => {
|
|
386
|
+
const run = record(value, "SARIF run");
|
|
387
|
+
const tool = record(run["tool"], "SARIF tool");
|
|
388
|
+
const driver = record(tool["driver"], "SARIF driver");
|
|
389
|
+
return read({ document, run, tool, driver });
|
|
390
|
+
});
|
|
391
|
+
}
|
|
199
392
|
/** Pair each result with its shared run context and original evidence. */
|
|
200
|
-
export function sarifRunResults(document, run, tool, driver, producer) {
|
|
393
|
+
export function sarifRunResults({ document, run, tool, driver }, producer) {
|
|
394
|
+
validateSarifRun(run, producer);
|
|
201
395
|
const rules = array(driver["rules"] ?? [], `${producer} rules`).map((rule) => record(rule, `${producer} rule`));
|
|
202
396
|
const rulesById = indexSarifRules(rules.entries());
|
|
203
397
|
const { runs: _runs, ...documentContext } = document;
|
|
@@ -223,7 +417,7 @@ export function sarifRunResults(document, run, tool, driver, producer) {
|
|
|
223
417
|
});
|
|
224
418
|
},
|
|
225
419
|
};
|
|
226
|
-
return
|
|
420
|
+
return optionalArray(run["results"], `${producer} results`).map((result) => ({
|
|
227
421
|
result,
|
|
228
422
|
context,
|
|
229
423
|
}));
|
|
@@ -248,92 +442,18 @@ export function validateSarifRuleReference(result, ruleId, selected, producer) {
|
|
|
248
442
|
? "Result uses an inconsistent or external rule reference."
|
|
249
443
|
: `Inconsistent or external ${producer} rule reference.`);
|
|
250
444
|
}
|
|
251
|
-
/**
|
|
252
|
-
export function
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
function append(position, id, project) {
|
|
256
|
-
const index = result.findings.length;
|
|
257
|
-
let outcome;
|
|
258
|
-
try {
|
|
259
|
-
const evidence = project();
|
|
260
|
-
outcome = evidence;
|
|
261
|
-
result.findings.push({ source_finding_id: id, evidence });
|
|
262
|
-
}
|
|
263
|
-
catch (error) {
|
|
264
|
-
outcome = error;
|
|
265
|
-
result.excluded.push({
|
|
266
|
-
position,
|
|
267
|
-
source_finding_id: id,
|
|
268
|
-
reason: errorMessage(error),
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
const previous = outcome && typeof outcome === "object"
|
|
272
|
-
? previousAdmission(outcome)
|
|
273
|
-
: undefined;
|
|
274
|
-
if (previous === "uncertain")
|
|
275
|
-
uncertainIds.add(id);
|
|
276
|
-
else if (previous !== undefined)
|
|
277
|
-
changes.push({ index, position, id, previous });
|
|
445
|
+
/** Append the evidence or its exclusion at the original input position. */
|
|
446
|
+
export function appendFinding(result, position, id, project) {
|
|
447
|
+
try {
|
|
448
|
+
result.findings.push({ source_finding_id: id, evidence: project() });
|
|
278
449
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
const excluded = [];
|
|
286
|
-
const restoredPositions = new Set();
|
|
287
|
-
let cursor = 0;
|
|
288
|
-
for (const { index, position, id, previous } of changes) {
|
|
289
|
-
while (cursor < index)
|
|
290
|
-
findings.push(result.findings[cursor++]);
|
|
291
|
-
if (previous) {
|
|
292
|
-
findings.push({ source_finding_id: id, evidence: previous });
|
|
293
|
-
restoredPositions.add(position);
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
cursor++;
|
|
297
|
-
excluded.push({
|
|
298
|
-
position,
|
|
299
|
-
source_finding_id: id,
|
|
300
|
-
reason: "Evidence exceeds the Cloud limit of 256 KiB.",
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
while (cursor < result.findings.length)
|
|
305
|
-
findings.push(result.findings[cursor++]);
|
|
306
|
-
for (const row of result.excluded) {
|
|
307
|
-
if (!restoredPositions.has(row.position))
|
|
308
|
-
excluded.push(row);
|
|
309
|
-
}
|
|
310
|
-
excluded.sort((a, b) => a.position - b.position);
|
|
311
|
-
const previous = { ...result, findings, excluded };
|
|
312
|
-
// A removed sibling could have depended on an unproven row for its scope.
|
|
313
|
-
filter?.(previous, uncertainIds.size ? uncertainIds : undefined);
|
|
314
|
-
filter?.(result);
|
|
315
|
-
const sourceFindingIds = [
|
|
316
|
-
...new Set([
|
|
317
|
-
...previous.findings.map((row) => row.source_finding_id),
|
|
318
|
-
...uncertainIds,
|
|
319
|
-
]),
|
|
320
|
-
];
|
|
321
|
-
if (uncertainIds.size) {
|
|
322
|
-
rememberPreviousSelection(result, {
|
|
323
|
-
sourceFindingIds,
|
|
324
|
-
uncertainFindingIds: [...uncertainIds],
|
|
325
|
-
knownFindings: structuredClone(previous.findings.filter((row) => !uncertainIds.has(row.source_finding_id))),
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
else {
|
|
329
|
-
rememberPreviousSelection(result, {
|
|
330
|
-
sourceFindingIds,
|
|
331
|
-
snapshot: structuredClone(previous),
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
return result;
|
|
450
|
+
catch (error) {
|
|
451
|
+
result.excluded.push({
|
|
452
|
+
position,
|
|
453
|
+
source_finding_id: id,
|
|
454
|
+
reason: errorMessage(error),
|
|
455
|
+
});
|
|
335
456
|
}
|
|
336
|
-
return { append, finish, uncertainIds };
|
|
337
457
|
}
|
|
338
458
|
/** Exclude every colliding record: choosing the first could overwrite another occurrence. */
|
|
339
459
|
export function normalizeRecords(records, projectEvidence, identify, target = "cloud", options = {}) {
|
|
@@ -343,7 +463,6 @@ export function normalizeRecords(records, projectEvidence, identify, target = "c
|
|
|
343
463
|
excluded: [],
|
|
344
464
|
...(options.report === undefined ? {} : { report: options.report }),
|
|
345
465
|
};
|
|
346
|
-
const selection = trackReaderSelection(result);
|
|
347
466
|
const identified = [];
|
|
348
467
|
const counts = new Map();
|
|
349
468
|
for (const [index, value] of records.entries()) {
|
|
@@ -375,9 +494,9 @@ export function normalizeRecords(records, projectEvidence, identify, target = "c
|
|
|
375
494
|
});
|
|
376
495
|
continue;
|
|
377
496
|
}
|
|
378
|
-
|
|
497
|
+
appendFinding(result, position, id, () => projectEvidence(value, id));
|
|
379
498
|
}
|
|
380
499
|
result.excluded.sort((a, b) => a.position - b.position);
|
|
381
|
-
return
|
|
500
|
+
return result;
|
|
382
501
|
}
|
|
383
502
|
//# sourceMappingURL=scanner-import.js.map
|