@openai/codex-security 0.8.3 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +192 -151
- package/_bundled_plugin/.mcp.json +5 -1
- package/_bundled_plugin/examples/completed-scan/findings.json +16 -4
- package/_bundled_plugin/examples/completed-scan/report.md +11 -8
- package/_bundled_plugin/examples/completed-scan/scan-manifest.json +4 -2
- package/_bundled_plugin/mcp/fzstd-LICENSE.txt +21 -0
- package/_bundled_plugin/mcp/helpers.mjs +2 -11
- package/_bundled_plugin/mcp/helpers.mjs.br +0 -0
- package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +3 -210
- package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
- package/_bundled_plugin/mcp/package.json +1 -0
- package/_bundled_plugin/mcp/permission-profile-preflight.mjs +5 -2
- package/_bundled_plugin/mcp/server.mjs +2 -11
- package/_bundled_plugin/mcp/server.mjs.br +0 -0
- package/_bundled_plugin/mcp/session-decompression.mjs +712 -0
- package/_bundled_plugin/references/default-severity-rubric.md +9 -4
- package/_bundled_plugin/references/final-report.md +5 -3
- package/_bundled_plugin/references/finding-detail-fields.md +18 -18
- package/_bundled_plugin/references/sarif-adapter.md +8 -2
- package/_bundled_plugin/references/scan-artifacts.md +21 -12
- package/_bundled_plugin/references/scan-contract.md +27 -33
- package/_bundled_plugin/schemas/tools/scan-draft.schema.json +2 -2
- package/_bundled_plugin/scripts/check_deep_scan_target.py +97 -0
- package/_bundled_plugin/scripts/codex_profile.mjs +7 -1
- package/_bundled_plugin/scripts/deep_scan_config.py +20 -1
- package/_bundled_plugin/scripts/deep_scan_workbench.py +165 -342
- package/_bundled_plugin/scripts/filesystem_identity.py +1 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +153 -227
- package/_bundled_plugin/scripts/finding_preview.py +20 -0
- package/_bundled_plugin/scripts/launch_codex_security_mcp +1 -0
- package/_bundled_plugin/scripts/legacy_findings.py +148 -0
- package/_bundled_plugin/scripts/posix_scan_local_files.py +11 -0
- package/_bundled_plugin/scripts/read_codex_session.mjs +21 -0
- package/_bundled_plugin/scripts/report_projection.py +81 -43
- package/_bundled_plugin/scripts/review_state.py +8 -2
- package/_bundled_plugin/scripts/servicenow_avit.py +20 -0
- package/_bundled_plugin/scripts/snapshot_sqlite.py +1 -0
- package/_bundled_plugin/scripts/threat_model_projection.py +22 -26
- package/_bundled_plugin/scripts/validate_scan_contract.py +7 -1
- package/_bundled_plugin/scripts/windows_scan_local_files.py +388 -17
- package/_bundled_plugin/scripts/workbench/__init__.py +1 -1
- package/_bundled_plugin/scripts/workbench/handoff.py +47 -0
- package/_bundled_plugin/scripts/workbench/retained_coverage.py +30 -51
- package/_bundled_plugin/scripts/workbench/retained_records.py +18 -30
- package/_bundled_plugin/scripts/workbench/runtime_toml.py +4 -1
- package/_bundled_plugin/scripts/workbench/saved_coverage.py +9 -17
- package/_bundled_plugin/scripts/workbench/saved_outputs.py +9 -0
- package/_bundled_plugin/scripts/workbench/saved_sources.py +47 -40
- package/_bundled_plugin/scripts/workbench/storage.py +71 -7
- package/_bundled_plugin/scripts/workbench_cli.py +30 -12
- package/_bundled_plugin/scripts/workbench_constants.py +10 -0
- package/_bundled_plugin/scripts/workbench_coverage_receipts.py +3 -3
- package/_bundled_plugin/scripts/workbench_db.py +369 -137
- package/_bundled_plugin/scripts/workbench_feedback.py +8 -7
- package/_bundled_plugin/scripts/workbench_finding_index.py +1 -0
- package/_bundled_plugin/scripts/workbench_finding_workflows.py +4 -0
- package/_bundled_plugin/scripts/workbench_native_indexes.py +12 -12
- package/_bundled_plugin/scripts/workbench_progress.py +10 -1
- package/_bundled_plugin/scripts/workbench_publication.py +14 -10
- package/_bundled_plugin/scripts/workbench_remediation.py +13 -0
- package/_bundled_plugin/scripts/workbench_saved_results.py +132 -77
- package/_bundled_plugin/scripts/workbench_scan_history.py +117 -55
- package/_bundled_plugin/scripts/workbench_scan_start.py +83 -24
- package/_bundled_plugin/scripts/workbench_scan_usage.py +644 -68
- package/_bundled_plugin/scripts/workbench_schema.py +44 -55
- package/_bundled_plugin/scripts/workbench_setup.py +13 -1
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +13 -0
- package/_bundled_plugin/scripts/workbench_source_scopes.py +18 -0
- package/_bundled_plugin/scripts/workbench_target.py +127 -56
- package/_bundled_plugin/scripts/workbench_target_state.py +3 -0
- package/_bundled_plugin/scripts/workbench_validation.py +43 -3
- package/_bundled_plugin/shared/workbench-history-repairs.json +19 -23
- package/_bundled_plugin/shared/workbench-migrations.json +34 -0
- package/_bundled_plugin/skills/cloud-findings/SKILL.md +5 -5
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +7 -50
- package/_bundled_plugin/skills/fix-finding/SKILL.md +1 -1
- package/_bundled_plugin/skills/publish-findings/SKILL.md +32 -25
- package/_bundled_plugin/skills/publish-findings/references/checkmarx-import.md +37 -0
- package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +3 -3
- package/_bundled_plugin/skills/publish-findings/scripts/collect_checkmarx.py +464 -0
- package/_bundled_plugin/skills/threat-model-visualize/scripts/build_explorer.py +22 -1
- package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +6 -2
- package/dist/api.d.ts +39 -4
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +774 -292
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +4 -6
- package/dist/auth.js.map +1 -1
- package/dist/bedrock-oss-pricing.d.ts +6 -0
- package/dist/bedrock-oss-pricing.d.ts.map +1 -0
- package/dist/bedrock-oss-pricing.js +58 -0
- package/dist/bedrock-oss-pricing.js.map +1 -0
- package/dist/bedrock-pricing.d.ts +15 -0
- package/dist/bedrock-pricing.d.ts.map +1 -0
- package/dist/bedrock-pricing.js +117 -0
- package/dist/bedrock-pricing.js.map +1 -0
- package/dist/blackduck-findings.d.ts.map +1 -1
- package/dist/blackduck-findings.js +35 -20
- package/dist/blackduck-findings.js.map +1 -1
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +4 -4
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/checkmarx-evidence.d.ts +19 -0
- package/dist/checkmarx-evidence.d.ts.map +1 -0
- package/dist/checkmarx-evidence.js +36 -0
- package/dist/checkmarx-evidence.js.map +1 -0
- package/dist/checkmarx-findings.d.ts +4 -0
- package/dist/checkmarx-findings.d.ts.map +1 -0
- package/dist/checkmarx-findings.js +27 -0
- package/dist/checkmarx-findings.js.map +1 -0
- package/dist/checkmarx-one.d.ts +4 -0
- package/dist/checkmarx-one.d.ts.map +1 -0
- package/dist/checkmarx-one.js +53 -0
- package/dist/checkmarx-one.js.map +1 -0
- package/dist/checkmarx-repository.d.ts +12 -0
- package/dist/checkmarx-repository.d.ts.map +1 -0
- package/dist/checkmarx-repository.js +181 -0
- package/dist/checkmarx-repository.js.map +1 -0
- package/dist/checkmarx-xml.d.ts +12 -0
- package/dist/checkmarx-xml.d.ts.map +1 -0
- package/dist/checkmarx-xml.js +196 -0
- package/dist/checkmarx-xml.js.map +1 -0
- package/dist/classify-severity-records.d.ts +1 -9
- package/dist/classify-severity-records.d.ts.map +1 -1
- package/dist/classify-severity-records.js +3 -13
- package/dist/classify-severity-records.js.map +1 -1
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +2 -4
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli.d.ts +11 -5
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1734 -1238
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.js +2 -2
- package/dist/cloud-publish.js.map +1 -1
- package/dist/component-scan.d.ts +16 -3
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +27 -2
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +100 -66
- package/dist/config.js.map +1 -1
- package/dist/continuum-findings.d.ts.map +1 -1
- package/dist/continuum-findings.js +80 -12
- package/dist/continuum-findings.js.map +1 -1
- package/dist/contract-values.d.ts +2 -0
- package/dist/contract-values.d.ts.map +1 -1
- package/dist/contract-values.js +12 -9
- package/dist/contract-values.js.map +1 -1
- package/dist/cost-model.d.ts +13 -1
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +66 -112
- package/dist/cost-model.js.map +1 -1
- package/dist/cost.d.ts +42 -3
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +483 -104
- package/dist/cost.js.map +1 -1
- package/dist/custom-publish.d.ts +4 -0
- package/dist/custom-publish.d.ts.map +1 -1
- package/dist/custom-publish.js +40 -3
- package/dist/custom-publish.js.map +1 -1
- package/dist/deduplication/local.d.ts +2 -2
- package/dist/deduplication/local.d.ts.map +1 -1
- package/dist/deduplication/local.js +2 -2
- package/dist/deduplication/local.js.map +1 -1
- package/dist/deduplication/refusal.d.ts.map +1 -1
- package/dist/deduplication/refusal.js +25 -5
- package/dist/deduplication/refusal.js.map +1 -1
- package/dist/deduplication/scan.d.ts +3 -0
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +1 -1
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-config.d.ts +0 -1
- package/dist/deep-config.d.ts.map +1 -1
- package/dist/deep-config.js +22 -33
- package/dist/deep-config.js.map +1 -1
- package/dist/deep-scan-defaults.d.ts +2 -0
- package/dist/deep-scan-defaults.d.ts.map +1 -1
- package/dist/deep-scan-defaults.js +28 -1
- package/dist/deep-scan-defaults.js.map +1 -1
- package/dist/deep-scan.d.ts +2 -0
- package/dist/deep-scan.d.ts.map +1 -1
- package/dist/deep-scan.js +28 -4
- package/dist/deep-scan.js.map +1 -1
- package/dist/default-severity-rubric.d.ts +1 -1
- package/dist/default-severity-rubric.d.ts.map +1 -1
- package/dist/default-severity-rubric.js +1 -1
- package/dist/default-severity-rubric.js.map +1 -1
- package/dist/endor-findings.d.ts +3 -1
- package/dist/endor-findings.d.ts.map +1 -1
- package/dist/endor-findings.js +103 -45
- package/dist/endor-findings.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +8 -1
- package/dist/errors.js.map +1 -1
- package/dist/external-findings-import.d.ts +5 -3
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +7 -6
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts +7 -5
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +337 -89
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +8 -6
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +1318 -258
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +20 -2
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +148 -66
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-findings.d.ts +15 -3
- package/dist/external-findings.d.ts.map +1 -1
- package/dist/external-findings.js +42 -1
- package/dist/external-findings.js.map +1 -1
- package/dist/external-import-contract.d.ts +5 -1
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +23 -9
- package/dist/external-import-contract.js.map +1 -1
- package/dist/external-import-models.d.ts +1 -1
- package/dist/external-import-models.d.ts.map +1 -1
- package/dist/external-import-models.js.map +1 -1
- package/dist/feedback.d.ts.map +1 -1
- package/dist/feedback.js +5 -4
- package/dist/feedback.js.map +1 -1
- package/dist/finding-prompt.d.ts +5 -0
- package/dist/finding-prompt.d.ts.map +1 -0
- package/dist/finding-prompt.js +32 -0
- package/dist/finding-prompt.js.map +1 -0
- package/dist/findings-client.d.ts +1 -0
- package/dist/findings-client.d.ts.map +1 -1
- package/dist/findings-client.js +27 -3
- package/dist/findings-client.js.map +1 -1
- package/dist/github-advisories.d.ts.map +1 -1
- package/dist/github-advisories.js +0 -2
- package/dist/github-advisories.js.map +1 -1
- package/dist/github-dependabot-findings.d.ts.map +1 -1
- package/dist/github-dependabot-findings.js +15 -4
- package/dist/github-dependabot-findings.js.map +1 -1
- package/dist/github-findings.d.ts +4 -1
- package/dist/github-findings.d.ts.map +1 -1
- package/dist/github-findings.js +55 -30
- package/dist/github-findings.js.map +1 -1
- package/dist/hosted-git-remotes.d.ts +5 -0
- package/dist/hosted-git-remotes.d.ts.map +1 -0
- package/dist/hosted-git-remotes.js +285 -0
- package/dist/hosted-git-remotes.js.map +1 -0
- package/dist/hosted-git-repository.d.ts +28 -0
- package/dist/hosted-git-repository.d.ts.map +1 -0
- package/dist/hosted-git-repository.js +222 -0
- package/dist/hosted-git-repository.js.map +1 -0
- package/dist/hosted-scan-protocol.js +2 -2
- package/dist/hosted-scan-protocol.js.map +1 -1
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +16 -11
- package/dist/hosted-scan.js.map +1 -1
- package/dist/hosted-scanner-http.d.ts +21 -0
- package/dist/hosted-scanner-http.d.ts.map +1 -0
- package/dist/hosted-scanner-http.js +204 -0
- package/dist/hosted-scanner-http.js.map +1 -0
- package/dist/hosted-scanner-v1.d.ts +6 -0
- package/dist/hosted-scanner-v1.d.ts.map +1 -0
- package/dist/hosted-scanner-v1.js +60 -0
- package/dist/hosted-scanner-v1.js.map +1 -0
- package/dist/import-scan.d.ts.map +1 -1
- package/dist/import-scan.js +3 -0
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +18 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/inspector-findings.d.ts.map +1 -1
- package/dist/inspector-findings.js +47 -65
- package/dist/inspector-findings.js.map +1 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +68 -5
- package/dist/knowledge-base.js.map +1 -1
- package/dist/local-git-metadata.d.ts +1 -1
- package/dist/local-git-metadata.d.ts.map +1 -1
- package/dist/local-git-metadata.js +1 -2
- package/dist/local-git-metadata.js.map +1 -1
- package/dist/multiscan.d.ts +6 -4
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +138 -65
- package/dist/multiscan.js.map +1 -1
- package/dist/native-json-findings.d.ts +2 -1
- package/dist/native-json-findings.d.ts.map +1 -1
- package/dist/native-json-findings.js +12 -2
- package/dist/native-json-findings.js.map +1 -1
- package/dist/opengrep-findings.d.ts +1 -0
- package/dist/opengrep-findings.d.ts.map +1 -1
- package/dist/opengrep-findings.js +17 -13
- package/dist/opengrep-findings.js.map +1 -1
- package/dist/operation-telemetry.d.ts +104 -0
- package/dist/operation-telemetry.d.ts.map +1 -0
- package/dist/operation-telemetry.js +293 -0
- package/dist/operation-telemetry.js.map +1 -0
- package/dist/plugin-python-probe.d.ts +4 -0
- package/dist/plugin-python-probe.d.ts.map +1 -0
- package/dist/plugin-python-probe.js +10 -0
- package/dist/plugin-python-probe.js.map +1 -0
- package/dist/private-finding-import.d.ts +97 -2
- package/dist/private-finding-import.d.ts.map +1 -1
- package/dist/private-finding-import.js +58 -34
- package/dist/private-finding-import.js.map +1 -1
- package/dist/provider-profile.d.ts +1 -1
- package/dist/provider-profile.d.ts.map +1 -1
- package/dist/provider-profile.js +8 -1
- package/dist/provider-profile.js.map +1 -1
- package/dist/publication-telemetry.d.ts +45 -0
- package/dist/publication-telemetry.d.ts.map +1 -0
- package/dist/publication-telemetry.js +50 -0
- package/dist/publication-telemetry.js.map +1 -0
- package/dist/publish.d.ts +4 -0
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +42 -2
- package/dist/publish.js.map +1 -1
- package/dist/reader-selection.d.ts +2 -0
- package/dist/reader-selection.d.ts.map +1 -1
- package/dist/reader-selection.js +8 -0
- package/dist/reader-selection.js.map +1 -1
- package/dist/remediation.d.ts +1 -4
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +3 -7
- package/dist/remediation.js.map +1 -1
- package/dist/request-metadata.d.ts +3 -0
- package/dist/request-metadata.d.ts.map +1 -1
- package/dist/request-metadata.js +9 -0
- package/dist/request-metadata.js.map +1 -1
- package/dist/result.d.ts +4 -0
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +1 -1
- package/dist/result.js.map +1 -1
- package/dist/retry-windows-rename.d.ts +8 -0
- package/dist/retry-windows-rename.d.ts.map +1 -0
- package/dist/retry-windows-rename.js +24 -0
- package/dist/retry-windows-rename.js.map +1 -0
- package/dist/runtime.d.ts +20 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +313 -110
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan-bootstrap.d.ts +1 -0
- package/dist/saved-scan-bootstrap.d.ts.map +1 -1
- package/dist/saved-scan-bootstrap.js +18 -15
- package/dist/saved-scan-bootstrap.js.map +1 -1
- package/dist/scan-activity.d.ts.map +1 -1
- package/dist/scan-activity.js +141 -56
- package/dist/scan-activity.js.map +1 -1
- package/dist/scan-comparison.d.ts +10 -5
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +60 -15
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +6 -6
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +75 -42
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-executor.d.ts +10 -1
- package/dist/scan-executor.d.ts.map +1 -1
- package/dist/scan-executor.js +22 -2
- package/dist/scan-executor.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +9 -19
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts +12 -0
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +106 -77
- package/dist/scan-logs.js.map +1 -1
- package/dist/scan-measurement.d.ts +26 -0
- package/dist/scan-measurement.d.ts.map +1 -0
- package/dist/scan-measurement.js +77 -0
- package/dist/scan-measurement.js.map +1 -0
- package/dist/scan-progress.d.ts +1 -0
- package/dist/scan-progress.d.ts.map +1 -1
- package/dist/scan-progress.js +3 -0
- package/dist/scan-progress.js.map +1 -1
- package/dist/scan-sessions.d.ts.map +1 -1
- package/dist/scan-sessions.js +4 -1
- package/dist/scan-sessions.js.map +1 -1
- package/dist/scan-settings.d.ts +1 -1
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +1 -24
- package/dist/scan-settings.js.map +1 -1
- package/dist/scanner-import.d.ts +20 -2
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +200 -8
- package/dist/scanner-import.js.map +1 -1
- package/dist/scanner-repository-url.d.ts +4 -1
- package/dist/scanner-repository-url.d.ts.map +1 -1
- package/dist/scanner-repository-url.js +10 -6
- package/dist/scanner-repository-url.js.map +1 -1
- package/dist/security-policy.d.ts +1 -1
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js.map +1 -1
- package/dist/semgrep-findings.d.ts +6 -3
- package/dist/semgrep-findings.d.ts.map +1 -1
- package/dist/semgrep-findings.js +107 -43
- package/dist/semgrep-findings.js.map +1 -1
- package/dist/semgrep-guardian-findings.d.ts +38 -0
- package/dist/semgrep-guardian-findings.d.ts.map +1 -0
- package/dist/semgrep-guardian-findings.js +165 -0
- package/dist/semgrep-guardian-findings.js.map +1 -0
- package/dist/semgrep-platform-collector.d.ts +26 -0
- package/dist/semgrep-platform-collector.d.ts.map +1 -0
- package/dist/semgrep-platform-collector.js +108 -0
- package/dist/semgrep-platform-collector.js.map +1 -0
- package/dist/semgrep-platform-findings.d.ts +207 -6
- package/dist/semgrep-platform-findings.d.ts.map +1 -1
- package/dist/semgrep-platform-findings.js +983 -103
- package/dist/semgrep-platform-findings.js.map +1 -1
- package/dist/semgrep-platform-v1.d.ts +6 -0
- package/dist/semgrep-platform-v1.d.ts.map +1 -0
- package/dist/semgrep-platform-v1.js +83 -0
- package/dist/semgrep-platform-v1.js.map +1 -0
- package/dist/server/api.d.ts +1 -1
- package/dist/server/api.d.ts.map +1 -1
- package/dist/server/api.js.map +1 -1
- package/dist/server/embedding-tokenizer.cdx.json +33 -0
- package/dist/server/embedding-tokenizer.d.ts +2 -0
- package/dist/server/embedding-tokenizer.d.ts.map +1 -0
- package/dist/server/embedding-tokenizer.js +322 -0
- package/dist/server/embedding-tokenizer.js.map +6 -0
- package/dist/server/embeddings.d.ts +16 -2
- package/dist/server/embeddings.d.ts.map +1 -1
- package/dist/server/embeddings.js +35 -5
- package/dist/server/embeddings.js.map +1 -1
- package/dist/session-lines.d.ts +5 -0
- package/dist/session-lines.d.ts.map +1 -0
- package/dist/session-lines.js +60 -0
- package/dist/session-lines.js.map +1 -0
- package/dist/severity-review.d.ts +3 -1
- package/dist/severity-review.d.ts.map +1 -1
- package/dist/severity-review.js +3 -2
- package/dist/severity-review.js.map +1 -1
- package/dist/skill-authentication.d.ts +1 -0
- package/dist/skill-authentication.d.ts.map +1 -1
- package/dist/skill-authentication.js +1 -0
- package/dist/skill-authentication.js.map +1 -1
- package/dist/snyk-findings.d.ts +7 -2
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +93 -70
- package/dist/snyk-findings.js.map +1 -1
- package/dist/snyk-rest-findings.d.ts +76 -0
- package/dist/snyk-rest-findings.d.ts.map +1 -0
- package/dist/snyk-rest-findings.js +1051 -0
- package/dist/snyk-rest-findings.js.map +1 -0
- package/dist/snyk-rest-v1.d.ts +28 -0
- package/dist/snyk-rest-v1.d.ts.map +1 -0
- package/dist/snyk-rest-v1.js +132 -0
- package/dist/snyk-rest-v1.js.map +1 -0
- package/dist/snyk-token-origin.d.ts +4 -0
- package/dist/snyk-token-origin.d.ts.map +1 -0
- package/dist/snyk-token-origin.js +82 -0
- package/dist/snyk-token-origin.js.map +1 -0
- package/dist/sonar-collector.d.ts.map +1 -1
- package/dist/sonar-collector.js +0 -3
- package/dist/sonar-collector.js.map +1 -1
- package/dist/sonar-import.d.ts.map +1 -1
- package/dist/sonar-import.js +2 -4
- package/dist/sonar-import.js.map +1 -1
- package/dist/target-drift.d.ts +9 -0
- package/dist/target-drift.d.ts.map +1 -0
- package/dist/target-drift.js +27 -0
- package/dist/target-drift.js.map +1 -0
- package/dist/targets.d.ts +2 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +56 -20
- package/dist/targets.js.map +1 -1
- package/dist/tenable-findings.d.ts +9 -0
- package/dist/tenable-findings.d.ts.map +1 -0
- package/dist/tenable-findings.js +122 -0
- package/dist/tenable-findings.js.map +1 -0
- package/dist/terminal-stream.d.ts +13 -0
- package/dist/terminal-stream.d.ts.map +1 -0
- package/dist/terminal-stream.js +35 -0
- package/dist/terminal-stream.js.map +1 -0
- package/dist/trivy-findings.d.ts +19 -0
- package/dist/trivy-findings.d.ts.map +1 -0
- package/dist/trivy-findings.js +435 -0
- package/dist/trivy-findings.js.map +1 -0
- package/dist/trivy-import.d.ts +19 -0
- package/dist/trivy-import.d.ts.map +1 -0
- package/dist/trivy-import.js +151 -0
- package/dist/trivy-import.js.map +1 -0
- package/dist/validation-records.js +1 -1
- package/dist/validation-records.js.map +1 -1
- package/dist/veracode-findings.d.ts +2 -0
- package/dist/veracode-findings.d.ts.map +1 -1
- package/dist/veracode-findings.js +49 -11
- package/dist/veracode-findings.js.map +1 -1
- package/dist/vertex-pricing.d.ts +8 -0
- package/dist/vertex-pricing.d.ts.map +1 -0
- package/dist/vertex-pricing.js +20 -0
- package/dist/vertex-pricing.js.map +1 -0
- package/dist/windows-path.d.ts +1 -0
- package/dist/windows-path.d.ts.map +1 -1
- package/dist/windows-path.js +26 -1
- package/dist/windows-path.js.map +1 -1
- package/dist/wiz-findings.d.ts +4 -0
- package/dist/wiz-findings.d.ts.map +1 -1
- package/dist/wiz-findings.js +57 -3
- package/dist/wiz-findings.js.map +1 -1
- package/docs/classify-severity-records.md +27 -12
- package/docs/cli.md +497 -550
- package/docs/dedupe-records.md +44 -24
- package/docs/findings-service.md +66 -39
- package/docs/hosted-remediation.md +14 -7
- package/docs/hosted-scans.md +50 -42
- package/docs/telemetry.md +236 -0
- package/docs/validate-records.md +78 -44
- package/package.json +18 -15
- package/schemas/external-findings.schema.json +3 -1
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
- package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +0 -96
- package/dist/external-imports-feature.d.ts +0 -6
- package/dist/external-imports-feature.d.ts.map +0 -1
- package/dist/external-imports-feature.js +0 -51
- package/dist/external-imports-feature.js.map +0 -1
- package/dist/finding-normalization.d.ts +0 -5
- package/dist/finding-normalization.d.ts.map +0 -1
- package/dist/finding-normalization.js +0 -155
- package/dist/finding-normalization.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-git-repository.d.ts","sourceRoot":"","sources":["../src/hosted-git-repository.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,oBAAoB,EAG1B,MAAM,+BAA+B,CAAC;AAQvC,sDAAsD;AACtD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAIxD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAOzD;AAyBD,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAOxE;AAED,8EAA8E;AAC9E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKtD;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQvD;AAED,yEAAyE;AACzE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAIrD;AAqBD,gFAAgF;AAChF,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,UAAU,EAAE,OAAO,GAClB,MAAM,CAQR;AAmFD,oFAAoF;AACpF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAS9D;AAED,uFAAuF;AACvF,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EACb,MAAM,UAAQ,EACd,cAAc,UAAQ,EACtB,MAAM,GAAE,oBAA8B,GACrC,MAAM,CAqBR;AAED,6FAA6F;AAC7F,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAQvD;AAED,2EAA2E;AAC3E,wBAAgB,uBAAuB,CACrC,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,EAC5D,MAAM,EAAE,MAAM,GACb,OAAO,CAqCT"}
|
|
@@ -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,6DAA6D,CAAC;AAEhF,MAAM,SAAS,GAAG,uDAAuD,CAAC;AAE1E,sDAAsD;AACtD,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAChE,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,KAAK,GAAG,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,wGAAwG;IACxG,OAAO,CACL,OAAO,CAAC,QAAQ,KAAK,OAAO;QAC5B,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QACvB,mCAAmC,CAAC,IAAI,CAAC,MAAM,CAAC,CACjD,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAA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;QAE5B,OAAO,KAAK,CAAC;IACf,uFAAuF;IACvF,MAAM,GAAG,GAAG,CAAC,KAAa,EAAE,EAAE,CAC5B,sBAAsB,CACpB,KAAK,CAAC,OAAO,CACX,+BAA+B,EAC/B,CAAC,KAAK,EAAE,MAAc,EAAE,SAAiB,EAAE,EAAE;QAC3C,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;QAC7C,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;IACrD,CAAC,CACF,EACD,MAAM,EACN,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAC9C,CAAC;IACJ,OAAO,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC","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"]}
|
|
@@ -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,CAA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;;;;;;;;;;;;;;;;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,13 @@ 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
11
|
import { severityRubricSnapshotSchema } from "./classify-severity-records.js";
|
|
12
|
-
import {
|
|
12
|
+
import { errorMessage } from "./errors.js";
|
|
13
13
|
import { abortable, normalizeRepository, repositoryRevision, } from "./targets.js";
|
|
14
14
|
import { isWithin } from "./trusted-executable.js";
|
|
15
15
|
/** Hosted v2 mirrors repository/paths targets; only Standard scans are supported. */
|
|
@@ -118,7 +118,11 @@ function hostedScanEnvironment(stateDirectory) {
|
|
|
118
118
|
return environment;
|
|
119
119
|
}
|
|
120
120
|
/** One invocation, with only scan-domain state. The host decides retry/reconciliation. */
|
|
121
|
-
export
|
|
121
|
+
export function runHostedScan(value, options) {
|
|
122
|
+
return runHostedScanInternal("sdk", value, options);
|
|
123
|
+
}
|
|
124
|
+
/** @internal */
|
|
125
|
+
export async function runHostedScanInternal(surface, value, options) {
|
|
122
126
|
const input = HostedScanInputSchema.parse(value);
|
|
123
127
|
const context = {
|
|
124
128
|
repository: input.repository,
|
|
@@ -132,6 +136,7 @@ export async function runHostedScan(value, options) {
|
|
|
132
136
|
let execution;
|
|
133
137
|
let request;
|
|
134
138
|
let scanId;
|
|
139
|
+
let stoppedStatus;
|
|
135
140
|
let outputDirectory = resolve(input.outputDirectory);
|
|
136
141
|
const base = () => ({
|
|
137
142
|
version: 2,
|
|
@@ -193,7 +198,7 @@ export async function runHostedScan(value, options) {
|
|
|
193
198
|
createCodex() {
|
|
194
199
|
throw new Error("Local inference is unavailable in hosted mode.");
|
|
195
200
|
},
|
|
196
|
-
}, { surface
|
|
201
|
+
}, { surface });
|
|
197
202
|
try {
|
|
198
203
|
const result = await client.run(context.repository, {
|
|
199
204
|
target: context.scope.paths[0] === "."
|
|
@@ -210,6 +215,10 @@ export async function runHostedScan(value, options) {
|
|
|
210
215
|
scanId = scan.scanId;
|
|
211
216
|
outputDirectory = scan.scanDir;
|
|
212
217
|
},
|
|
218
|
+
onLifecycle(scan) {
|
|
219
|
+
if (scan.status === "canceled" || scan.status === "failed")
|
|
220
|
+
stoppedStatus = scan.status;
|
|
221
|
+
},
|
|
213
222
|
onProgress(progress) {
|
|
214
223
|
onEvent({ type: "progress", progress });
|
|
215
224
|
},
|
|
@@ -262,15 +271,11 @@ export async function runHostedScan(value, options) {
|
|
|
262
271
|
catch (error) {
|
|
263
272
|
if (error instanceof ScanExecutionError)
|
|
264
273
|
execution = error.result;
|
|
274
|
+
const status = hostedScanFailureStatus(error, options.signal, execution);
|
|
265
275
|
return {
|
|
266
276
|
...base(),
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
: options.signal?.aborted ||
|
|
270
|
-
execution?.status === "canceled" ||
|
|
271
|
-
error instanceof ScanInterruptedError
|
|
272
|
-
? "canceled"
|
|
273
|
-
: "failed",
|
|
277
|
+
// A late abort during cleanup cannot change an already committed failure.
|
|
278
|
+
status: status === "acceptance_unknown" ? status : (stoppedStatus ?? status),
|
|
274
279
|
error: errorMessage(error),
|
|
275
280
|
artifacts: [],
|
|
276
281
|
};
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E,iBAAiB;oBACrB,IAAI,EAAE,SAAS;oBACf,MAAM,EAAE,QAAQ;oBAChB,WAAW,EAAE,+BAA+B,YAAY,CAAC,KAAK,CAAC,EAAE;oBACjE,KAAK,EAAE,EAAE;iBACV;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { hash } from \"node:crypto\";\nimport { isDeepStrictEqual } from \"node:util\";\nimport {\n readScanFile,\n safeScopePath,\n validatedFileDigests,\n} from \"./contract.js\";\nimport { isRecord } from \"./record.js\";\nimport { VERSION } from \"./version.js\";\nimport {\n ScanExecutionError,\n type ScanExecutor,\n type ScanExecutionResult,\n type ScanExecutionEvent,\n type ScanExecutionRequest,\n} from \"./scan-executor.js\";\nexport type { ScanExecutor, ScanExecutionRequest } from \"./scan-executor.js\";\nimport { realpath } from \"node:fs/promises\";\nimport { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { z } from \"zod\";\nimport { CodexSecurity } from \"./api.js\";\nimport { severityRubricSnapshotSchema } from \"./classify-severity-records.js\";\nimport { ScanInterruptedError, errorMessage } from \"./errors.js\";\nimport {\n abortable,\n normalizeRepository,\n repositoryRevision,\n} from \"./targets.js\";\nimport { isWithin } from \"./trusted-executable.js\";\n\n/** Hosted v2 mirrors repository/paths targets; only Standard scans are supported. */\nexport const HostedScanInputSchema = z.strictObject({\n version: z.literal(2),\n repository: z.string().min(1),\n revision: z.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),\n scope: z\n .strictObject({ paths: z.array(z.string().min(1)).min(1) })\n .optional(),\n outputDirectory: z.string().min(1),\n stateDirectory: z.string().min(1),\n model: z.string().min(1),\n reasoningEffort: z.string(),\n severityRubric: severityRubricSnapshotSchema\n .refine(\n ({ markdown, sha256 }) => hash(\"sha256\", markdown) === sha256,\n \"Rubric SHA-256 does not match its exact UTF-8 Markdown.\",\n )\n .optional(),\n ownerSuggestions: z.boolean().optional(),\n identity: z.strictObject({\n runId: z.string().min(1),\n attemptId: z.string().min(1),\n buildId: z.string().min(1),\n }),\n});\n\nexport type HostedScanInput = z.infer<typeof HostedScanInputSchema>;\nexport class HostedScanPreparationError extends Error {\n constructor(\n readonly reason:\n | \"scope_syntax\"\n | \"scope_missing\"\n | \"scope_outside_repository\"\n | \"scope_alias\"\n | \"revision_mismatch\",\n message: string,\n ) {\n super(message);\n this.name = \"HostedScanPreparationError\";\n }\n}\n\nexport function normalizeHostedScope(path: string): string {\n const parts = path.split(process.platform === \"win32\" ? /[/\\\\]/ : \"/\");\n if (\n path.length === 0 ||\n path.includes(\"\\0\") ||\n isAbsolute(path) ||\n (process.platform === \"win32\" && /^[a-z]:/i.test(path)) ||\n parts.includes(\"..\")\n ) {\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n \"Use non-empty repository-relative folders or files without parent traversal or NUL characters.\",\n );\n }\n const normalized = parts\n .filter((part) => part !== \"\" && part !== \".\")\n .join(\"/\");\n try {\n return safeScopePath(normalized || \".\");\n } catch {\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n `${JSON.stringify(path)} cannot be used as scan scope: the output contract requires UTF-8 repository-relative paths without drive prefixes, backslashes, or control characters.`,\n );\n }\n}\n\nfunction comparePaths(left: string, right: string): number {\n return Buffer.compare(Buffer.from(left), Buffer.from(right));\n}\n\nexport function normalizeHostedPaths(\n paths: readonly string[] = [\".\"],\n): string[] {\n if (paths.length === 0)\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n \"An explicit path scope must not be empty. Omit scope to scan the repository.\",\n );\n const normalized = [...new Set(paths.map(normalizeHostedScope))].sort(\n comparePaths,\n );\n if (normalized.length > 1 && normalized.includes(\".\"))\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n \"Repository scope cannot be mixed with narrower paths.\",\n );\n return normalized;\n}\n\n/** Validate every path at the frozen commit before registering a scan/executing. */\nasync function prepareHostedRepository(\n input: Pick<ScanExecutionRequest, \"repository\" | \"revision\" | \"scope\">,\n signal?: AbortSignal,\n) {\n const repository = await normalizeRepository(input.repository, signal);\n if ((await repositoryRevision(repository, signal)) !== input.revision)\n throw new HostedScanPreparationError(\n \"revision_mismatch\",\n \"Checkout does not match the frozen revision.\",\n );\n for (const path of input.scope.paths) {\n const selected = resolve(repository, path);\n let target: string;\n try {\n target = await abortable(() => realpath(selected), signal);\n } catch (error) {\n if (\n (signal?.aborted && error === signal.reason) ||\n !(error instanceof Error) ||\n !(\"code\" in error) ||\n error.code !== \"ENOENT\"\n )\n throw error;\n throw new HostedScanPreparationError(\n \"scope_missing\",\n `${path} does not exist at the selected revision. Update the paths and start a new scan.`,\n );\n }\n if (!isWithin(repository, target))\n throw new HostedScanPreparationError(\n \"scope_outside_repository\",\n `${path} resolves outside the repository.`,\n );\n if (target !== selected) {\n const canonical =\n relative(repository, target).split(sep).join(\"/\") || \".\";\n throw new HostedScanPreparationError(\n \"scope_alias\",\n `${path} resolves to ${canonical}. Use the canonical repository path and start a new scan.`,\n );\n }\n }\n return repository;\n}\n\nfunction hostedScanEnvironment(stateDirectory: string): Record<string, string> {\n const environment: Record<string, string> = {\n PATH: process.env[\"PATH\"] ?? \"\",\n CODEX_SECURITY_STATE_DIR: resolve(stateDirectory),\n };\n for (const key of [\n \"SYSTEMROOT\",\n \"WINDIR\",\n \"PATHEXT\",\n \"TMPDIR\",\n \"TEMP\",\n \"TMP\",\n ])\n if (process.env[key] !== undefined) environment[key] = process.env[key]!;\n return environment;\n}\n\nexport interface HostedScanOptions {\n executor: ScanExecutor;\n /** @deprecated Automatic owner reports validate scan hints without additional inference. */\n ownerCodex?: {\n startThread(options: { model?: string; modelReasoningEffort?: string }): {\n run(\n input: string,\n options: { outputSchema?: unknown; signal?: AbortSignal },\n ): Promise<{ finalResponse: string }>;\n };\n };\n signal?: AbortSignal;\n onEvent?: (event: ScanExecutionEvent) => void;\n}\n\n/** One invocation, with only scan-domain state. The host decides retry/reconciliation. */\nexport async function runHostedScan(\n value: HostedScanInput,\n options: HostedScanOptions,\n) {\n const input = HostedScanInputSchema.parse(value);\n const context = {\n repository: input.repository,\n revision: input.revision,\n scope: { paths: normalizeHostedPaths(input.scope?.paths) },\n identity: input.identity,\n ...(input.severityRubric === undefined\n ? {}\n : { severityRubric: input.severityRubric }),\n };\n let execution: ScanExecutionResult | undefined;\n let request: ScanExecutionRequest | undefined;\n let scanId: string | undefined;\n let outputDirectory = resolve(input.outputDirectory);\n const base = () => ({\n version: 2 as const,\n ...context,\n outputDirectory,\n ...(scanId === undefined ? {} : { scanId }),\n ...(request === undefined\n ? {}\n : {\n pluginVersion: request.runtime.pluginVersion,\n }),\n provenance: {\n cliVersion: VERSION,\n buildId: input.identity.buildId,\n ...(request === undefined\n ? {}\n : { pluginVersion: request.runtime.pluginVersion }),\n },\n ...(execution === undefined ? {} : { execution }),\n });\n try {\n context.repository = await prepareHostedRepository(context, options.signal);\n } catch (error) {\n if (\n options.signal?.aborted &&\n (Object.is(error, options.signal.reason) ||\n (error instanceof DOMException && error.name === \"AbortError\"))\n )\n return {\n ...base(),\n status: \"canceled\" as const,\n error: `Canceled before checkout verification finished: ${errorMessage(error)}`,\n artifacts: [],\n };\n throw error;\n }\n const onEvent = (event: ScanExecutionEvent): void => {\n void Promise.resolve()\n .then(() => options.onEvent?.(event))\n .catch(() => {});\n };\n const client = new CodexSecurity(\n {\n codexOverrides: {\n model: input.model,\n model_reasoning_effort: input.reasoningEffort,\n },\n },\n {\n environment: hostedScanEnvironment(input.stateDirectory),\n hostedScan: {\n context,\n executor: {\n async run(value, runOptions) {\n request = value;\n execution = await options.executor.run(value, runOptions);\n return execution;\n },\n },\n onEvent,\n },\n createCodex() {\n throw new Error(\"Local inference is unavailable in hosted mode.\");\n },\n },\n { surface: \"sdk\" },\n );\n try {\n const result = await client.run(context.repository, {\n target:\n context.scope.paths[0] === \".\"\n ? \"repository\"\n : context.scope.paths.map((path) => `./${path}`),\n mode: \"standard\",\n outputDir: outputDirectory,\n signal: options.signal,\n ownerSuggestions: input.ownerSuggestions,\n onOutputDirReady(path) {\n outputDirectory = path;\n },\n onScanRegistered(scan) {\n scanId = scan.scanId;\n outputDirectory = scan.scanDir;\n },\n onProgress(progress) {\n onEvent({ type: \"progress\", progress });\n },\n onActivity(activity) {\n onEvent({ type: \"activity\", activity });\n },\n });\n if (\n result.manifest.scan.target.revision !== context.revision ||\n // Owner cancellation cannot invalidate an already sealed base scan.\n (await repositoryRevision(context.repository)) !== context.revision\n )\n throw new Error(\n \"Checkout changed from the frozen revision during execution.\",\n );\n if (\n !isDeepStrictEqual(\n [...result.manifest.scan.scope.includePaths].sort(comparePaths),\n context.scope.paths,\n ) ||\n result.manifest.scan.scope.excludePaths.length !== 0\n )\n throw new Error(\"Completed artifacts do not match the requested scope.\");\n const sources = result.manifest.scan[\"preservedSources\"];\n const sealedDigests = validatedFileDigests.get(result.manifest)!;\n const names = new Set([\n \"scan-manifest.json\",\n \"findings.json\",\n \"report.md\",\n ...result.manifest.scan.artifacts.map(({ path }) => path),\n ...(isRecord(sources) ? Object.keys(sources) : []),\n ]);\n if (result.ownerSuggestionsPath !== undefined)\n names.add(\"owner-suggestions.json\");\n const artifacts = await Promise.all(\n [...names].sort().map(async (path) => {\n const contents = await readScanFile(outputDirectory, path, path);\n return {\n path,\n sha256: hash(\"sha256\", contents),\n bytes: contents.byteLength,\n };\n }),\n );\n // Report a seal mismatch after the concurrent reads have closed their files.\n for (const { path, sha256 } of artifacts) {\n const expected = sealedDigests.get(path);\n if (expected !== undefined && expected !== sha256) {\n throw new Error(\n `The sealed file ${path} changed before the hosted receipt was created.`,\n );\n }\n }\n return {\n ...base(),\n status: \"completed\" as const,\n ...(result.ownerSuggestionsError === undefined\n ? {}\n : { ownerSuggestionsError: result.ownerSuggestionsError }),\n artifacts,\n };\n } catch (error) {\n if (error instanceof ScanExecutionError) execution = error.result;\n return {\n ...base(),\n status:\n execution?.status === \"acceptance_unknown\"\n ? (\"acceptance_unknown\" as const)\n : options.signal?.aborted ||\n execution?.status === \"canceled\" ||\n error instanceof ScanInterruptedError\n ? (\"canceled\" as const)\n : (\"failed\" as const),\n error: errorMessage(error),\n artifacts: [],\n };\n } finally {\n try {\n await client.close();\n } catch (error) {\n onEvent({\n type: \"activity\",\n activity: {\n id: \"runtime.cleanup\",\n kind: \"message\",\n status: \"failed\",\n description: `Hosted scan cleanup failed: ${errorMessage(error)}`,\n paths: [],\n },\n });\n }\n }\n}\n\nexport type HostedScanResult = Awaited<ReturnType<typeof runHostedScan>>;\n"]}
|
|
1
|
+
{"version":3,"file":"hosted-scan.js","sourceRoot":"","sources":["../src/hosted-scan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,aAAa,EACb,oBAAoB,GACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,uBAAuB,EACvB,kBAAkB,GAKnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAA6B,MAAM,UAAU,CAAC;AACpE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,qFAAqF;AACrF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,YAA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CAAC;QAClE,MAAM,MAAM,GAAG,uBAAuB,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACzE,OAAO;YACL,GAAG,IAAI,EAAE;YACT,0EAA0E;YAC1E,MAAM,EACJ,MAAM,KAAK,oBAAoB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,IAAI,MAAM,CAAC;YACtE,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC;YAC1B,SAAS,EAAE,EAAE;SACd,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC;gBACN,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE;oBACR,EAAE,EAAE,iBAAiB;oBACrB,IAAI,EAAE,SAAS;oBACf,MAAM,EAAE,QAAQ;oBAChB,WAAW,EAAE,+BAA+B,YAAY,CAAC,KAAK,CAAC,EAAE;oBACjE,KAAK,EAAE,EAAE;iBACV;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { hash } from \"node:crypto\";\nimport { isDeepStrictEqual } from \"node:util\";\nimport {\n readScanFile,\n safeScopePath,\n validatedFileDigests,\n} from \"./contract.js\";\nimport { isRecord } from \"./record.js\";\nimport { VERSION } from \"./version.js\";\nimport {\n hostedScanFailureStatus,\n ScanExecutionError,\n type ScanExecutor,\n type ScanExecutionResult,\n type ScanExecutionEvent,\n type ScanExecutionRequest,\n} from \"./scan-executor.js\";\nexport type { ScanExecutor, ScanExecutionRequest } from \"./scan-executor.js\";\nimport { realpath } from \"node:fs/promises\";\nimport { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { z } from \"zod\";\nimport { CodexSecurity, type CodexSecuritySurface } from \"./api.js\";\nimport { severityRubricSnapshotSchema } from \"./classify-severity-records.js\";\nimport { errorMessage } from \"./errors.js\";\nimport {\n abortable,\n normalizeRepository,\n repositoryRevision,\n} from \"./targets.js\";\nimport { isWithin } from \"./trusted-executable.js\";\n\n/** Hosted v2 mirrors repository/paths targets; only Standard scans are supported. */\nexport const HostedScanInputSchema = z.strictObject({\n version: z.literal(2),\n repository: z.string().min(1),\n revision: z.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),\n scope: z\n .strictObject({ paths: z.array(z.string().min(1)).min(1) })\n .optional(),\n outputDirectory: z.string().min(1),\n stateDirectory: z.string().min(1),\n model: z.string().min(1),\n reasoningEffort: z.string(),\n severityRubric: severityRubricSnapshotSchema\n .refine(\n ({ markdown, sha256 }) => hash(\"sha256\", markdown) === sha256,\n \"Rubric SHA-256 does not match its exact UTF-8 Markdown.\",\n )\n .optional(),\n ownerSuggestions: z.boolean().optional(),\n identity: z.strictObject({\n runId: z.string().min(1),\n attemptId: z.string().min(1),\n buildId: z.string().min(1),\n }),\n});\n\nexport type HostedScanInput = z.infer<typeof HostedScanInputSchema>;\nexport class HostedScanPreparationError extends Error {\n constructor(\n readonly reason:\n | \"scope_syntax\"\n | \"scope_missing\"\n | \"scope_outside_repository\"\n | \"scope_alias\"\n | \"revision_mismatch\",\n message: string,\n ) {\n super(message);\n this.name = \"HostedScanPreparationError\";\n }\n}\n\nexport function normalizeHostedScope(path: string): string {\n const parts = path.split(process.platform === \"win32\" ? /[/\\\\]/ : \"/\");\n if (\n path.length === 0 ||\n path.includes(\"\\0\") ||\n isAbsolute(path) ||\n (process.platform === \"win32\" && /^[a-z]:/i.test(path)) ||\n parts.includes(\"..\")\n ) {\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n \"Use non-empty repository-relative folders or files without parent traversal or NUL characters.\",\n );\n }\n const normalized = parts\n .filter((part) => part !== \"\" && part !== \".\")\n .join(\"/\");\n try {\n return safeScopePath(normalized || \".\");\n } catch {\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n `${JSON.stringify(path)} cannot be used as scan scope: the output contract requires UTF-8 repository-relative paths without drive prefixes, backslashes, or control characters.`,\n );\n }\n}\n\nfunction comparePaths(left: string, right: string): number {\n return Buffer.compare(Buffer.from(left), Buffer.from(right));\n}\n\nexport function normalizeHostedPaths(\n paths: readonly string[] = [\".\"],\n): string[] {\n if (paths.length === 0)\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n \"An explicit path scope must not be empty. Omit scope to scan the repository.\",\n );\n const normalized = [...new Set(paths.map(normalizeHostedScope))].sort(\n comparePaths,\n );\n if (normalized.length > 1 && normalized.includes(\".\"))\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n \"Repository scope cannot be mixed with narrower paths.\",\n );\n return normalized;\n}\n\n/** Validate every path at the frozen commit before registering a scan/executing. */\nasync function prepareHostedRepository(\n input: Pick<ScanExecutionRequest, \"repository\" | \"revision\" | \"scope\">,\n signal?: AbortSignal,\n) {\n const repository = await normalizeRepository(input.repository, signal);\n if ((await repositoryRevision(repository, signal)) !== input.revision)\n throw new HostedScanPreparationError(\n \"revision_mismatch\",\n \"Checkout does not match the frozen revision.\",\n );\n for (const path of input.scope.paths) {\n const selected = resolve(repository, path);\n let target: string;\n try {\n target = await abortable(() => realpath(selected), signal);\n } catch (error) {\n if (\n (signal?.aborted && error === signal.reason) ||\n !(error instanceof Error) ||\n !(\"code\" in error) ||\n error.code !== \"ENOENT\"\n )\n throw error;\n throw new HostedScanPreparationError(\n \"scope_missing\",\n `${path} does not exist at the selected revision. Update the paths and start a new scan.`,\n );\n }\n if (!isWithin(repository, target))\n throw new HostedScanPreparationError(\n \"scope_outside_repository\",\n `${path} resolves outside the repository.`,\n );\n if (target !== selected) {\n const canonical =\n relative(repository, target).split(sep).join(\"/\") || \".\";\n throw new HostedScanPreparationError(\n \"scope_alias\",\n `${path} resolves to ${canonical}. Use the canonical repository path and start a new scan.`,\n );\n }\n }\n return repository;\n}\n\nfunction hostedScanEnvironment(stateDirectory: string): Record<string, string> {\n const environment: Record<string, string> = {\n PATH: process.env[\"PATH\"] ?? \"\",\n CODEX_SECURITY_STATE_DIR: resolve(stateDirectory),\n };\n for (const key of [\n \"SYSTEMROOT\",\n \"WINDIR\",\n \"PATHEXT\",\n \"TMPDIR\",\n \"TEMP\",\n \"TMP\",\n ])\n if (process.env[key] !== undefined) environment[key] = process.env[key]!;\n return environment;\n}\n\nexport interface HostedScanOptions {\n executor: ScanExecutor;\n /** @deprecated Automatic owner reports validate scan hints without additional inference. */\n ownerCodex?: {\n startThread(options: { model?: string; modelReasoningEffort?: string }): {\n run(\n input: string,\n options: { outputSchema?: unknown; signal?: AbortSignal },\n ): Promise<{ finalResponse: string }>;\n };\n };\n signal?: AbortSignal;\n onEvent?: (event: ScanExecutionEvent) => void;\n}\n\n/** One invocation, with only scan-domain state. The host decides retry/reconciliation. */\nexport function runHostedScan(\n value: HostedScanInput,\n options: HostedScanOptions,\n) {\n return runHostedScanInternal(\"sdk\", value, options);\n}\n\n/** @internal */\nexport async function runHostedScanInternal(\n surface: CodexSecuritySurface,\n value: HostedScanInput,\n options: HostedScanOptions,\n) {\n const input = HostedScanInputSchema.parse(value);\n const context = {\n repository: input.repository,\n revision: input.revision,\n scope: { paths: normalizeHostedPaths(input.scope?.paths) },\n identity: input.identity,\n ...(input.severityRubric === undefined\n ? {}\n : { severityRubric: input.severityRubric }),\n };\n let execution: ScanExecutionResult | undefined;\n let request: ScanExecutionRequest | undefined;\n let scanId: string | undefined;\n let stoppedStatus: \"canceled\" | \"failed\" | undefined;\n let outputDirectory = resolve(input.outputDirectory);\n const base = () => ({\n version: 2 as const,\n ...context,\n outputDirectory,\n ...(scanId === undefined ? {} : { scanId }),\n ...(request === undefined\n ? {}\n : {\n pluginVersion: request.runtime.pluginVersion,\n }),\n provenance: {\n cliVersion: VERSION,\n buildId: input.identity.buildId,\n ...(request === undefined\n ? {}\n : { pluginVersion: request.runtime.pluginVersion }),\n },\n ...(execution === undefined ? {} : { execution }),\n });\n try {\n context.repository = await prepareHostedRepository(context, options.signal);\n } catch (error) {\n if (\n options.signal?.aborted &&\n (Object.is(error, options.signal.reason) ||\n (error instanceof DOMException && error.name === \"AbortError\"))\n )\n return {\n ...base(),\n status: \"canceled\" as const,\n error: `Canceled before checkout verification finished: ${errorMessage(error)}`,\n artifacts: [],\n };\n throw error;\n }\n const onEvent = (event: ScanExecutionEvent): void => {\n void Promise.resolve()\n .then(() => options.onEvent?.(event))\n .catch(() => {});\n };\n const client = new CodexSecurity(\n {\n codexOverrides: {\n model: input.model,\n model_reasoning_effort: input.reasoningEffort,\n },\n },\n {\n environment: hostedScanEnvironment(input.stateDirectory),\n hostedScan: {\n context,\n executor: {\n async run(value, runOptions) {\n request = value;\n execution = await options.executor.run(value, runOptions);\n return execution;\n },\n },\n onEvent,\n },\n createCodex() {\n throw new Error(\"Local inference is unavailable in hosted mode.\");\n },\n },\n { surface },\n );\n try {\n const result = await client.run(context.repository, {\n target:\n context.scope.paths[0] === \".\"\n ? \"repository\"\n : context.scope.paths.map((path) => `./${path}`),\n mode: \"standard\",\n outputDir: outputDirectory,\n signal: options.signal,\n ownerSuggestions: input.ownerSuggestions,\n onOutputDirReady(path) {\n outputDirectory = path;\n },\n onScanRegistered(scan) {\n scanId = scan.scanId;\n outputDirectory = scan.scanDir;\n },\n onLifecycle(scan) {\n if (scan.status === \"canceled\" || scan.status === \"failed\")\n stoppedStatus = scan.status;\n },\n onProgress(progress) {\n onEvent({ type: \"progress\", progress });\n },\n onActivity(activity) {\n onEvent({ type: \"activity\", activity });\n },\n });\n if (\n result.manifest.scan.target.revision !== context.revision ||\n // Owner cancellation cannot invalidate an already sealed base scan.\n (await repositoryRevision(context.repository)) !== context.revision\n )\n throw new Error(\n \"Checkout changed from the frozen revision during execution.\",\n );\n if (\n !isDeepStrictEqual(\n [...result.manifest.scan.scope.includePaths].sort(comparePaths),\n context.scope.paths,\n ) ||\n result.manifest.scan.scope.excludePaths.length !== 0\n )\n throw new Error(\"Completed artifacts do not match the requested scope.\");\n const sources = result.manifest.scan[\"preservedSources\"];\n const sealedDigests = validatedFileDigests.get(result.manifest)!;\n const names = new Set([\n \"scan-manifest.json\",\n \"findings.json\",\n \"report.md\",\n ...result.manifest.scan.artifacts.map(({ path }) => path),\n ...(isRecord(sources) ? Object.keys(sources) : []),\n ]);\n if (result.ownerSuggestionsPath !== undefined)\n names.add(\"owner-suggestions.json\");\n const artifacts = await Promise.all(\n [...names].sort().map(async (path) => {\n const contents = await readScanFile(outputDirectory, path, path);\n return {\n path,\n sha256: hash(\"sha256\", contents),\n bytes: contents.byteLength,\n };\n }),\n );\n // Report a seal mismatch after the concurrent reads have closed their files.\n for (const { path, sha256 } of artifacts) {\n const expected = sealedDigests.get(path);\n if (expected !== undefined && expected !== sha256) {\n throw new Error(\n `The sealed file ${path} changed before the hosted receipt was created.`,\n );\n }\n }\n return {\n ...base(),\n status: \"completed\" as const,\n ...(result.ownerSuggestionsError === undefined\n ? {}\n : { ownerSuggestionsError: result.ownerSuggestionsError }),\n artifacts,\n };\n } catch (error) {\n if (error instanceof ScanExecutionError) execution = error.result;\n const status = hostedScanFailureStatus(error, options.signal, execution);\n return {\n ...base(),\n // A late abort during cleanup cannot change an already committed failure.\n status:\n status === \"acceptance_unknown\" ? status : (stoppedStatus ?? status),\n error: errorMessage(error),\n artifacts: [],\n };\n } finally {\n try {\n await client.close();\n } catch (error) {\n onEvent({\n type: \"activity\",\n activity: {\n id: \"runtime.cleanup\",\n kind: \"message\",\n status: \"failed\",\n description: `Hosted scan cleanup failed: ${errorMessage(error)}`,\n paths: [],\n },\n });\n }\n }\n}\n\nexport type HostedScanResult = Awaited<ReturnType<typeof runHostedScan>>;\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface HostedScannerHttpOptions {
|
|
2
|
+
environment?: NodeJS.ProcessEnv;
|
|
3
|
+
fetch?: (url: URL, init: RequestInit) => Promise<Response>;
|
|
4
|
+
signal?: AbortSignal;
|
|
5
|
+
}
|
|
6
|
+
export declare function hostedNumberToken(value: unknown): string | undefined;
|
|
7
|
+
/** Store native evidence by exact numeric value, independently of its wire spelling. */
|
|
8
|
+
export declare function stringifyHostedEvidence(value: unknown): string;
|
|
9
|
+
/** Keep vendor numeric IDs and evidence exact when a response is saved as JSON. */
|
|
10
|
+
export declare function parseHostedScannerJson(source: string): unknown;
|
|
11
|
+
export declare function hostedRepositoryUrl(value: unknown, label: string): string;
|
|
12
|
+
/** Normalize the provider's HTTP or independently identified SSH repository address. */
|
|
13
|
+
export declare function hostedNativeRepositoryUrl(value: unknown, label: string, additionalGitHost?: string): string;
|
|
14
|
+
export declare function scannerEnvironmentValue(environment: NodeJS.ProcessEnv, requested: string): string | undefined;
|
|
15
|
+
/** Use the selected vendor credential only with its configured service origin. */
|
|
16
|
+
export declare function hostedScannerToken(environment: NodeJS.ProcessEnv, tokenName: string, explicitToken: string | undefined, origin: string, ...originNames: string[]): string | undefined;
|
|
17
|
+
export declare function hostedScannerHttp(dependencies: HostedScannerHttpOptions, callerSignal?: AbortSignal): {
|
|
18
|
+
signal: AbortSignal | undefined;
|
|
19
|
+
getJson: (url: URL, authorization: string) => Promise<unknown>;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=hosted-scanner-http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-scanner-http.d.ts","sourceRoot":"","sources":["../src/hosted-scanner-http.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,wBAAwB;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IAChC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3D,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAOD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAEpE;AAED,wFAAwF;AACxF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAA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