@openai/codex-security 0.8.2 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +201 -178
- package/_bundled_plugin/.app.json +4 -0
- package/_bundled_plugin/.mcp.json +6 -1
- package/_bundled_plugin/examples/completed-scan/findings.json +16 -4
- package/_bundled_plugin/examples/completed-scan/report.md +11 -8
- package/_bundled_plugin/examples/completed-scan/scan-manifest.json +4 -2
- package/_bundled_plugin/mcp/fzstd-LICENSE.txt +21 -0
- package/_bundled_plugin/mcp/helpers.mjs +2 -11
- package/_bundled_plugin/mcp/helpers.mjs.br +0 -0
- package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +3 -210
- package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
- package/_bundled_plugin/mcp/package.json +1 -0
- package/_bundled_plugin/mcp/permission-profile-preflight.mjs +51 -14
- package/_bundled_plugin/mcp/server.mjs +2 -11
- package/_bundled_plugin/mcp/server.mjs.br +0 -0
- package/_bundled_plugin/mcp/session-decompression.mjs +712 -0
- package/_bundled_plugin/references/artifact-storage.md +1 -1
- package/_bundled_plugin/references/core-scan.md +14 -5
- package/_bundled_plugin/references/default-severity-rubric.md +33 -0
- package/_bundled_plugin/references/final-report.md +5 -3
- package/_bundled_plugin/references/finding-detail-fields.md +19 -18
- package/_bundled_plugin/references/sarif-adapter.md +8 -2
- package/_bundled_plugin/references/scan-artifacts.md +21 -12
- package/_bundled_plugin/references/scan-contract.md +27 -33
- package/_bundled_plugin/references/threat-model.md +1 -0
- package/_bundled_plugin/schemas/tools/scan-draft.schema.json +2 -2
- package/_bundled_plugin/scripts/check_deep_scan_target.py +97 -0
- package/_bundled_plugin/scripts/codex_profile.mjs +7 -1
- package/_bundled_plugin/scripts/deep_scan_config.py +20 -1
- package/_bundled_plugin/scripts/deep_scan_workbench.py +188 -454
- package/_bundled_plugin/scripts/filesystem_identity.py +1 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +317 -377
- package/_bundled_plugin/scripts/finding_preview.py +25 -29
- package/_bundled_plugin/scripts/launch_codex_security_mcp +1 -0
- package/_bundled_plugin/scripts/legacy_findings.py +148 -0
- package/_bundled_plugin/scripts/posix_scan_local_files.py +198 -0
- package/_bundled_plugin/scripts/read_codex_session.mjs +21 -0
- package/_bundled_plugin/scripts/report_projection.py +167 -178
- package/_bundled_plugin/scripts/review_state.py +8 -2
- package/_bundled_plugin/scripts/servicenow_avit.py +20 -0
- package/_bundled_plugin/scripts/snapshot_sqlite.py +1 -0
- package/_bundled_plugin/scripts/threat_model_projection.py +22 -26
- package/_bundled_plugin/scripts/validate_scan_contract.py +9 -7
- package/_bundled_plugin/scripts/windows_scan_local_files.py +600 -72
- package/_bundled_plugin/scripts/workbench/__init__.py +1 -1
- package/_bundled_plugin/scripts/workbench/handoff.py +47 -0
- package/_bundled_plugin/scripts/workbench/retained_coverage.py +38 -75
- package/_bundled_plugin/scripts/workbench/retained_records.py +18 -30
- package/_bundled_plugin/scripts/workbench/runtime_toml.py +4 -1
- package/_bundled_plugin/scripts/workbench/saved_coverage.py +152 -248
- package/_bundled_plugin/scripts/workbench/saved_outputs.py +9 -0
- package/_bundled_plugin/scripts/workbench/saved_sources.py +47 -40
- package/_bundled_plugin/scripts/workbench/storage.py +71 -7
- package/_bundled_plugin/scripts/workbench_cli.py +121 -14
- package/_bundled_plugin/scripts/workbench_constants.py +19 -0
- package/_bundled_plugin/scripts/workbench_coverage_receipts.py +3 -3
- package/_bundled_plugin/scripts/workbench_db.py +550 -492
- package/_bundled_plugin/scripts/workbench_feedback.py +8 -7
- package/_bundled_plugin/scripts/workbench_finding_index.py +1 -0
- package/_bundled_plugin/scripts/workbench_finding_workflows.py +90 -4
- package/_bundled_plugin/scripts/workbench_native_indexes.py +29 -33
- package/_bundled_plugin/scripts/workbench_progress.py +10 -1
- package/_bundled_plugin/scripts/workbench_publication.py +14 -10
- package/_bundled_plugin/scripts/workbench_remediation.py +508 -11
- package/_bundled_plugin/scripts/workbench_saved_results.py +132 -77
- package/_bundled_plugin/scripts/workbench_scan_history.py +139 -80
- package/_bundled_plugin/scripts/workbench_scan_start.py +84 -25
- package/_bundled_plugin/scripts/workbench_scan_usage.py +666 -117
- package/_bundled_plugin/scripts/workbench_schema.py +44 -55
- package/_bundled_plugin/scripts/workbench_setup.py +251 -0
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +13 -0
- package/_bundled_plugin/scripts/workbench_source_scopes.py +33 -23
- package/_bundled_plugin/scripts/workbench_target.py +330 -66
- package/_bundled_plugin/scripts/workbench_target_state.py +3 -0
- package/_bundled_plugin/scripts/workbench_validation.py +44 -12
- package/_bundled_plugin/shared/workbench-history-repairs.json +19 -16
- package/_bundled_plugin/shared/workbench-migrations.json +53 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +1 -1
- package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +4 -68
- package/_bundled_plugin/skills/check-skills/SKILL.md +43 -0
- package/_bundled_plugin/skills/check-skills/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/cloud-findings/SKILL.md +6 -4
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +7 -50
- package/_bundled_plugin/skills/fix-finding/SKILL.md +19 -2
- package/_bundled_plugin/skills/publish-findings/SKILL.md +81 -45
- package/_bundled_plugin/skills/publish-findings/references/checkmarx-import.md +37 -0
- package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +5 -24
- package/_bundled_plugin/skills/publish-findings/scripts/collect_checkmarx.py +464 -0
- package/_bundled_plugin/skills/threat-model-visualize/scripts/build_explorer.py +36 -9
- package/_bundled_plugin/skills/track-findings/SKILL.md +5 -3
- package/_bundled_plugin/skills/triage-finding/references/github-rest-intake.md +22 -68
- package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +12 -6
- package/dist/api.d.ts +45 -5
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +1144 -411
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +10 -7
- package/dist/auth.js.map +1 -1
- package/dist/bedrock-oss-pricing.d.ts +6 -0
- package/dist/bedrock-oss-pricing.d.ts.map +1 -0
- package/dist/bedrock-oss-pricing.js +58 -0
- package/dist/bedrock-oss-pricing.js.map +1 -0
- package/dist/bedrock-pricing.d.ts +15 -0
- package/dist/bedrock-pricing.d.ts.map +1 -0
- package/dist/bedrock-pricing.js +117 -0
- package/dist/bedrock-pricing.js.map +1 -0
- package/dist/blackduck-findings.d.ts +8 -0
- package/dist/blackduck-findings.d.ts.map +1 -0
- package/dist/blackduck-findings.js +320 -0
- package/dist/blackduck-findings.js.map +1 -0
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +51 -36
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/checkmarx-evidence.d.ts +19 -0
- package/dist/checkmarx-evidence.d.ts.map +1 -0
- package/dist/checkmarx-evidence.js +36 -0
- package/dist/checkmarx-evidence.js.map +1 -0
- package/dist/checkmarx-findings.d.ts +4 -0
- package/dist/checkmarx-findings.d.ts.map +1 -0
- package/dist/checkmarx-findings.js +27 -0
- package/dist/checkmarx-findings.js.map +1 -0
- package/dist/checkmarx-one.d.ts +4 -0
- package/dist/checkmarx-one.d.ts.map +1 -0
- package/dist/checkmarx-one.js +53 -0
- package/dist/checkmarx-one.js.map +1 -0
- package/dist/checkmarx-repository.d.ts +12 -0
- package/dist/checkmarx-repository.d.ts.map +1 -0
- package/dist/checkmarx-repository.js +181 -0
- package/dist/checkmarx-repository.js.map +1 -0
- package/dist/checkmarx-xml.d.ts +12 -0
- package/dist/checkmarx-xml.d.ts.map +1 -0
- package/dist/checkmarx-xml.js +196 -0
- package/dist/checkmarx-xml.js.map +1 -0
- package/dist/classify-severity-records.d.ts +6 -9
- package/dist/classify-severity-records.d.ts.map +1 -1
- package/dist/classify-severity-records.js +9 -21
- package/dist/classify-severity-records.js.map +1 -1
- package/dist/classify-severity.d.ts +4 -1
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +30 -13
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli.d.ts +14 -5
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2112 -1266
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.js +2 -2
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codex-prompt.d.ts +2 -0
- package/dist/codex-prompt.d.ts.map +1 -1
- package/dist/codex-prompt.js +6 -0
- package/dist/codex-prompt.js.map +1 -1
- package/dist/component-scan.d.ts +16 -3
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +32 -6
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +221 -65
- package/dist/config.js.map +1 -1
- package/dist/continuum-findings.d.ts +7 -0
- package/dist/continuum-findings.d.ts.map +1 -0
- package/dist/continuum-findings.js +225 -0
- package/dist/continuum-findings.js.map +1 -0
- package/dist/contract-values.d.ts +30 -0
- package/dist/contract-values.d.ts.map +1 -0
- package/dist/contract-values.js +78 -0
- package/dist/contract-values.js.map +1 -0
- package/dist/contract.d.ts +2 -20
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +58 -669
- package/dist/contract.js.map +1 -1
- package/dist/cost-model.d.ts +13 -1
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +66 -115
- package/dist/cost-model.js.map +1 -1
- package/dist/cost.d.ts +61 -4
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +2560 -100
- package/dist/cost.js.map +1 -1
- package/dist/custom-publish.d.ts +4 -0
- package/dist/custom-publish.d.ts.map +1 -1
- package/dist/custom-publish.js +40 -3
- package/dist/custom-publish.js.map +1 -1
- package/dist/custom-validation-prompt.d.ts +1 -1
- package/dist/custom-validation-prompt.d.ts.map +1 -1
- package/dist/custom-validation-prompt.js +5 -0
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/custom-validation.d.ts +2 -0
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +4 -0
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts +4 -4
- package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
- package/dist/deduplication/deduplication-prompts.js +2 -2
- package/dist/deduplication/deduplication-prompts.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts +14 -11
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
- package/dist/deduplication/deduplication-reviewer.js +11 -4
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/deduplication.js.map +1 -1
- package/dist/deduplication/finding-schema.d.ts +19 -1
- package/dist/deduplication/finding-schema.d.ts.map +1 -1
- package/dist/deduplication/finding-schema.js +25 -0
- package/dist/deduplication/finding-schema.js.map +1 -1
- package/dist/deduplication/local.d.ts +2 -2
- package/dist/deduplication/local.d.ts.map +1 -1
- package/dist/deduplication/local.js +5 -10
- package/dist/deduplication/local.js.map +1 -1
- package/dist/deduplication/records.d.ts +8 -2
- package/dist/deduplication/records.d.ts.map +1 -1
- package/dist/deduplication/records.js +36 -8
- package/dist/deduplication/records.js.map +1 -1
- package/dist/deduplication/refusal.d.ts.map +1 -1
- package/dist/deduplication/refusal.js +25 -5
- package/dist/deduplication/refusal.js.map +1 -1
- package/dist/deduplication/scan.d.ts +3 -0
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +1 -1
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-config.d.ts +0 -1
- package/dist/deep-config.d.ts.map +1 -1
- package/dist/deep-config.js +22 -33
- package/dist/deep-config.js.map +1 -1
- package/dist/deep-scan-defaults.d.ts +2 -0
- package/dist/deep-scan-defaults.d.ts.map +1 -1
- package/dist/deep-scan-defaults.js +28 -1
- package/dist/deep-scan-defaults.js.map +1 -1
- package/dist/deep-scan.d.ts +13 -0
- package/dist/deep-scan.d.ts.map +1 -1
- package/dist/deep-scan.js +262 -7
- package/dist/deep-scan.js.map +1 -1
- package/dist/default-severity-rubric.d.ts +1 -2
- package/dist/default-severity-rubric.d.ts.map +1 -1
- package/dist/default-severity-rubric.js +2 -66
- package/dist/default-severity-rubric.js.map +1 -1
- package/dist/endor-findings.d.ts +3 -1
- package/dist/endor-findings.d.ts.map +1 -1
- package/dist/endor-findings.js +108 -80
- package/dist/endor-findings.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +9 -2
- package/dist/errors.js.map +1 -1
- package/dist/external-findings-import.d.ts +5 -3
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +11 -16
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts +15 -4
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +619 -225
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +20 -6
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +2356 -308
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +28 -2
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +174 -81
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-findings.d.ts +17 -3
- package/dist/external-findings.d.ts.map +1 -1
- package/dist/external-findings.js +153 -1
- package/dist/external-findings.js.map +1 -1
- package/dist/external-import-contract.d.ts +33 -1
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +335 -51
- package/dist/external-import-contract.js.map +1 -1
- package/dist/external-import-models.d.ts +1 -1
- package/dist/external-import-models.d.ts.map +1 -1
- package/dist/external-import-models.js.map +1 -1
- package/dist/feedback.d.ts.map +1 -1
- package/dist/feedback.js +5 -4
- package/dist/feedback.js.map +1 -1
- package/dist/finding-prompt.d.ts +5 -0
- package/dist/finding-prompt.d.ts.map +1 -0
- package/dist/finding-prompt.js +32 -0
- package/dist/finding-prompt.js.map +1 -0
- package/dist/finding-retrieval.d.ts +3 -3
- package/dist/finding-retrieval.d.ts.map +1 -1
- package/dist/finding-retrieval.js.map +1 -1
- package/dist/finding-workflow.d.ts +6 -1
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js +2 -2
- package/dist/finding-workflow.js.map +1 -1
- package/dist/findings-client.d.ts +1 -0
- package/dist/findings-client.d.ts.map +1 -1
- package/dist/findings-client.js +27 -3
- package/dist/findings-client.js.map +1 -1
- package/dist/git-remote.d.ts +4 -0
- package/dist/git-remote.d.ts.map +1 -1
- package/dist/git-remote.js +20 -0
- package/dist/git-remote.js.map +1 -1
- package/dist/github-advisories.d.ts +3 -12
- package/dist/github-advisories.d.ts.map +1 -1
- package/dist/github-advisories.js +9 -31
- package/dist/github-advisories.js.map +1 -1
- package/dist/github-dependabot-findings.d.ts.map +1 -1
- package/dist/github-dependabot-findings.js +22 -20
- package/dist/github-dependabot-findings.js.map +1 -1
- package/dist/github-findings.d.ts +4 -1
- package/dist/github-findings.d.ts.map +1 -1
- package/dist/github-findings.js +392 -79
- package/dist/github-findings.js.map +1 -1
- package/dist/github.d.ts +17 -7
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +43 -30
- package/dist/github.js.map +1 -1
- package/dist/host-protocol.d.ts +2 -2
- package/dist/host-protocol.d.ts.map +1 -1
- package/dist/host-protocol.js.map +1 -1
- package/dist/host-records-protocol.d.ts +10 -11
- package/dist/host-records-protocol.d.ts.map +1 -1
- package/dist/host-records-protocol.js +69 -9
- package/dist/host-records-protocol.js.map +1 -1
- package/dist/hosted-git-remotes.d.ts +5 -0
- package/dist/hosted-git-remotes.d.ts.map +1 -0
- package/dist/hosted-git-remotes.js +285 -0
- package/dist/hosted-git-remotes.js.map +1 -0
- package/dist/hosted-git-repository.d.ts +28 -0
- package/dist/hosted-git-repository.d.ts.map +1 -0
- package/dist/hosted-git-repository.js +222 -0
- package/dist/hosted-git-repository.js.map +1 -0
- package/dist/hosted-scan-protocol.js +2 -2
- package/dist/hosted-scan-protocol.js.map +1 -1
- package/dist/hosted-scan.d.ts +15 -0
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +71 -44
- package/dist/hosted-scan.js.map +1 -1
- package/dist/hosted-scanner-http.d.ts +21 -0
- package/dist/hosted-scanner-http.d.ts.map +1 -0
- package/dist/hosted-scanner-http.js +204 -0
- package/dist/hosted-scanner-http.js.map +1 -0
- package/dist/hosted-scanner-v1.d.ts +6 -0
- package/dist/hosted-scanner-v1.d.ts.map +1 -0
- package/dist/hosted-scanner-v1.js +60 -0
- package/dist/hosted-scanner-v1.js.map +1 -0
- package/dist/import-scan.d.ts.map +1 -1
- package/dist/import-scan.js +3 -0
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +24 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/inspector-findings.d.ts.map +1 -1
- package/dist/inspector-findings.js +58 -81
- package/dist/inspector-findings.js.map +1 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +86 -10
- package/dist/knowledge-base.js.map +1 -1
- package/dist/local-git-metadata.d.ts +5 -0
- package/dist/local-git-metadata.d.ts.map +1 -0
- package/dist/local-git-metadata.js +130 -0
- package/dist/local-git-metadata.js.map +1 -0
- package/dist/multiscan.d.ts +6 -4
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +160 -77
- package/dist/multiscan.js.map +1 -1
- package/dist/native-json-findings.d.ts +2 -1
- package/dist/native-json-findings.d.ts.map +1 -1
- package/dist/native-json-findings.js +12 -2
- package/dist/native-json-findings.js.map +1 -1
- package/dist/opengrep-findings.d.ts +1 -0
- package/dist/opengrep-findings.d.ts.map +1 -1
- package/dist/opengrep-findings.js +49 -31
- package/dist/opengrep-findings.js.map +1 -1
- package/dist/operation-telemetry.d.ts +104 -0
- package/dist/operation-telemetry.d.ts.map +1 -0
- package/dist/operation-telemetry.js +293 -0
- package/dist/operation-telemetry.js.map +1 -0
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +90 -35
- package/dist/patch-tui.js.map +1 -1
- package/dist/plugin-python-probe.d.ts +4 -0
- package/dist/plugin-python-probe.d.ts.map +1 -0
- package/dist/plugin-python-probe.js +10 -0
- package/dist/plugin-python-probe.js.map +1 -0
- package/dist/private-finding-import.d.ts +341 -0
- package/dist/private-finding-import.d.ts.map +1 -0
- package/dist/private-finding-import.js +411 -0
- package/dist/private-finding-import.js.map +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +2 -2
- package/dist/project-config.js.map +1 -1
- package/dist/provider-profile.d.ts +11 -3
- package/dist/provider-profile.d.ts.map +1 -1
- package/dist/provider-profile.js +80 -11
- package/dist/provider-profile.js.map +1 -1
- package/dist/publication-telemetry.d.ts +45 -0
- package/dist/publication-telemetry.d.ts.map +1 -0
- package/dist/publication-telemetry.js +50 -0
- package/dist/publication-telemetry.js.map +1 -0
- package/dist/publication.js +7 -1
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts +4 -0
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +42 -2
- package/dist/publish.js.map +1 -1
- package/dist/reader-selection.d.ts +15 -0
- package/dist/reader-selection.d.ts.map +1 -0
- package/dist/reader-selection.js +89 -0
- package/dist/reader-selection.js.map +1 -0
- package/dist/record.d.ts +6 -1
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +53 -2
- package/dist/record.js.map +1 -1
- package/dist/remediation.d.ts +3 -1
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +28 -2
- package/dist/remediation.js.map +1 -1
- package/dist/request-metadata.d.ts +3 -0
- package/dist/request-metadata.d.ts.map +1 -1
- package/dist/request-metadata.js +9 -0
- package/dist/request-metadata.js.map +1 -1
- package/dist/result.d.ts +6 -0
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +3 -1
- package/dist/result.js.map +1 -1
- package/dist/retry-windows-rename.d.ts +8 -0
- package/dist/retry-windows-rename.d.ts.map +1 -0
- package/dist/retry-windows-rename.js +24 -0
- package/dist/retry-windows-rename.js.map +1 -0
- package/dist/runtime.d.ts +22 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +408 -162
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan-bootstrap.d.ts +1 -0
- package/dist/saved-scan-bootstrap.d.ts.map +1 -1
- package/dist/saved-scan-bootstrap.js +18 -15
- package/dist/saved-scan-bootstrap.js.map +1 -1
- package/dist/scan-activity.d.ts.map +1 -1
- package/dist/scan-activity.js +172 -64
- package/dist/scan-activity.js.map +1 -1
- package/dist/scan-comparison.d.ts +10 -5
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +68 -25
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +7 -6
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +91 -79
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-executor.d.ts +12 -1
- package/dist/scan-executor.d.ts.map +1 -1
- package/dist/scan-executor.js +22 -2
- package/dist/scan-executor.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +31 -28
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts +12 -0
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +106 -77
- package/dist/scan-logs.js.map +1 -1
- package/dist/scan-measurement.d.ts +26 -0
- package/dist/scan-measurement.d.ts.map +1 -0
- package/dist/scan-measurement.js +77 -0
- package/dist/scan-measurement.js.map +1 -0
- package/dist/scan-progress.d.ts +1 -0
- package/dist/scan-progress.d.ts.map +1 -1
- package/dist/scan-progress.js +3 -0
- package/dist/scan-progress.js.map +1 -1
- package/dist/scan-sessions.d.ts.map +1 -1
- package/dist/scan-sessions.js +4 -1
- package/dist/scan-sessions.js.map +1 -1
- package/dist/scan-settings.d.ts +1 -1
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +1 -24
- package/dist/scan-settings.js.map +1 -1
- package/dist/scanner-import.d.ts +64 -6
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +406 -48
- package/dist/scanner-import.js.map +1 -1
- package/dist/scanner-repository-url.d.ts +17 -0
- package/dist/scanner-repository-url.d.ts.map +1 -0
- package/dist/scanner-repository-url.js +71 -0
- package/dist/scanner-repository-url.js.map +1 -0
- package/dist/security-policy.d.ts +1 -1
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js.map +1 -1
- package/dist/semgrep-findings.d.ts +6 -3
- package/dist/semgrep-findings.d.ts.map +1 -1
- package/dist/semgrep-findings.js +124 -88
- package/dist/semgrep-findings.js.map +1 -1
- package/dist/semgrep-guardian-findings.d.ts +38 -0
- package/dist/semgrep-guardian-findings.d.ts.map +1 -0
- package/dist/semgrep-guardian-findings.js +165 -0
- package/dist/semgrep-guardian-findings.js.map +1 -0
- package/dist/semgrep-platform-collector.d.ts +26 -0
- package/dist/semgrep-platform-collector.d.ts.map +1 -0
- package/dist/semgrep-platform-collector.js +108 -0
- package/dist/semgrep-platform-collector.js.map +1 -0
- package/dist/semgrep-platform-findings.d.ts +213 -0
- package/dist/semgrep-platform-findings.d.ts.map +1 -0
- package/dist/semgrep-platform-findings.js +1078 -0
- package/dist/semgrep-platform-findings.js.map +1 -0
- package/dist/semgrep-platform-v1.d.ts +6 -0
- package/dist/semgrep-platform-v1.d.ts.map +1 -0
- package/dist/semgrep-platform-v1.js +83 -0
- package/dist/semgrep-platform-v1.js.map +1 -0
- package/dist/server/api.d.ts +1 -1
- package/dist/server/api.d.ts.map +1 -1
- package/dist/server/api.js.map +1 -1
- package/dist/server/embedding-tokenizer.cdx.json +33 -0
- package/dist/server/embedding-tokenizer.d.ts +2 -0
- package/dist/server/embedding-tokenizer.d.ts.map +1 -0
- package/dist/server/embedding-tokenizer.js +322 -0
- package/dist/server/embedding-tokenizer.js.map +6 -0
- package/dist/server/embeddings.d.ts +16 -2
- package/dist/server/embeddings.d.ts.map +1 -1
- package/dist/server/embeddings.js +35 -5
- package/dist/server/embeddings.js.map +1 -1
- package/dist/session-lines.d.ts +5 -0
- package/dist/session-lines.d.ts.map +1 -0
- package/dist/session-lines.js +60 -0
- package/dist/session-lines.js.map +1 -0
- package/dist/severity-review.d.ts +3 -1
- package/dist/severity-review.d.ts.map +1 -1
- package/dist/severity-review.js +3 -2
- package/dist/severity-review.js.map +1 -1
- package/dist/severity-rubric.d.ts +20 -0
- package/dist/severity-rubric.d.ts.map +1 -0
- package/dist/severity-rubric.js +73 -0
- package/dist/severity-rubric.js.map +1 -0
- package/dist/severity-store.js +15 -5
- package/dist/severity-store.js.map +1 -1
- package/dist/skill-authentication.d.ts +1 -0
- package/dist/skill-authentication.d.ts.map +1 -1
- package/dist/skill-authentication.js +1 -0
- package/dist/skill-authentication.js.map +1 -1
- package/dist/snyk-findings.d.ts +7 -2
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +108 -84
- package/dist/snyk-findings.js.map +1 -1
- package/dist/snyk-rest-findings.d.ts +76 -0
- package/dist/snyk-rest-findings.d.ts.map +1 -0
- package/dist/snyk-rest-findings.js +1051 -0
- package/dist/snyk-rest-findings.js.map +1 -0
- package/dist/snyk-rest-v1.d.ts +28 -0
- package/dist/snyk-rest-v1.d.ts.map +1 -0
- package/dist/snyk-rest-v1.js +132 -0
- package/dist/snyk-rest-v1.js.map +1 -0
- package/dist/snyk-token-origin.d.ts +4 -0
- package/dist/snyk-token-origin.d.ts.map +1 -0
- package/dist/snyk-token-origin.js +82 -0
- package/dist/snyk-token-origin.js.map +1 -0
- package/dist/sonar-collector.d.ts +16 -0
- package/dist/sonar-collector.d.ts.map +1 -0
- package/dist/sonar-collector.js +380 -0
- package/dist/sonar-collector.js.map +1 -0
- package/dist/sonar-findings.d.ts +49 -0
- package/dist/sonar-findings.d.ts.map +1 -0
- package/dist/sonar-findings.js +288 -0
- package/dist/sonar-findings.js.map +1 -0
- package/dist/sonar-import.d.ts +111 -0
- package/dist/sonar-import.d.ts.map +1 -0
- package/dist/sonar-import.js +277 -0
- package/dist/sonar-import.js.map +1 -0
- package/dist/suggest-owners.d.ts.map +1 -1
- package/dist/suggest-owners.js +2 -1
- package/dist/suggest-owners.js.map +1 -1
- package/dist/target-drift.d.ts +9 -0
- package/dist/target-drift.d.ts.map +1 -0
- package/dist/target-drift.js +27 -0
- package/dist/target-drift.js.map +1 -0
- package/dist/targets.d.ts +5 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +73 -31
- package/dist/targets.js.map +1 -1
- package/dist/tenable-findings.d.ts +9 -0
- package/dist/tenable-findings.d.ts.map +1 -0
- package/dist/tenable-findings.js +122 -0
- package/dist/tenable-findings.js.map +1 -0
- package/dist/terminal-columns.d.ts +4 -0
- package/dist/terminal-columns.d.ts.map +1 -0
- package/dist/terminal-columns.js +19 -0
- package/dist/terminal-columns.js.map +1 -0
- package/dist/terminal-stream.d.ts +13 -0
- package/dist/terminal-stream.d.ts.map +1 -0
- package/dist/terminal-stream.js +35 -0
- package/dist/terminal-stream.js.map +1 -0
- package/dist/trivy-findings.d.ts +19 -0
- package/dist/trivy-findings.d.ts.map +1 -0
- package/dist/trivy-findings.js +435 -0
- package/dist/trivy-findings.js.map +1 -0
- package/dist/trivy-import.d.ts +19 -0
- package/dist/trivy-import.d.ts.map +1 -0
- package/dist/trivy-import.js +151 -0
- package/dist/trivy-import.js.map +1 -0
- package/dist/validation-records.d.ts +0 -3
- package/dist/validation-records.d.ts.map +1 -1
- package/dist/validation-records.js +1 -17
- package/dist/validation-records.js.map +1 -1
- package/dist/veracode-findings.d.ts +9 -0
- package/dist/veracode-findings.d.ts.map +1 -0
- package/dist/veracode-findings.js +409 -0
- package/dist/veracode-findings.js.map +1 -0
- package/dist/vertex-pricing.d.ts +8 -0
- package/dist/vertex-pricing.d.ts.map +1 -0
- package/dist/vertex-pricing.js +20 -0
- package/dist/vertex-pricing.js.map +1 -0
- package/dist/windows-path.d.ts +1 -0
- package/dist/windows-path.d.ts.map +1 -1
- package/dist/windows-path.js +27 -1
- package/dist/windows-path.js.map +1 -1
- package/dist/wiz-csv.d.ts +2 -2
- package/dist/wiz-csv.d.ts.map +1 -1
- package/dist/wiz-csv.js +1 -3
- package/dist/wiz-csv.js.map +1 -1
- package/dist/wiz-findings.d.ts +14 -2
- package/dist/wiz-findings.d.ts.map +1 -1
- package/dist/wiz-findings.js +143 -50
- package/dist/wiz-findings.js.map +1 -1
- package/docs/classify-severity-records.md +28 -13
- package/docs/cli.md +623 -843
- package/docs/dedupe-records.md +54 -24
- package/docs/findings-service.md +87 -47
- package/docs/hosted-remediation.md +14 -7
- package/docs/hosted-scans.md +64 -41
- package/docs/telemetry.md +236 -0
- package/docs/validate-records.md +78 -44
- package/package.json +19 -17
- package/schemas/external-findings.schema.json +14 -1
- package/schemas/hosted-scan-v2.fixture.json +16 -1
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
- package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +0 -96
- package/_bundled_plugin/scripts/validate_tracking_source.py +0 -82
- package/_bundled_plugin/scripts/workbench_local_dedupe.py +0 -136
- package/dist/deduplication/records-protocol.d.ts +0 -4
- package/dist/deduplication/records-protocol.d.ts.map +0 -1
- package/dist/deduplication/records-protocol.js +0 -49
- package/dist/deduplication/records-protocol.js.map +0 -1
- package/dist/external-imports-feature.d.ts +0 -6
- package/dist/external-imports-feature.d.ts.map +0 -1
- package/dist/external-imports-feature.js +0 -51
- package/dist/external-imports-feature.js.map +0 -1
- package/dist/finding-normalization.d.ts +0 -5
- package/dist/finding-normalization.d.ts.map +0 -1
- package/dist/finding-normalization.js +0 -120
- package/dist/finding-normalization.js.map +0 -1
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { isIPv4 } from "node:net";
|
|
2
|
+
import { cloudRepositoryUrlKey, repositoryUrlKey, } from "./external-import-contract.js";
|
|
3
|
+
import { isGitHubCloudHost } from "./git-remote.js";
|
|
4
|
+
// Git treats a colon followed by "//" as the start of a URL transport.
|
|
5
|
+
const scpRemote = /^(?:([^@/:\s?#]+)@)?(\[[^\]]+\]|[^@/:\s?#]+):(?!\/\/)(.+)$/u;
|
|
6
|
+
const sshRemote = /^(?:ssh|git\+ssh|ssh\+git):\/\/([^/]+?)(?:\/|%2[fF])/u;
|
|
7
|
+
/** A native file URL or an unambiguous local path. */
|
|
8
|
+
export function isLocalGitRemote(remote) {
|
|
9
|
+
if (remote.includes("://"))
|
|
10
|
+
return remote.startsWith("file://");
|
|
11
|
+
const colon = remote.indexOf(":");
|
|
12
|
+
return colon < 0 || remote.slice(0, colon).includes("/");
|
|
13
|
+
}
|
|
14
|
+
export function isWindowsGitDrive(remote) {
|
|
15
|
+
// Git for Windows accepts one character or up to four consecutive non-ASCII bytes before a drive colon.
|
|
16
|
+
return (process.platform === "win32" &&
|
|
17
|
+
!remote.includes("://") &&
|
|
18
|
+
/^(?:.|[\u0080-\u07ff]{2}):(?!:)/su.test(remote));
|
|
19
|
+
}
|
|
20
|
+
function parseScpRemote(remote) {
|
|
21
|
+
return !isLocalGitRemote(remote) &&
|
|
22
|
+
!remote.includes("://") &&
|
|
23
|
+
!/^[a-z\d][a-z\d+.-]*::/iu.test(remote)
|
|
24
|
+
? scpRemote.exec(remote)
|
|
25
|
+
: null;
|
|
26
|
+
}
|
|
27
|
+
function sshAuthority(host) {
|
|
28
|
+
if (/[\/\\?#@\s\x00-\x1f\x7f]/u.test(host))
|
|
29
|
+
return null;
|
|
30
|
+
// Git passes a leading plus on decimal ports through to OpenSSH.
|
|
31
|
+
const parse = (authority) => URL.parse("ssh://" + authority.replace(/:\+(\d+)$/u, ":$1"));
|
|
32
|
+
const parsed = parse(host);
|
|
33
|
+
if (parsed)
|
|
34
|
+
return parsed;
|
|
35
|
+
// Git accepts brackets around DNS names, with an SSH port inside or after the brackets.
|
|
36
|
+
const bracketed = /^\[([^\]]+)\](?::(\+?\d*))?$/u.exec(host);
|
|
37
|
+
// An empty port outside the brackets is ignored, but an inner trailing colon is a hostname byte.
|
|
38
|
+
if (!bracketed || bracketed[1].endsWith(":"))
|
|
39
|
+
return null;
|
|
40
|
+
const [, name, port] = bracketed;
|
|
41
|
+
return parse(name + (port ? `:${port}` : ""));
|
|
42
|
+
}
|
|
43
|
+
/** Git decodes URI escapes once except for NUL, and sends SCP bytes literally. */
|
|
44
|
+
export function gitTransportBytes(raw, scpStyle) {
|
|
45
|
+
const bytes = Buffer.from(raw).toString("latin1");
|
|
46
|
+
return scpStyle
|
|
47
|
+
? bytes
|
|
48
|
+
: bytes.replace(/%(?!00)([\da-f]{2})/giu, (_, hex) => String.fromCharCode(parseInt(hex, 16)));
|
|
49
|
+
}
|
|
50
|
+
/** Decode only URI escapes whose ASCII bytes cannot introduce a delimiter. */
|
|
51
|
+
export function decodeUnreserved(value) {
|
|
52
|
+
return value.replace(/%([0-9a-f]{2})/giu, (escape, hex) => {
|
|
53
|
+
const byte = String.fromCharCode(parseInt(hex, 16));
|
|
54
|
+
return /^[a-z0-9._~-]$/iu.test(byte) ? byte : escape.toUpperCase();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** Represent upload-pack path bytes relative to an HTTP repository origin. */
|
|
58
|
+
export function gitPathToHttpPath(bytes) {
|
|
59
|
+
return bytes
|
|
60
|
+
.replace(/^\//u, "")
|
|
61
|
+
.replace(/[%\x00-\x20\x7f-\xff]/gu, (byte) => "%" + byte.charCodeAt(0).toString(16).toUpperCase().padStart(2, "0"));
|
|
62
|
+
}
|
|
63
|
+
/** Ignore the optional DNS root dot for provider classification only. */
|
|
64
|
+
export function gitServiceHostname(hostname) {
|
|
65
|
+
return hostname.replace(/\.$/u, "");
|
|
66
|
+
}
|
|
67
|
+
export function isPublicGitHost(host) {
|
|
68
|
+
return (isGitHubCloudHost(host) || host === "gitlab.com" || host === "bitbucket.org");
|
|
69
|
+
}
|
|
70
|
+
/** Public SSH-over-443 hosts share the HTTPS hostname after the first DNS label. */
|
|
71
|
+
function publicGitSsh443Host(hostname) {
|
|
72
|
+
switch (gitServiceHostname(hostname)) {
|
|
73
|
+
case "ssh.github.com":
|
|
74
|
+
case "altssh.gitlab.com":
|
|
75
|
+
case "altssh.bitbucket.org":
|
|
76
|
+
return hostname.slice(hostname.indexOf(".") + 1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function matchesHttpsHost(url, hostname) {
|
|
80
|
+
const source = url && URL.parse(url);
|
|
81
|
+
return (!!source &&
|
|
82
|
+
source.protocol === "https:" &&
|
|
83
|
+
source.hostname.toLowerCase() === hostname);
|
|
84
|
+
}
|
|
85
|
+
/** Standard public SSH aliases, plus a hosted SCM established by the caller. */
|
|
86
|
+
export function normalizeHostedGitRepositoryUrl(remote, source, trustedScm) {
|
|
87
|
+
// A projected single-project report may retain only its SSH spelling.
|
|
88
|
+
return normalizeGitSshAlias(remote, (host) => (trustedScm || isPublicGitHost(gitServiceHostname(host))) &&
|
|
89
|
+
matchesHttpsHost(source ?? `https://${host}`, host));
|
|
90
|
+
}
|
|
91
|
+
function normalizeGitSshAlias(repository, isAliasHost) {
|
|
92
|
+
const isGitSshUser = (username, hostname) => (username === "git" && hostname === "github.com") ||
|
|
93
|
+
(isAliasHost(hostname) &&
|
|
94
|
+
(username === "git" ||
|
|
95
|
+
username ===
|
|
96
|
+
/^([^.]+)\.ghe\.com$/u.exec(gitServiceHostname(hostname))?.[1]));
|
|
97
|
+
const hostedAlias = (url, user, path, scpStyle) => {
|
|
98
|
+
const hostname = url.hostname.toLowerCase();
|
|
99
|
+
const standard = isGitSshUser(user, hostname) && (url.port === "" || url.port === "22");
|
|
100
|
+
const alternate = user === "git" && url.port === "443" && publicGitSsh443Host(hostname);
|
|
101
|
+
if (!standard && !alternate)
|
|
102
|
+
return repository;
|
|
103
|
+
const bytes = gitTransportBytes(path, scpStyle);
|
|
104
|
+
if (/[?#\\]/u.test(bytes) || /(?:^|\/)\.{1,2}(?:\/|$)/u.test(bytes))
|
|
105
|
+
return repository;
|
|
106
|
+
return `https://${alternate || hostname}/${gitPathToHttpPath(bytes)}`;
|
|
107
|
+
};
|
|
108
|
+
const scp = parseScpRemote(repository);
|
|
109
|
+
if (scp) {
|
|
110
|
+
if (!scp[1])
|
|
111
|
+
return repository;
|
|
112
|
+
const authority = sshAuthority(scp[2]);
|
|
113
|
+
return authority
|
|
114
|
+
? hostedAlias(authority, scp[1], scp[3], true)
|
|
115
|
+
: repository;
|
|
116
|
+
}
|
|
117
|
+
// Git separates the decoded authority from the path at the first slash.
|
|
118
|
+
const ssh = sshRemote.exec(repository);
|
|
119
|
+
if (ssh && !/[\t\r\n]/u.test(repository)) {
|
|
120
|
+
const authority = gitTransportBytes(ssh[1], false);
|
|
121
|
+
const login = /^([^@:]+)@([^@]+)$/u.exec(authority);
|
|
122
|
+
if (!login || /[/\\%?#\s]/u.test(authority))
|
|
123
|
+
return repository;
|
|
124
|
+
const url = sshAuthority(login[2]);
|
|
125
|
+
if (url)
|
|
126
|
+
return hostedAlias(url, login[1], "/" + repository.slice(ssh[0].length), false);
|
|
127
|
+
}
|
|
128
|
+
return repository;
|
|
129
|
+
}
|
|
130
|
+
function hostedHttpAuthority(authority) {
|
|
131
|
+
if (/[%@\\\s]/u.test(authority))
|
|
132
|
+
return authority;
|
|
133
|
+
const hostname = URL.parse(`https://${authority}/`)?.hostname;
|
|
134
|
+
// Hostname serialization handles IP literals and IDNA. The connector distinguishes explicit ports.
|
|
135
|
+
const port = /:\d*$/u.exec(authority)?.[0] ?? "";
|
|
136
|
+
return hostname ? hostname + port : authority;
|
|
137
|
+
}
|
|
138
|
+
function hostedHttpPath(path) {
|
|
139
|
+
const segments = [];
|
|
140
|
+
for (const segment of path.split("/")) {
|
|
141
|
+
// Git's HTTP transport resolves literal dot segments before sending the path.
|
|
142
|
+
if (segment === "..") {
|
|
143
|
+
segments.pop();
|
|
144
|
+
}
|
|
145
|
+
else if (segment !== ".") {
|
|
146
|
+
const spelling = segment.replace(/\P{ASCII}+/gu, (text) => encodeURIComponent(text.toWellFormed()));
|
|
147
|
+
const decoded = decodeUnreserved(spelling);
|
|
148
|
+
segments.push(decoded === "." || decoded === ".." ? segment.toUpperCase() : decoded);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (/(?:^|\/)\.{1,2}$/u.test(path))
|
|
152
|
+
segments.push("");
|
|
153
|
+
return segments.join("/");
|
|
154
|
+
}
|
|
155
|
+
/** Compare the HTTP request path a browser and Git would send for the same link. */
|
|
156
|
+
export function ambiguousHostedHttpPath(value) {
|
|
157
|
+
const path = /^https?:\/\/[^/?#]+\/([^?#]*)/iu.exec(value)?.[1];
|
|
158
|
+
if (path === undefined)
|
|
159
|
+
return false;
|
|
160
|
+
const web = URL.parse(value)?.pathname.slice(1);
|
|
161
|
+
return (web !== undefined &&
|
|
162
|
+
path !== web &&
|
|
163
|
+
hostedHttpPath(path) !== hostedHttpPath(web));
|
|
164
|
+
}
|
|
165
|
+
/** Compare hosted HTTP repository spellings without changing the retained evidence. */
|
|
166
|
+
export function hostedRepositoryUrlKey(value, github = false, knownGitSuffix = false, target = "local") {
|
|
167
|
+
const url = value.replace(/^(https?:\/\/)([^/?#]+)\/([^?#]*)/iu, (_, scheme, authority, path) => scheme +
|
|
168
|
+
(target === "cloud" && ambiguousGitIpHost(value)
|
|
169
|
+
? authority.toLowerCase()
|
|
170
|
+
: hostedHttpAuthority(authority)) +
|
|
171
|
+
"/" +
|
|
172
|
+
hostedHttpPath(path));
|
|
173
|
+
if (github)
|
|
174
|
+
return cloudRepositoryUrlKey(url);
|
|
175
|
+
const host = URL.parse(url)?.hostname ?? "";
|
|
176
|
+
const service = /^https?:\/\//iu.test(url) ? gitServiceHostname(host) : host;
|
|
177
|
+
if (service !== host && isGitHubCloudHost(service))
|
|
178
|
+
return cloudRepositoryUrlKey(url);
|
|
179
|
+
// An arbitrary Git server can serve different repositories at /repo and /repo.git.
|
|
180
|
+
const key = repositoryUrlKey(url);
|
|
181
|
+
return !knownGitSuffix && !isPublicGitHost(service) && /\.git\/?$/u.test(url)
|
|
182
|
+
? key + ".git"
|
|
183
|
+
: key;
|
|
184
|
+
}
|
|
185
|
+
/** The Git HTTP Host and TLS server name can differ from the web URL's parsed IP literal. */
|
|
186
|
+
export function ambiguousGitIpHost(url) {
|
|
187
|
+
const host = URL.parse(url)?.hostname;
|
|
188
|
+
if (!host || (!isIPv4(host) && !host.startsWith("[")))
|
|
189
|
+
return false;
|
|
190
|
+
const authority = /^https?:\/\/([^/?#]*)/iu.exec(url)?.[1] ?? "";
|
|
191
|
+
const rawHost = authority
|
|
192
|
+
.slice(authority.lastIndexOf("@") + 1)
|
|
193
|
+
.replace(/:\d*$/u, "");
|
|
194
|
+
return rawHost.toLowerCase() !== host;
|
|
195
|
+
}
|
|
196
|
+
/** Match a Git checkout to an independently selected hosted repository. */
|
|
197
|
+
export function hostedRepositoryMatches(source, remote) {
|
|
198
|
+
if (!/^https?:\/\//iu.test(source.url))
|
|
199
|
+
return remote === source.url;
|
|
200
|
+
const github = source.platform === "github";
|
|
201
|
+
const url = normalizeHostedGitRepositoryUrl(remote, source.url, github || source.platform === "gitlab");
|
|
202
|
+
const userinfo = /^https?:\/\/([^/?#]*)@/iu.exec(url)?.[1] ?? "";
|
|
203
|
+
// Git passes raw URL paths to its HTTP transport. Do not turn backslashes,
|
|
204
|
+
// controls or an encoded traversal into a match via web URL serialization.
|
|
205
|
+
if (!/^https?:\/\//iu.test(url) ||
|
|
206
|
+
/[\\\x00-\x20\x7f?#]/u.test(url) ||
|
|
207
|
+
// libcurl accepts encoded userinfo but rejects multiple literal authority delimiters.
|
|
208
|
+
userinfo.includes("@") ||
|
|
209
|
+
// Git rejects a decoded line feed in credentials and libcurl rejects a NUL in usernames.
|
|
210
|
+
/%0a/iu.test(userinfo) ||
|
|
211
|
+
/^[^:]*%00/u.test(userinfo) ||
|
|
212
|
+
ambiguousGitIpHost(url) ||
|
|
213
|
+
ambiguousHostedHttpPath(url))
|
|
214
|
+
return false;
|
|
215
|
+
// The local checkout's credentials and default HTTP port don't change the server path.
|
|
216
|
+
const key = (value) => hostedRepositoryUrlKey(value.replace(/^(https?:\/\/)([^/?#\\]+)\//iu, (match, scheme, authority) => {
|
|
217
|
+
const parsed = URL.parse(scheme + authority);
|
|
218
|
+
return parsed ? scheme + parsed.host + "/" : match;
|
|
219
|
+
}), github, source.gitlab || source.platform === "gitlab");
|
|
220
|
+
return key(url) === key(source.url);
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=hosted-git-repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-git-repository.js","sourceRoot":"","sources":["../src/hosted-git-repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAEL,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,uEAAuE;AACvE,MAAM,SAAS,GAAG,6D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AAC","sourcesContent":["import { isIPv4 } from \"node:net\";\nimport {\n type ExternalImportTarget,\n cloudRepositoryUrlKey,\n repositoryUrlKey,\n} from \"./external-import-contract.js\";\nimport { isGitHubCloudHost } from \"./git-remote.js\";\n\n// Git treats a colon followed by \"//\" as the start of a URL transport.\nconst scpRemote = /^(?:([^@/:\\s?#]+)@)?(\\[[^\\]]+\\]|[^@/:\\s?#]+):(?!\\/\\/)(.+)$/u;\n\nconst sshRemote = /^(?:ssh|git\\+ssh|ssh\\+git):\\/\\/([^/]+?)(?:\\/|%2[fF])/u;\n\n/** A native file URL or an unambiguous local path. */\nexport function isLocalGitRemote(remote: string): boolean {\n if (remote.includes(\"://\")) return remote.startsWith(\"file://\");\n const colon = remote.indexOf(\":\");\n return colon < 0 || remote.slice(0, colon).includes(\"/\");\n}\n\nexport function isWindowsGitDrive(remote: string): boolean {\n // Git for Windows accepts one character or up to four consecutive non-ASCII bytes before a drive colon.\n return (\n process.platform === \"win32\" &&\n !remote.includes(\"://\") &&\n /^(?:.|[\\u0080-\\u07ff]{2}):(?!:)/su.test(remote)\n );\n}\n\nfunction parseScpRemote(remote: string): RegExpExecArray | null {\n return !isLocalGitRemote(remote) &&\n !remote.includes(\"://\") &&\n !/^[a-z\\d][a-z\\d+.-]*::/iu.test(remote)\n ? scpRemote.exec(remote)\n : null;\n}\n\nfunction sshAuthority(host: string): URL | null {\n if (/[\\/\\\\?#@\\s\\x00-\\x1f\\x7f]/u.test(host)) return null;\n // Git passes a leading plus on decimal ports through to OpenSSH.\n const parse = (authority: string) =>\n URL.parse(\"ssh://\" + authority.replace(/:\\+(\\d+)$/u, \":$1\"));\n const parsed = parse(host);\n if (parsed) return parsed;\n // Git accepts brackets around DNS names, with an SSH port inside or after the brackets.\n const bracketed = /^\\[([^\\]]+)\\](?::(\\+?\\d*))?$/u.exec(host);\n // An empty port outside the brackets is ignored, but an inner trailing colon is a hostname byte.\n if (!bracketed || bracketed[1]!.endsWith(\":\")) return null;\n const [, name, port] = bracketed;\n return parse(name + (port ? `:${port}` : \"\"));\n}\n\n/** Git decodes URI escapes once except for NUL, and sends SCP bytes literally. */\nexport function gitTransportBytes(raw: string, scpStyle: boolean): string {\n const bytes = Buffer.from(raw).toString(\"latin1\");\n return scpStyle\n ? bytes\n : bytes.replace(/%(?!00)([\\da-f]{2})/giu, (_, hex: string) =>\n String.fromCharCode(parseInt(hex, 16)),\n );\n}\n\n/** Decode only URI escapes whose ASCII bytes cannot introduce a delimiter. */\nexport function decodeUnreserved(value: string): string {\n return value.replace(/%([0-9a-f]{2})/giu, (escape, hex: string) => {\n const byte = String.fromCharCode(parseInt(hex, 16));\n return /^[a-z0-9._~-]$/iu.test(byte) ? byte : escape.toUpperCase();\n });\n}\n\n/** Represent upload-pack path bytes relative to an HTTP repository origin. */\nexport function gitPathToHttpPath(bytes: string): string {\n return bytes\n .replace(/^\\//u, \"\")\n .replace(\n /[%\\x00-\\x20\\x7f-\\xff]/gu,\n (byte) =>\n \"%\" + byte.charCodeAt(0).toString(16).toUpperCase().padStart(2, \"0\"),\n );\n}\n\n/** Ignore the optional DNS root dot for provider classification only. */\nexport function gitServiceHostname(hostname: string): string {\n return hostname.replace(/\\.$/u, \"\");\n}\n\nexport function isPublicGitHost(host: string): boolean {\n return (\n isGitHubCloudHost(host) || host === \"gitlab.com\" || host === \"bitbucket.org\"\n );\n}\n\n/** Public SSH-over-443 hosts share the HTTPS hostname after the first DNS label. */\nfunction publicGitSsh443Host(hostname: string): string | undefined {\n switch (gitServiceHostname(hostname)) {\n case \"ssh.github.com\":\n case \"altssh.gitlab.com\":\n case \"altssh.bitbucket.org\":\n return hostname.slice(hostname.indexOf(\".\") + 1);\n }\n}\n\nfunction matchesHttpsHost(url: string | undefined, hostname: string): boolean {\n const source = url && URL.parse(url);\n return (\n !!source &&\n source.protocol === \"https:\" &&\n source.hostname.toLowerCase() === hostname\n );\n}\n\n/** Standard public SSH aliases, plus a hosted SCM established by the caller. */\nexport function normalizeHostedGitRepositoryUrl(\n remote: string,\n source: string | undefined,\n trustedScm: boolean,\n): string {\n // A projected single-project report may retain only its SSH spelling.\n return normalizeGitSshAlias(\n remote,\n (host) =>\n (trustedScm || isPublicGitHost(gitServiceHostname(host))) &&\n matchesHttpsHost(source ?? `https://${host}`, host),\n );\n}\n\nfunction normalizeGitSshAlias(\n repository: string,\n isAliasHost: (host: string) => boolean,\n): string {\n const isGitSshUser = (username: string, hostname: string) =>\n (username === \"git\" && hostname === \"github.com\") ||\n (isAliasHost(hostname) &&\n (username === \"git\" ||\n username ===\n /^([^.]+)\\.ghe\\.com$/u.exec(gitServiceHostname(hostname))?.[1]));\n const hostedAlias = (\n url: URL,\n user: string,\n path: string,\n scpStyle: boolean,\n ) => {\n const hostname = url.hostname.toLowerCase();\n const standard =\n isGitSshUser(user, hostname) && (url.port === \"\" || url.port === \"22\");\n const alternate =\n user === \"git\" && url.port === \"443\" && publicGitSsh443Host(hostname);\n if (!standard && !alternate) return repository;\n const bytes = gitTransportBytes(path, scpStyle);\n if (/[?#\\\\]/u.test(bytes) || /(?:^|\\/)\\.{1,2}(?:\\/|$)/u.test(bytes))\n return repository;\n return `https://${alternate || hostname}/${gitPathToHttpPath(bytes)}`;\n };\n const scp = parseScpRemote(repository);\n if (scp) {\n if (!scp[1]) return repository;\n const authority = sshAuthority(scp[2]!);\n return authority\n ? hostedAlias(authority, scp[1], scp[3]!, true)\n : repository;\n }\n // Git separates the decoded authority from the path at the first slash.\n const ssh = sshRemote.exec(repository);\n if (ssh && !/[\\t\\r\\n]/u.test(repository)) {\n const authority = gitTransportBytes(ssh[1]!, false);\n const login = /^([^@:]+)@([^@]+)$/u.exec(authority);\n if (!login || /[/\\\\%?#\\s]/u.test(authority)) return repository;\n const url = sshAuthority(login[2]!);\n if (url)\n return hostedAlias(\n url,\n login[1]!,\n \"/\" + repository.slice(ssh[0].length),\n false,\n );\n }\n return repository;\n}\n\nfunction hostedHttpAuthority(authority: string): string {\n if (/[%@\\\\\\s]/u.test(authority)) return authority;\n const hostname = URL.parse(`https://${authority}/`)?.hostname;\n // Hostname serialization handles IP literals and IDNA. The connector distinguishes explicit ports.\n const port = /:\\d*$/u.exec(authority)?.[0] ?? \"\";\n return hostname ? hostname + port : authority;\n}\n\nfunction hostedHttpPath(path: string): string {\n const segments: string[] = [];\n for (const segment of path.split(\"/\")) {\n // Git's HTTP transport resolves literal dot segments before sending the path.\n if (segment === \"..\") {\n segments.pop();\n } else if (segment !== \".\") {\n const spelling = segment.replace(/\\P{ASCII}+/gu, (text) =>\n encodeURIComponent(text.toWellFormed()),\n );\n const decoded = decodeUnreserved(spelling);\n segments.push(\n decoded === \".\" || decoded === \"..\" ? segment.toUpperCase() : decoded,\n );\n }\n }\n if (/(?:^|\\/)\\.{1,2}$/u.test(path)) segments.push(\"\");\n return segments.join(\"/\");\n}\n\n/** Compare the HTTP request path a browser and Git would send for the same link. */\nexport function ambiguousHostedHttpPath(value: string): boolean {\n const path = /^https?:\\/\\/[^/?#]+\\/([^?#]*)/iu.exec(value)?.[1];\n if (path === undefined) return false;\n const web = URL.parse(value)?.pathname.slice(1);\n return (\n web !== undefined &&\n path !== web &&\n hostedHttpPath(path) !== hostedHttpPath(web)\n );\n}\n\n/** Compare hosted HTTP repository spellings without changing the retained evidence. */\nexport function hostedRepositoryUrlKey(\n value: string,\n github = false,\n knownGitSuffix = false,\n target: ExternalImportTarget = \"local\",\n): string {\n const url = value.replace(\n /^(https?:\\/\\/)([^/?#]+)\\/([^?#]*)/iu,\n (_, scheme: string, authority: string, path: string) =>\n scheme +\n (target === \"cloud\" && ambiguousGitIpHost(value)\n ? authority.toLowerCase()\n : hostedHttpAuthority(authority)) +\n \"/\" +\n hostedHttpPath(path),\n );\n if (github) return cloudRepositoryUrlKey(url);\n const host = URL.parse(url)?.hostname ?? \"\";\n const service = /^https?:\\/\\//iu.test(url) ? gitServiceHostname(host) : host;\n if (service !== host && isGitHubCloudHost(service))\n return cloudRepositoryUrlKey(url);\n // An arbitrary Git server can serve different repositories at /repo and /repo.git.\n const key = repositoryUrlKey(url);\n return !knownGitSuffix && !isPublicGitHost(service) && /\\.git\\/?$/u.test(url)\n ? key + \".git\"\n : key;\n}\n\n/** The Git HTTP Host and TLS server name can differ from the web URL's parsed IP literal. */\nexport function ambiguousGitIpHost(url: string): boolean {\n const host = URL.parse(url)?.hostname;\n if (!host || (!isIPv4(host) && !host.startsWith(\"[\"))) return false;\n const authority = /^https?:\\/\\/([^/?#]*)/iu.exec(url)?.[1] ?? \"\";\n const rawHost = authority\n .slice(authority.lastIndexOf(\"@\") + 1)\n .replace(/:\\d*$/u, \"\");\n return rawHost.toLowerCase() !== host;\n}\n\n/** Match a Git checkout to an independently selected hosted repository. */\nexport function hostedRepositoryMatches(\n source: { url: string; platform?: string; gitlab?: boolean },\n remote: string,\n): boolean {\n if (!/^https?:\\/\\//iu.test(source.url)) return remote === source.url;\n const github = source.platform === \"github\";\n const url = normalizeHostedGitRepositoryUrl(\n remote,\n source.url,\n github || source.platform === \"gitlab\",\n );\n const userinfo = /^https?:\\/\\/([^/?#]*)@/iu.exec(url)?.[1] ?? \"\";\n // Git passes raw URL paths to its HTTP transport. Do not turn backslashes,\n // controls or an encoded traversal into a match via web URL serialization.\n if (\n !/^https?:\\/\\//iu.test(url) ||\n /[\\\\\\x00-\\x20\\x7f?#]/u.test(url) ||\n // libcurl accepts encoded userinfo but rejects multiple literal authority delimiters.\n userinfo.includes(\"@\") ||\n // Git rejects a decoded line feed in credentials and libcurl rejects a NUL in usernames.\n /%0a/iu.test(userinfo) ||\n /^[^:]*%00/u.test(userinfo) ||\n ambiguousGitIpHost(url) ||\n ambiguousHostedHttpPath(url)\n )\n return false;\n // The local checkout's credentials and default HTTP port don't change the server path.\n const key = (value: string) =>\n hostedRepositoryUrlKey(\n value.replace(\n /^(https?:\\/\\/)([^/?#\\\\]+)\\//iu,\n (match, scheme: string, authority: string) => {\n const parsed = URL.parse(scheme + authority);\n return parsed ? scheme + parsed.host + \"/\" : match;\n },\n ),\n github,\n source.gitlab || source.platform === \"gitlab\",\n );\n return key(url) === key(source.url);\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { runHostProtocol } from "./host-protocol.js";
|
|
2
|
-
import { HostedScanPreparationError,
|
|
2
|
+
import { HostedScanPreparationError, runHostedScanInternal, } from "./hosted-scan.js";
|
|
3
3
|
import { ScanExecutionEventSchema, ScanExecutionResultSchema, } from "./scan-executor.js";
|
|
4
4
|
export async function runHostedScanProtocol(input, output, signal) {
|
|
5
5
|
return await runHostProtocol(input, output, {
|
|
@@ -9,7 +9,7 @@ export async function runHostedScanProtocol(input, output, signal) {
|
|
|
9
9
|
errorData: (error) => error instanceof HostedScanPreparationError
|
|
10
10
|
? { reason: error.reason }
|
|
11
11
|
: undefined,
|
|
12
|
-
run: async (params, execute, signal, onEvent) => await
|
|
12
|
+
run: async (params, execute, signal, onEvent) => await runHostedScanInternal("cli", params, {
|
|
13
13
|
signal,
|
|
14
14
|
onEvent,
|
|
15
15
|
executor: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-scan-protocol.js","sourceRoot":"","sources":["../src/hosted-scan-protocol.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAEL,0BAA0B,EAC1B,
|
|
1
|
+
{"version":3,"file":"hosted-scan-protocol.js","sourceRoot":"","sources":["../src/hosted-scan-protocol.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAEL,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAE5B,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,KAAe,EACf,MAA6C,EAC7C,MAAoB;IAEpB,OAAO,MAAM,eAAe,CAC1B,KAAK,EACL,MAAM,EACN;QACE,KAAK,EAAE,MAAM;QACb,aAAa,EAAE,eAAe;QAC9B,wBAAwB,EAAE,IAAI;QAC9B,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CACnB,KAAK,YAAY,0BAA0B;YACzC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;YAC1B,CAAC,CAAC,SAAS;QACf,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAC9C,MAAM,qBAAqB,CAAC,KAAK,EAAE,MAAyB,EAAE;YAC5D,MAAM;YACN,OAAO;YACP,QAAQ,EAAE;gBACR,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAC9B,yBAAyB,CAAC,KAAK,CAC7B,MAAM,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;oBAClD,MAAM,MAAM,GAAG,wBAAwB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;oBACzD,IAAI,MAAM,CAAC,OAAO;wBAAE,OAAO,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACrD,CAAC,CAAC,CACH;aACJ;SACF,CAAC;KACL,EACD,MAAM,CACP,CAAC;AACJ,CAAC","sourcesContent":["import type { Readable } from \"node:stream\";\nimport { runHostProtocol } from \"./host-protocol.js\";\nimport {\n type HostedScanInput,\n HostedScanPreparationError,\n runHostedScanInternal,\n} from \"./hosted-scan.js\";\nimport {\n ScanExecutionEventSchema,\n ScanExecutionResultSchema,\n} from \"./scan-executor.js\";\n\nexport async function runHostedScanProtocol(\n input: Readable,\n output: Parameters<typeof runHostProtocol>[1],\n signal?: AbortSignal,\n): Promise<number> {\n return await runHostProtocol(\n input,\n output,\n {\n label: \"Scan\",\n requestMethod: \"execution.run\",\n awaitCancellationReceipt: true,\n errorData: (error) =>\n error instanceof HostedScanPreparationError\n ? { reason: error.reason }\n : undefined,\n run: async (params, execute, signal, onEvent) =>\n await runHostedScanInternal(\"cli\", params as HostedScanInput, {\n signal,\n onEvent,\n executor: {\n run: async (request, options) =>\n ScanExecutionResultSchema.parse(\n await execute(request.requestId, request, (event) => {\n const parsed = ScanExecutionEventSchema.safeParse(event);\n if (parsed.success) options.onEvent?.(parsed.data);\n }),\n ),\n },\n }),\n },\n signal,\n );\n}\n"]}
|
package/dist/hosted-scan.d.ts
CHANGED
|
@@ -13,6 +13,11 @@ export declare const HostedScanInputSchema: z.ZodObject<{
|
|
|
13
13
|
stateDirectory: z.ZodString;
|
|
14
14
|
model: z.ZodString;
|
|
15
15
|
reasoningEffort: z.ZodString;
|
|
16
|
+
severityRubric: z.ZodOptional<z.ZodObject<{
|
|
17
|
+
revision: z.ZodNumber;
|
|
18
|
+
markdown: z.ZodString;
|
|
19
|
+
sha256: z.ZodString;
|
|
20
|
+
}, z.core.$strict>>;
|
|
16
21
|
ownerSuggestions: z.ZodOptional<z.ZodBoolean>;
|
|
17
22
|
identity: z.ZodObject<{
|
|
18
23
|
runId: z.ZodString;
|
|
@@ -58,6 +63,11 @@ export declare function runHostedScan(value: HostedScanInput, options: HostedSca
|
|
|
58
63
|
attemptId: string;
|
|
59
64
|
buildId: string;
|
|
60
65
|
};
|
|
66
|
+
severityRubric?: {
|
|
67
|
+
revision: number;
|
|
68
|
+
markdown: string;
|
|
69
|
+
sha256: string;
|
|
70
|
+
} | undefined;
|
|
61
71
|
version: 2;
|
|
62
72
|
outputDirectory: string;
|
|
63
73
|
scanId?: string | undefined;
|
|
@@ -98,6 +108,11 @@ export declare function runHostedScan(value: HostedScanInput, options: HostedSca
|
|
|
98
108
|
attemptId: string;
|
|
99
109
|
buildId: string;
|
|
100
110
|
};
|
|
111
|
+
severityRubric?: {
|
|
112
|
+
revision: number;
|
|
113
|
+
markdown: string;
|
|
114
|
+
sha256: string;
|
|
115
|
+
} | undefined;
|
|
101
116
|
version: 2;
|
|
102
117
|
outputDirectory: string;
|
|
103
118
|
scanId?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-scan.d.ts","sourceRoot":"","sources":["../src/hosted-scan.ts"],"names":[],"mappings":"AASA,OAAO,
|
|
1
|
+
{"version":3,"file":"hosted-scan.d.ts","sourceRoot":"","sources":["../src/hosted-scan.ts"],"names":[],"mappings":"AASA,OAAO,EAGL,KAAK,YAAY,EAEjB,KAAK,kBAAkB,EAExB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG7E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,qFAAqF;AACrF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;kBAuBhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,qBAAa,0BAA2B,SAAQ,KAAK;IAEjD,QAAQ,CAAC,MAAM,EACX,cAAc,GACd,eAAe,GACf,0BAA0B,GAC1B,aAAa,GACb,mBAAmB;IANzB,YACW,MAAM,EACX,cAAc,GACd,eAAe,GACf,0BAA0B,GAC1B,aAAa,GACb,mBAAmB,EACvB,OAAO,EAAE,MAAM,EAIhB;CACF;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAyBzD;AAMD,wBAAgB,oBAAoB,CAClC,KAAK,GAAE,SAAS,MAAM,EAAU,GAC/B,MAAM,EAAE,CAeV;AAiED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,YAAY,CAAC;IACvB,4FAA4F;IAC5F,UAAU,CAAC,EAAE;QACX,WAAW,CAAC,OAAO,EAAE;YAAE,KAAK,CAAC,EAAE,MAAM,CAAC;YAAC,oBAAoB,CAAC,EAAE,MAAM,CAAA;SAAE,GAAG;YACvE,GAAG,CACD,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;gBAAE,YAAY,CAAC,EAAE,OAAO,CAAC;gBAAC,MAAM,CAAC,EAAE,WAAW,CAAA;aAAE,GACxD,OAAO,CAAC;gBAAE,aAAa,EAAE,MAAM,CAAA;aAAE,CAAC,CAAC;SACvC,CAAC;KACH,CAAC;IACF,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CAC/C;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,CAC3B,KAAK,EAAE,eAAe,EACtB,OAAO,EAAE,iBAAiB;;;;QAef,KAAK;;;;;;;;;;;;aAYL,CAAC;;;;;;;;;;;;;;;;;;;;;;YA6IA,WAAW;;;;;;;;;;;QAzJZ,KAAK;;;;;;;;;;;;aAYL,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;GAxBb;AAwMD,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC"}
|
package/dist/hosted-scan.js
CHANGED
|
@@ -3,13 +3,14 @@ import { isDeepStrictEqual } from "node:util";
|
|
|
3
3
|
import { readScanFile, safeScopePath, validatedFileDigests, } from "./contract.js";
|
|
4
4
|
import { isRecord } from "./record.js";
|
|
5
5
|
import { VERSION } from "./version.js";
|
|
6
|
-
import { ScanExecutionError, } from "./scan-executor.js";
|
|
6
|
+
import { hostedScanFailureStatus, ScanExecutionError, } from "./scan-executor.js";
|
|
7
7
|
import { realpath } from "node:fs/promises";
|
|
8
8
|
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
9
9
|
import { z } from "zod";
|
|
10
10
|
import { CodexSecurity } from "./api.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { severityRubricSnapshotSchema } from "./classify-severity-records.js";
|
|
12
|
+
import { errorMessage } from "./errors.js";
|
|
13
|
+
import { abortable, normalizeRepository, repositoryRevision, } from "./targets.js";
|
|
13
14
|
import { isWithin } from "./trusted-executable.js";
|
|
14
15
|
/** Hosted v2 mirrors repository/paths targets; only Standard scans are supported. */
|
|
15
16
|
export const HostedScanInputSchema = z.strictObject({
|
|
@@ -23,6 +24,9 @@ export const HostedScanInputSchema = z.strictObject({
|
|
|
23
24
|
stateDirectory: z.string().min(1),
|
|
24
25
|
model: z.string().min(1),
|
|
25
26
|
reasoningEffort: z.string(),
|
|
27
|
+
severityRubric: severityRubricSnapshotSchema
|
|
28
|
+
.refine(({ markdown, sha256 }) => hash("sha256", markdown) === sha256, "Rubric SHA-256 does not match its exact UTF-8 Markdown.")
|
|
29
|
+
.optional(),
|
|
26
30
|
ownerSuggestions: z.boolean().optional(),
|
|
27
31
|
identity: z.strictObject({
|
|
28
32
|
runId: z.string().min(1),
|
|
@@ -69,19 +73,19 @@ export function normalizeHostedPaths(paths = ["."]) {
|
|
|
69
73
|
return normalized;
|
|
70
74
|
}
|
|
71
75
|
/** Validate every path at the frozen commit before registering a scan/executing. */
|
|
72
|
-
async function
|
|
73
|
-
const scope = { paths: normalizeHostedPaths(input.scope?.paths) };
|
|
76
|
+
async function prepareHostedRepository(input, signal) {
|
|
74
77
|
const repository = await normalizeRepository(input.repository, signal);
|
|
75
78
|
if ((await repositoryRevision(repository, signal)) !== input.revision)
|
|
76
79
|
throw new HostedScanPreparationError("revision_mismatch", "Checkout does not match the frozen revision.");
|
|
77
|
-
for (const path of scope.paths) {
|
|
80
|
+
for (const path of input.scope.paths) {
|
|
78
81
|
const selected = resolve(repository, path);
|
|
79
82
|
let target;
|
|
80
83
|
try {
|
|
81
|
-
target = await realpath(selected);
|
|
84
|
+
target = await abortable(() => realpath(selected), signal);
|
|
82
85
|
}
|
|
83
86
|
catch (error) {
|
|
84
|
-
if (
|
|
87
|
+
if ((signal?.aborted && error === signal.reason) ||
|
|
88
|
+
!(error instanceof Error) ||
|
|
85
89
|
!("code" in error) ||
|
|
86
90
|
error.code !== "ENOENT")
|
|
87
91
|
throw error;
|
|
@@ -94,12 +98,7 @@ async function prepareHostedScan(input, signal) {
|
|
|
94
98
|
throw new HostedScanPreparationError("scope_alias", `${path} resolves to ${canonical}. Use the canonical repository path and start a new scan.`);
|
|
95
99
|
}
|
|
96
100
|
}
|
|
97
|
-
return
|
|
98
|
-
repository,
|
|
99
|
-
revision: input.revision,
|
|
100
|
-
scope,
|
|
101
|
-
identity: input.identity,
|
|
102
|
-
};
|
|
101
|
+
return repository;
|
|
103
102
|
}
|
|
104
103
|
function hostedScanEnvironment(stateDirectory) {
|
|
105
104
|
const environment = {
|
|
@@ -119,12 +118,60 @@ function hostedScanEnvironment(stateDirectory) {
|
|
|
119
118
|
return environment;
|
|
120
119
|
}
|
|
121
120
|
/** One invocation, with only scan-domain state. The host decides retry/reconciliation. */
|
|
122
|
-
export
|
|
121
|
+
export function runHostedScan(value, options) {
|
|
122
|
+
return runHostedScanInternal("sdk", value, options);
|
|
123
|
+
}
|
|
124
|
+
/** @internal */
|
|
125
|
+
export async function runHostedScanInternal(surface, value, options) {
|
|
123
126
|
const input = HostedScanInputSchema.parse(value);
|
|
124
|
-
const context =
|
|
127
|
+
const context = {
|
|
128
|
+
repository: input.repository,
|
|
129
|
+
revision: input.revision,
|
|
130
|
+
scope: { paths: normalizeHostedPaths(input.scope?.paths) },
|
|
131
|
+
identity: input.identity,
|
|
132
|
+
...(input.severityRubric === undefined
|
|
133
|
+
? {}
|
|
134
|
+
: { severityRubric: input.severityRubric }),
|
|
135
|
+
};
|
|
125
136
|
let execution;
|
|
126
137
|
let request;
|
|
127
138
|
let scanId;
|
|
139
|
+
let stoppedStatus;
|
|
140
|
+
let outputDirectory = resolve(input.outputDirectory);
|
|
141
|
+
const base = () => ({
|
|
142
|
+
version: 2,
|
|
143
|
+
...context,
|
|
144
|
+
outputDirectory,
|
|
145
|
+
...(scanId === undefined ? {} : { scanId }),
|
|
146
|
+
...(request === undefined
|
|
147
|
+
? {}
|
|
148
|
+
: {
|
|
149
|
+
pluginVersion: request.runtime.pluginVersion,
|
|
150
|
+
}),
|
|
151
|
+
provenance: {
|
|
152
|
+
cliVersion: VERSION,
|
|
153
|
+
buildId: input.identity.buildId,
|
|
154
|
+
...(request === undefined
|
|
155
|
+
? {}
|
|
156
|
+
: { pluginVersion: request.runtime.pluginVersion }),
|
|
157
|
+
},
|
|
158
|
+
...(execution === undefined ? {} : { execution }),
|
|
159
|
+
});
|
|
160
|
+
try {
|
|
161
|
+
context.repository = await prepareHostedRepository(context, options.signal);
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
if (options.signal?.aborted &&
|
|
165
|
+
(Object.is(error, options.signal.reason) ||
|
|
166
|
+
(error instanceof DOMException && error.name === "AbortError")))
|
|
167
|
+
return {
|
|
168
|
+
...base(),
|
|
169
|
+
status: "canceled",
|
|
170
|
+
error: `Canceled before checkout verification finished: ${errorMessage(error)}`,
|
|
171
|
+
artifacts: [],
|
|
172
|
+
};
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
128
175
|
const onEvent = (event) => {
|
|
129
176
|
void Promise.resolve()
|
|
130
177
|
.then(() => options.onEvent?.(event))
|
|
@@ -151,27 +198,7 @@ export async function runHostedScan(value, options) {
|
|
|
151
198
|
createCodex() {
|
|
152
199
|
throw new Error("Local inference is unavailable in hosted mode.");
|
|
153
200
|
},
|
|
154
|
-
}, { surface
|
|
155
|
-
let outputDirectory = resolve(input.outputDirectory);
|
|
156
|
-
const base = () => ({
|
|
157
|
-
version: 2,
|
|
158
|
-
...context,
|
|
159
|
-
outputDirectory,
|
|
160
|
-
...(scanId === undefined ? {} : { scanId }),
|
|
161
|
-
...(request === undefined
|
|
162
|
-
? {}
|
|
163
|
-
: {
|
|
164
|
-
pluginVersion: request.runtime.pluginVersion,
|
|
165
|
-
}),
|
|
166
|
-
provenance: {
|
|
167
|
-
cliVersion: VERSION,
|
|
168
|
-
buildId: input.identity.buildId,
|
|
169
|
-
...(request === undefined
|
|
170
|
-
? {}
|
|
171
|
-
: { pluginVersion: request.runtime.pluginVersion }),
|
|
172
|
-
},
|
|
173
|
-
...(execution === undefined ? {} : { execution }),
|
|
174
|
-
});
|
|
201
|
+
}, { surface });
|
|
175
202
|
try {
|
|
176
203
|
const result = await client.run(context.repository, {
|
|
177
204
|
target: context.scope.paths[0] === "."
|
|
@@ -188,6 +215,10 @@ export async function runHostedScan(value, options) {
|
|
|
188
215
|
scanId = scan.scanId;
|
|
189
216
|
outputDirectory = scan.scanDir;
|
|
190
217
|
},
|
|
218
|
+
onLifecycle(scan) {
|
|
219
|
+
if (scan.status === "canceled" || scan.status === "failed")
|
|
220
|
+
stoppedStatus = scan.status;
|
|
221
|
+
},
|
|
191
222
|
onProgress(progress) {
|
|
192
223
|
onEvent({ type: "progress", progress });
|
|
193
224
|
},
|
|
@@ -240,15 +271,11 @@ export async function runHostedScan(value, options) {
|
|
|
240
271
|
catch (error) {
|
|
241
272
|
if (error instanceof ScanExecutionError)
|
|
242
273
|
execution = error.result;
|
|
274
|
+
const status = hostedScanFailureStatus(error, options.signal, execution);
|
|
243
275
|
return {
|
|
244
276
|
...base(),
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
: options.signal?.aborted ||
|
|
248
|
-
execution?.status === "canceled" ||
|
|
249
|
-
error instanceof ScanInterruptedError
|
|
250
|
-
? "canceled"
|
|
251
|
-
: "failed",
|
|
277
|
+
// A late abort during cleanup cannot change an already committed failure.
|
|
278
|
+
status: status === "acceptance_unknown" ? status : (stoppedStatus ?? status),
|
|
252
279
|
error: errorMessage(error),
|
|
253
280
|
artifacts: [],
|
|
254
281
|
};
|