@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,204 @@
|
|
|
1
|
+
import { waitForRetry } from "./deduplication/retry.js";
|
|
2
|
+
import { canonicalNumber } from "./external-import-contract.js";
|
|
3
|
+
import { CodexSecurityError, errorMessage } from "./errors.js";
|
|
4
|
+
import { normalizeHostedGitRepositoryUrl } from "./hosted-git-repository.js";
|
|
5
|
+
import { isRecord } from "./record.js";
|
|
6
|
+
import { declaredScannerRepositoryUrl } from "./scanner-repository-url.js";
|
|
7
|
+
// Our minimum Node runtime provides source-aware JSON parsing. Our SDK targets ES2022 types.
|
|
8
|
+
const wireJson = JSON;
|
|
9
|
+
export function hostedNumberToken(value) {
|
|
10
|
+
return wireJson.isRawJSON(value) ? value.rawJSON : undefined;
|
|
11
|
+
}
|
|
12
|
+
/** Store native evidence by exact numeric value, independently of its wire spelling. */
|
|
13
|
+
export function stringifyHostedEvidence(value) {
|
|
14
|
+
return JSON.stringify(value, (_key, field) => wireJson.isRawJSON(field)
|
|
15
|
+
? wireJson.rawJSON(canonicalNumber(field.rawJSON))
|
|
16
|
+
: field);
|
|
17
|
+
}
|
|
18
|
+
/** Keep vendor numeric IDs and evidence exact when a response is saved as JSON. */
|
|
19
|
+
export function parseHostedScannerJson(source) {
|
|
20
|
+
return JSON.parse(source, (_key, value, context) => {
|
|
21
|
+
if (typeof value === "number")
|
|
22
|
+
return wireJson.rawJSON(context.source);
|
|
23
|
+
// Identical vendor evidence can arrive with a different member order on replay.
|
|
24
|
+
return isRecord(value)
|
|
25
|
+
? Object.fromEntries(Object.keys(value)
|
|
26
|
+
.sort()
|
|
27
|
+
.map((key) => [key, value[key]]))
|
|
28
|
+
: value;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export function hostedRepositoryUrl(value, label) {
|
|
32
|
+
// Hosted Git URLs retain %23 and %3F as path bytes; a literal query or fragment is rejected.
|
|
33
|
+
return declaredScannerRepositoryUrl(value, label, "local", {
|
|
34
|
+
allowEncodedQueryAndFragment: true,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/** Normalize the provider's HTTP or independently identified SSH repository address. */
|
|
38
|
+
export function hostedNativeRepositoryUrl(value, label, additionalGitHost) {
|
|
39
|
+
const source = additionalGitHost ? `https://${additionalGitHost}` : undefined;
|
|
40
|
+
const normalized = typeof value === "string" && value.trim() === value
|
|
41
|
+
? normalizeHostedGitRepositoryUrl(value, source, source !== undefined)
|
|
42
|
+
: value;
|
|
43
|
+
return hostedRepositoryUrl(normalized, label);
|
|
44
|
+
}
|
|
45
|
+
export function scannerEnvironmentValue(environment, requested) {
|
|
46
|
+
const exact = environment[requested];
|
|
47
|
+
if (process.platform !== "win32")
|
|
48
|
+
return exact;
|
|
49
|
+
// A scan can override a case-insensitive process.env with its own spelling.
|
|
50
|
+
function callerDeclares(key) {
|
|
51
|
+
for (let owner = environment; owner && owner !== process.env; owner = Object.getPrototypeOf(owner)) {
|
|
52
|
+
if (Object.hasOwn(owner, key))
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
if (exact !== undefined && callerDeclares(requested))
|
|
58
|
+
return exact;
|
|
59
|
+
// Node includes enumerable prototype keys and sorts competing spellings.
|
|
60
|
+
const keys = [];
|
|
61
|
+
for (const name in environment) {
|
|
62
|
+
if (name.toUpperCase() === requested)
|
|
63
|
+
keys.push(name);
|
|
64
|
+
}
|
|
65
|
+
keys.sort();
|
|
66
|
+
const key = keys.find(callerDeclares) ?? keys[0];
|
|
67
|
+
if (key !== undefined)
|
|
68
|
+
return key === requested ? exact : environment[key];
|
|
69
|
+
}
|
|
70
|
+
/** Use the selected vendor credential only with its configured service origin. */
|
|
71
|
+
export function hostedScannerToken(environment, tokenName, explicitToken, origin, ...originNames) {
|
|
72
|
+
const token = explicitToken ?? scannerEnvironmentValue(environment, tokenName);
|
|
73
|
+
if (token) {
|
|
74
|
+
for (const name of originNames) {
|
|
75
|
+
const configured = scannerEnvironmentValue(environment, name);
|
|
76
|
+
if (!configured)
|
|
77
|
+
continue;
|
|
78
|
+
if (URL.parse(configured)?.origin !== origin)
|
|
79
|
+
throw new Error(`${name} does not match ${origin}. Select a matching API origin and ${tokenName} before collecting findings.`);
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return token;
|
|
84
|
+
}
|
|
85
|
+
function httpDate(hint, now) {
|
|
86
|
+
const normalized = hint.replace("23:59:60", "23:59:59");
|
|
87
|
+
const leapSecond = normalized === hint ? 0 : 1000;
|
|
88
|
+
let canonical = normalized;
|
|
89
|
+
const asctime = /^(\w{3}) (\w{3}) ( \d|\d{2}) (\d{2}:\d{2}:\d{2}) (\d{4})$/u.exec(normalized);
|
|
90
|
+
const rfc850 = /^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d{2})-(\w{3})-(\d{2}) (\d{2}:\d{2}:\d{2}) GMT$/u.exec(normalized);
|
|
91
|
+
if (asctime) {
|
|
92
|
+
const [, weekday, month, day, time, year] = asctime;
|
|
93
|
+
canonical = `${weekday}, ${day.replace(" ", "0")} ${month} ${year} ${time} GMT`;
|
|
94
|
+
}
|
|
95
|
+
else if (rfc850) {
|
|
96
|
+
const [, weekday, day, month, year, time] = rfc850;
|
|
97
|
+
const cutoff = new Date(now);
|
|
98
|
+
cutoff.setUTCFullYear(cutoff.getUTCFullYear() + 50);
|
|
99
|
+
const century = Math.floor(cutoff.getUTCFullYear() / 100) * 100;
|
|
100
|
+
const dateIn = (century) => `${weekday.slice(0, 3)}, ${day} ${month} ${century + Number(year)} ${time} GMT`;
|
|
101
|
+
canonical = dateIn(century);
|
|
102
|
+
if (Date.parse(canonical) + leapSecond > cutoff.getTime())
|
|
103
|
+
canonical = dateIn(century - 100);
|
|
104
|
+
}
|
|
105
|
+
const date = new Date(canonical);
|
|
106
|
+
if (leapSecond && new Date(date.getTime() + leapSecond).getUTCDate() !== 1)
|
|
107
|
+
return NaN;
|
|
108
|
+
return canonical.length === 29 && date.toUTCString() === canonical
|
|
109
|
+
? date.getTime() + leapSecond
|
|
110
|
+
: NaN;
|
|
111
|
+
}
|
|
112
|
+
function retryAfterMs(response) {
|
|
113
|
+
if (response.status !== 429)
|
|
114
|
+
return;
|
|
115
|
+
const hint = response.headers.get("retry-after");
|
|
116
|
+
if (!hint)
|
|
117
|
+
return;
|
|
118
|
+
let delay;
|
|
119
|
+
if (/^\d+$/u.test(hint)) {
|
|
120
|
+
delay = Number(hint) * 1000;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
const now = Date.now();
|
|
124
|
+
const serverDate = httpDate(response.headers.get("date") ?? "", now);
|
|
125
|
+
const reference = Number.isNaN(serverDate) ? now : serverDate;
|
|
126
|
+
delay = Math.max(0, httpDate(hint, reference) - reference);
|
|
127
|
+
}
|
|
128
|
+
return delay <= 10_000 ? delay : undefined;
|
|
129
|
+
}
|
|
130
|
+
// A proxy's failure page can be arbitrarily large, including when chunked or compressed.
|
|
131
|
+
// Bound only the remote diagnostic; successful vendor findings use the normal parser.
|
|
132
|
+
const HTTP_ERROR_DETAIL_BYTES = 64 * 1024;
|
|
133
|
+
async function scannerHttpError(url, response, signal) {
|
|
134
|
+
const retry = response.headers.get("retry-after");
|
|
135
|
+
const status = `GET ${url.origin}${url.pathname} failed (HTTP ${response.status})${retry ? `; Retry-After: ${retry}` : ""}`;
|
|
136
|
+
const reader = response.body?.getReader();
|
|
137
|
+
if (!reader)
|
|
138
|
+
return new CodexSecurityError(`${status}.`);
|
|
139
|
+
const decoder = new TextDecoder();
|
|
140
|
+
let remaining = HTTP_ERROR_DETAIL_BYTES;
|
|
141
|
+
let detail = "";
|
|
142
|
+
try {
|
|
143
|
+
for (;;) {
|
|
144
|
+
const { done, value } = await reader.read();
|
|
145
|
+
if (done) {
|
|
146
|
+
detail += decoder.decode();
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
const prefix = value.subarray(0, remaining);
|
|
150
|
+
detail += decoder.decode(prefix, { stream: true });
|
|
151
|
+
remaining -= prefix.byteLength;
|
|
152
|
+
if (prefix.byteLength < value.byteLength) {
|
|
153
|
+
void reader.cancel().catch(() => undefined);
|
|
154
|
+
detail += `\nShowing the first ${HTTP_ERROR_DETAIL_BYTES} bytes of the error response.`;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch (cause) {
|
|
160
|
+
signal?.throwIfAborted();
|
|
161
|
+
const received = detail ? `: ${detail}` : "";
|
|
162
|
+
return new CodexSecurityError(`${status}${received}\nReading the error response failed: ${errorMessage(cause)}`, { cause });
|
|
163
|
+
}
|
|
164
|
+
finally {
|
|
165
|
+
reader.releaseLock();
|
|
166
|
+
}
|
|
167
|
+
return new CodexSecurityError(`${status}${detail ? `: ${detail}` : "."}`);
|
|
168
|
+
}
|
|
169
|
+
export function hostedScannerHttp(dependencies, callerSignal) {
|
|
170
|
+
const { signal: transportSignal } = dependencies;
|
|
171
|
+
const signal = callerSignal && transportSignal
|
|
172
|
+
? AbortSignal.any([callerSignal, transportSignal])
|
|
173
|
+
: (callerSignal ?? transportSignal);
|
|
174
|
+
signal?.throwIfAborted();
|
|
175
|
+
const request = dependencies.fetch?.bind(dependencies) ?? fetch;
|
|
176
|
+
async function getJson(url, authorization) {
|
|
177
|
+
signal?.throwIfAborted();
|
|
178
|
+
if (/[\0\r\n]/u.test(authorization))
|
|
179
|
+
throw new Error("Scanner API token cannot contain a NUL or line break.");
|
|
180
|
+
const get = () => request(new URL(url), {
|
|
181
|
+
method: "GET",
|
|
182
|
+
headers: {
|
|
183
|
+
accept: "application/vnd.api+json, application/json",
|
|
184
|
+
authorization,
|
|
185
|
+
},
|
|
186
|
+
redirect: "error",
|
|
187
|
+
signal,
|
|
188
|
+
});
|
|
189
|
+
let response = await get();
|
|
190
|
+
const delay = retryAfterMs(response);
|
|
191
|
+
if (delay !== undefined) {
|
|
192
|
+
void response.body?.cancel().catch(() => undefined);
|
|
193
|
+
if (delay > 0)
|
|
194
|
+
await waitForRetry(delay, signal);
|
|
195
|
+
signal?.throwIfAborted();
|
|
196
|
+
response = await get();
|
|
197
|
+
}
|
|
198
|
+
if (!response.ok)
|
|
199
|
+
throw await scannerHttpError(url, response, signal);
|
|
200
|
+
return parseHostedScannerJson(new TextDecoder("utf-8", { fatal: true }).decode(await response.arrayBuffer()));
|
|
201
|
+
}
|
|
202
|
+
return { signal, getJson };
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=hosted-scanner-http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-scanner-http.js","sourceRoot":"","sources":["../src/hosted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AC,CAAC,MAAM,CAC9C,MAAM,QAAQ,CAAC,WAAW,EAAE,CAC7B,CACF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["import { waitForRetry } from \"./deduplication/retry.js\";\nimport { canonicalNumber } from \"./external-import-contract.js\";\nimport { CodexSecurityError, errorMessage } from \"./errors.js\";\nimport { normalizeHostedGitRepositoryUrl } from \"./hosted-git-repository.js\";\nimport { isRecord } from \"./record.js\";\nimport { declaredScannerRepositoryUrl } from \"./scanner-repository-url.js\";\n\nexport interface HostedScannerHttpOptions {\n environment?: NodeJS.ProcessEnv;\n fetch?: (url: URL, init: RequestInit) => Promise<Response>;\n signal?: AbortSignal;\n}\n\n// Our minimum Node runtime provides source-aware JSON parsing. Our SDK targets ES2022 types.\nconst wireJson = JSON as JSON & {\n rawJSON(source: string): { rawJSON: string };\n isRawJSON(value: unknown): value is { rawJSON: string };\n};\nexport function hostedNumberToken(value: unknown): string | undefined {\n return wireJson.isRawJSON(value) ? value.rawJSON : undefined;\n}\n\n/** Store native evidence by exact numeric value, independently of its wire spelling. */\nexport function stringifyHostedEvidence(value: unknown): string {\n return JSON.stringify(value, (_key, field: unknown) =>\n wireJson.isRawJSON(field)\n ? wireJson.rawJSON(canonicalNumber(field.rawJSON))\n : field,\n );\n}\n\n/** Keep vendor numeric IDs and evidence exact when a response is saved as JSON. */\nexport function parseHostedScannerJson(source: string): unknown {\n return JSON.parse(\n source,\n (_key: string, value: unknown, context?: { source?: string }) => {\n if (typeof value === \"number\") return wireJson.rawJSON(context!.source!);\n // Identical vendor evidence can arrive with a different member order on replay.\n return isRecord(value)\n ? Object.fromEntries(\n Object.keys(value)\n .sort()\n .map((key) => [key, value[key]]),\n )\n : value;\n },\n );\n}\n\nexport function hostedRepositoryUrl(value: unknown, label: string): string {\n // Hosted Git URLs retain %23 and %3F as path bytes; a literal query or fragment is rejected.\n return declaredScannerRepositoryUrl(value, label, \"local\", {\n allowEncodedQueryAndFragment: true,\n });\n}\n\n/** Normalize the provider's HTTP or independently identified SSH repository address. */\nexport function hostedNativeRepositoryUrl(\n value: unknown,\n label: string,\n additionalGitHost?: string,\n): string {\n const source = additionalGitHost ? `https://${additionalGitHost}` : undefined;\n const normalized =\n typeof value === \"string\" && value.trim() === value\n ? normalizeHostedGitRepositoryUrl(value, source, source !== undefined)\n : value;\n return hostedRepositoryUrl(normalized, label);\n}\n\nexport function scannerEnvironmentValue(\n environment: NodeJS.ProcessEnv,\n requested: string,\n) {\n const exact = environment[requested];\n if (process.platform !== \"win32\") return exact;\n // A scan can override a case-insensitive process.env with its own spelling.\n function callerDeclares(key: string): boolean {\n for (\n let owner: object | null = environment;\n owner && owner !== process.env;\n owner = Object.getPrototypeOf(owner)\n ) {\n if (Object.hasOwn(owner, key)) return true;\n }\n return false;\n }\n if (exact !== undefined && callerDeclares(requested)) return exact;\n // Node includes enumerable prototype keys and sorts competing spellings.\n const keys: string[] = [];\n for (const name in environment) {\n if (name.toUpperCase() === requested) keys.push(name);\n }\n keys.sort();\n const key = keys.find(callerDeclares) ?? keys[0];\n if (key !== undefined) return key === requested ? exact : environment[key];\n}\n\n/** Use the selected vendor credential only with its configured service origin. */\nexport function hostedScannerToken(\n environment: NodeJS.ProcessEnv,\n tokenName: string,\n explicitToken: string | undefined,\n origin: string,\n ...originNames: string[]\n): string | undefined {\n const token =\n explicitToken ?? scannerEnvironmentValue(environment, tokenName);\n if (token) {\n for (const name of originNames) {\n const configured = scannerEnvironmentValue(environment, name);\n if (!configured) continue;\n if (URL.parse(configured)?.origin !== origin)\n throw new Error(\n `${name} does not match ${origin}. Select a matching API origin and ${tokenName} before collecting findings.`,\n );\n break;\n }\n }\n return token;\n}\n\nfunction httpDate(hint: string, now: number): number {\n const normalized = hint.replace(\"23:59:60\", \"23:59:59\");\n const leapSecond = normalized === hint ? 0 : 1000;\n let canonical = normalized;\n const asctime =\n /^(\\w{3}) (\\w{3}) ( \\d|\\d{2}) (\\d{2}:\\d{2}:\\d{2}) (\\d{4})$/u.exec(\n normalized,\n );\n const rfc850 =\n /^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\\d{2})-(\\w{3})-(\\d{2}) (\\d{2}:\\d{2}:\\d{2}) GMT$/u.exec(\n normalized,\n );\n if (asctime) {\n const [, weekday, month, day, time, year] = asctime;\n canonical = `${weekday}, ${day!.replace(\" \", \"0\")} ${month} ${year} ${time} GMT`;\n } else if (rfc850) {\n const [, weekday, day, month, year, time] = rfc850;\n const cutoff = new Date(now);\n cutoff.setUTCFullYear(cutoff.getUTCFullYear() + 50);\n const century = Math.floor(cutoff.getUTCFullYear() / 100) * 100;\n const dateIn = (century: number) =>\n `${weekday!.slice(0, 3)}, ${day} ${month} ${century + Number(year)} ${time} GMT`;\n canonical = dateIn(century);\n if (Date.parse(canonical) + leapSecond > cutoff.getTime())\n canonical = dateIn(century - 100);\n }\n const date = new Date(canonical);\n if (leapSecond && new Date(date.getTime() + leapSecond).getUTCDate() !== 1)\n return NaN;\n return canonical.length === 29 && date.toUTCString() === canonical\n ? date.getTime() + leapSecond\n : NaN;\n}\n\nfunction retryAfterMs(response: Response): number | undefined {\n if (response.status !== 429) return;\n const hint = response.headers.get(\"retry-after\");\n if (!hint) return;\n let delay: number;\n if (/^\\d+$/u.test(hint)) {\n delay = Number(hint) * 1000;\n } else {\n const now = Date.now();\n const serverDate = httpDate(response.headers.get(\"date\") ?? \"\", now);\n const reference = Number.isNaN(serverDate) ? now : serverDate;\n delay = Math.max(0, httpDate(hint, reference) - reference);\n }\n return delay <= 10_000 ? delay : undefined;\n}\n\n// A proxy's failure page can be arbitrarily large, including when chunked or compressed.\n// Bound only the remote diagnostic; successful vendor findings use the normal parser.\nconst HTTP_ERROR_DETAIL_BYTES = 64 * 1024;\n\nasync function scannerHttpError(\n url: URL,\n response: Response,\n signal?: AbortSignal,\n) {\n const retry = response.headers.get(\"retry-after\");\n const status = `GET ${url.origin}${url.pathname} failed (HTTP ${response.status})${retry ? `; Retry-After: ${retry}` : \"\"}`;\n const reader = response.body?.getReader();\n if (!reader) return new CodexSecurityError(`${status}.`);\n const decoder = new TextDecoder();\n let remaining = HTTP_ERROR_DETAIL_BYTES;\n let detail = \"\";\n try {\n for (;;) {\n const { done, value } = await reader.read();\n if (done) {\n detail += decoder.decode();\n break;\n }\n const prefix = value.subarray(0, remaining);\n detail += decoder.decode(prefix, { stream: true });\n remaining -= prefix.byteLength;\n if (prefix.byteLength < value.byteLength) {\n void reader.cancel().catch(() => undefined);\n detail += `\\nShowing the first ${HTTP_ERROR_DETAIL_BYTES} bytes of the error response.`;\n break;\n }\n }\n } catch (cause) {\n signal?.throwIfAborted();\n const received = detail ? `: ${detail}` : \"\";\n return new CodexSecurityError(\n `${status}${received}\\nReading the error response failed: ${errorMessage(cause)}`,\n { cause },\n );\n } finally {\n reader.releaseLock();\n }\n return new CodexSecurityError(`${status}${detail ? `: ${detail}` : \".\"}`);\n}\n\nexport function hostedScannerHttp(\n dependencies: HostedScannerHttpOptions,\n callerSignal?: AbortSignal,\n) {\n const { signal: transportSignal } = dependencies;\n const signal =\n callerSignal && transportSignal\n ? AbortSignal.any([callerSignal, transportSignal])\n : (callerSignal ?? transportSignal);\n signal?.throwIfAborted();\n const request = dependencies.fetch?.bind(dependencies) ?? fetch;\n async function getJson(url: URL, authorization: string): Promise<unknown> {\n signal?.throwIfAborted();\n if (/[\\0\\r\\n]/u.test(authorization))\n throw new Error(\"Scanner API token cannot contain a NUL or line break.\");\n const get = () =>\n request(new URL(url), {\n method: \"GET\",\n headers: {\n accept: \"application/vnd.api+json, application/json\",\n authorization,\n },\n redirect: \"error\",\n signal,\n });\n let response = await get();\n const delay = retryAfterMs(response);\n if (delay !== undefined) {\n void response.body?.cancel().catch(() => undefined);\n if (delay > 0) await waitForRetry(delay, signal);\n signal?.throwIfAborted();\n response = await get();\n }\n if (!response.ok) throw await scannerHttpError(url, response, signal);\n return parseHostedScannerJson(\n new TextDecoder(\"utf-8\", { fatal: true }).decode(\n await response.arrayBuffer(),\n ),\n );\n }\n return { signal, getJson };\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function legacyDecimalInteger(token: string): string | undefined;
|
|
2
|
+
/** A legacy export needs a type witness when JSON.parse cannot preserve a decimal. */
|
|
3
|
+
export declare function isLegacyWitness(token: string): boolean;
|
|
4
|
+
/** Original hosted exports saved imprecise JSON numbers as text plus a sparse type witness. */
|
|
5
|
+
export declare function restoreLegacyHostedNumbers(document: Record<string, unknown>): Record<string, unknown>;
|
|
6
|
+
//# sourceMappingURL=hosted-scanner-v1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-scanner-v1.d.ts","sourceRoot":"","sources":["../src/hosted-scanner-v1.ts"],"names":[],"mappings":"AASA,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAUtE;AAED,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAWtD;AAyBD,+FAA+F;AAC/F,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMzB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { canonicalNumber } from "./external-import-contract.js";
|
|
2
|
+
import { hostedNumberToken, parseHostedScannerJson, } from "./hosted-scanner-http.js";
|
|
3
|
+
import { isRecord } from "./record.js";
|
|
4
|
+
const jsonNumber = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:e[+-]?\d+)?$/iu;
|
|
5
|
+
export function legacyDecimalInteger(token) {
|
|
6
|
+
if (!jsonNumber.test(token))
|
|
7
|
+
return;
|
|
8
|
+
const value = Number(token);
|
|
9
|
+
// Rule out unbounded exponents cheaply. Rounded boundary values still need an exact check.
|
|
10
|
+
if (!Number.isInteger(value) || value < 1 || value > 2 ** 63)
|
|
11
|
+
return;
|
|
12
|
+
const id = canonicalNumber(token);
|
|
13
|
+
return /^[1-9]\d{0,18}$/u.test(id) &&
|
|
14
|
+
(id.length < 19 || id <= "9223372036854775807")
|
|
15
|
+
? id
|
|
16
|
+
: undefined;
|
|
17
|
+
}
|
|
18
|
+
/** A legacy export needs a type witness when JSON.parse cannot preserve a decimal. */
|
|
19
|
+
export function isLegacyWitness(token) {
|
|
20
|
+
if (!jsonNumber.test(token))
|
|
21
|
+
return false;
|
|
22
|
+
const value = Number(token);
|
|
23
|
+
if (!Number.isFinite(value) ||
|
|
24
|
+
(Number.isInteger(value) && !Number.isSafeInteger(value)))
|
|
25
|
+
return true;
|
|
26
|
+
// Distinguish zero from underflow without converting an unbounded exponent.
|
|
27
|
+
if (value === 0)
|
|
28
|
+
return /[1-9]/u.test(token.split(/e/iu, 1)[0]);
|
|
29
|
+
return canonicalNumber(token) !== String(value);
|
|
30
|
+
}
|
|
31
|
+
function restoreField(value, witness) {
|
|
32
|
+
if (typeof witness === "string") {
|
|
33
|
+
if (value !== witness || !isLegacyWitness(witness))
|
|
34
|
+
throw new Error("Invalid exact scanner number.");
|
|
35
|
+
return parseHostedScannerJson(witness);
|
|
36
|
+
}
|
|
37
|
+
if (!isRecord(witness) ||
|
|
38
|
+
hostedNumberToken(witness) !== undefined ||
|
|
39
|
+
(!Array.isArray(value) &&
|
|
40
|
+
(!isRecord(value) || hostedNumberToken(value) !== undefined)))
|
|
41
|
+
throw new Error("Invalid scanner numeric fields.");
|
|
42
|
+
const restored = Array.isArray(value) ? [...value] : { ...value };
|
|
43
|
+
const fields = restored;
|
|
44
|
+
for (const [key, child] of Object.entries(witness)) {
|
|
45
|
+
if (!Object.hasOwn(restored, key))
|
|
46
|
+
throw new Error("Invalid scanner numeric field.");
|
|
47
|
+
fields[key] = restoreField(fields[key], child);
|
|
48
|
+
}
|
|
49
|
+
return restored;
|
|
50
|
+
}
|
|
51
|
+
/** Original hosted exports saved imprecise JSON numbers as text plus a sparse type witness. */
|
|
52
|
+
export function restoreLegacyHostedNumbers(document) {
|
|
53
|
+
const fields = document["numericFields"];
|
|
54
|
+
if (fields === undefined)
|
|
55
|
+
return document;
|
|
56
|
+
if (!isRecord(fields) || Object.hasOwn(fields, "numericFields"))
|
|
57
|
+
throw new Error("Invalid scanner numeric fields.");
|
|
58
|
+
return restoreField(document, fields);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=hosted-scanner-v1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-scanner-v1.js","sourceRoot":"","sources":["../src/hosted-scanner-v1.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,UAAU,GAAG,8CAA8C,CAAC;AAElE,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO;IACpC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,2FAA2F;IAC3F,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,EAAE;QAAE,OAAO;IACrE,MAAM,EAAE,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IAClC,OAAO,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,CAAC,EAAE,CAAC,MAAM,GAAG,EAAE,IAAI,EAAE,IAAI,qBAAqB,CAAC;QAC/C,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,eAAe,CAAC,KAAa;I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CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;IAClE,MAAM,MAAM,GAAG,QAAmC,CAAC;IACnD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACpD,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,0BAA0B,CACxC,QAAiC;IAEjC,MAAM,MAAM,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAC;IACzC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IAC1C,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;QAC7D,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,OAAO,YAAY,CAAC,QAAQ,EAAE,MAAM,CAA4B,CAAC;AACnE,CAAC","sourcesContent":["import { canonicalNumber } from \"./external-import-contract.js\";\nimport {\n hostedNumberToken,\n parseHostedScannerJson,\n} from \"./hosted-scanner-http.js\";\nimport { isRecord } from \"./record.js\";\n\nconst jsonNumber = /^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:e[+-]?\\d+)?$/iu;\n\nexport function legacyDecimalInteger(token: string): string | undefined {\n if (!jsonNumber.test(token)) return;\n const value = Number(token);\n // Rule out unbounded exponents cheaply. Rounded boundary values still need an exact check.\n if (!Number.isInteger(value) || value < 1 || value > 2 ** 63) return;\n const id = canonicalNumber(token);\n return /^[1-9]\\d{0,18}$/u.test(id) &&\n (id.length < 19 || id <= \"9223372036854775807\")\n ? id\n : undefined;\n}\n\n/** A legacy export needs a type witness when JSON.parse cannot preserve a decimal. */\nexport function isLegacyWitness(token: string): boolean {\n if (!jsonNumber.test(token)) return false;\n const value = Number(token);\n if (\n !Number.isFinite(value) ||\n (Number.isInteger(value) && !Number.isSafeInteger(value))\n )\n return true;\n // Distinguish zero from underflow without converting an unbounded exponent.\n if (value === 0) return /[1-9]/u.test(token.split(/e/iu, 1)[0]!);\n return canonicalNumber(token) !== String(value);\n}\n\nfunction restoreField(value: unknown, witness: unknown): unknown {\n if (typeof witness === \"string\") {\n if (value !== witness || !isLegacyWitness(witness))\n throw new Error(\"Invalid exact scanner number.\");\n return parseHostedScannerJson(witness);\n }\n if (\n !isRecord(witness) ||\n hostedNumberToken(witness) !== undefined ||\n (!Array.isArray(value) &&\n (!isRecord(value) || hostedNumberToken(value) !== undefined))\n )\n throw new Error(\"Invalid scanner numeric fields.\");\n const restored = Array.isArray(value) ? [...value] : { ...value };\n const fields = restored as Record<string, unknown>;\n for (const [key, child] of Object.entries(witness)) {\n if (!Object.hasOwn(restored, key))\n throw new Error(\"Invalid scanner numeric field.\");\n fields[key] = restoreField(fields[key], child);\n }\n return restored;\n}\n\n/** Original hosted exports saved imprecise JSON numbers as text plus a sparse type witness. */\nexport function restoreLegacyHostedNumbers(\n document: Record<string, unknown>,\n): Record<string, unknown> {\n const fields = document[\"numericFields\"];\n if (fields === undefined) return document;\n if (!isRecord(fields) || Object.hasOwn(fields, \"numericFields\"))\n throw new Error(\"Invalid scanner numeric fields.\");\n return restoreField(document, fields) as Record<string, unknown>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-scan.d.ts","sourceRoot":"","sources":["../src/import-scan.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAWvD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAYL,m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 +18,7 @@ import { CodexSecurityError, ScanInterruptedError, errorMessage, } from "./error
|
|
|
18
18
|
import { bindImportedFindings, parseImportedFindings, } from "./findings-import.js";
|
|
19
19
|
import { ScanResult } from "./result.js";
|
|
20
20
|
import { bundledPluginRoot, cleanupSdkDirectory, codexSecurityStateDirectory, expandHome, pluginMetadata, prepareScanRegistrationOutput, preparePersistentOutputRoot, requireOutputOutsideRepository, requirePrivateOutputDirectory, requireSecureOutputAncestry, resolvePluginPath, resolvePluginPython, runWorkbench, validateOutputDir, } from "./runtime.js";
|
|
21
|
+
import { VERSION } from "./version.js";
|
|
21
22
|
const IMPORT_DESCRIPTION = "Imported findings; no security analysis was performed. Coverage is unknown. Source locations describe the imported reports.";
|
|
22
23
|
async function readImportSource(inputPath, signal) {
|
|
23
24
|
signal?.throwIfAborted();
|
|
@@ -138,6 +139,8 @@ export async function importScan(options, dependencies = {}) {
|
|
|
138
139
|
archiveExisting: Boolean(options.archiveExisting),
|
|
139
140
|
parentScanId: options.parentScanId,
|
|
140
141
|
}), JSON.stringify({
|
|
142
|
+
surface: "cli",
|
|
143
|
+
packageVersion: VERSION,
|
|
141
144
|
recipe: {
|
|
142
145
|
repository,
|
|
143
146
|
target: { kind: "repository", paths: [] },
|
package/dist/import-scan.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-scan.js","sourceRoot":"","sources":["../src/import-scan.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,Q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,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE;gBAC5D,WAAW;gBACX,WAAW;gBACX,UAAU,CAAC,EAAE;gBACb,aAAa,YAAY,CAAC,KAAK,CAAC,EAAE;aACnC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC;QACD,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,oBAAoB,CAC5B,wCAAwC,EACxC,OAAO,EACP,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,MAAM,mBAAmB,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YAC5D,KAAK,OAAO,CAAC,OAAO,EAAE;iBACnB,IAAI,CAAC,GAAG,EAAE,CACT,YAAY,CAAC,SAAS,EAAE,CACtB,uDAAuD,YAAY,CAAC,KAAK,CAAC,EAAE,CAC7E,CACF;iBACA,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import { workbenchArgs } from \"./workbench-arguments.js\";\nimport { createHash } from \"node:crypto\";\nimport { constants } from \"node:fs\";\nimport {\n lstat,\n mkdir,\n mkdtemp,\n open,\n readFile,\n realpath,\n writeFile,\n} from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { CodexSecurityConfig } from \"./config.js\";\nimport { loadContract, sameCheckedFileDevice } from \"./contract.js\";\nimport {\n CodexSecurityError,\n ScanInterruptedError,\n errorMessage,\n} from \"./errors.js\";\nimport {\n bindImportedFindings,\n parseImportedFindings,\n} from \"./findings-import.js\";\nimport { ScanResult } from \"./result.js\";\nimport {\n bundledPluginRoot,\n cleanupSdkDirectory,\n codexSecurityStateDirectory,\n expandHome,\n pluginMetadata,\n prepareScanRegistrationOutput,\n preparePersistentOutputRoot,\n requireOutputOutsideRepository,\n requirePrivateOutputDirectory,\n requireSecureOutputAncestry,\n resolvePluginPath,\n resolvePluginPython,\n runWorkbench,\n validateOutputDir,\n type ProcessEnvironment,\n type WorkbenchCommandOptions,\n} from \"./runtime.js\";\n\nexport interface ImportScanOptions {\n sourcePath: string;\n format: \"csv\" | \"json\";\n config?: CodexSecurityConfig;\n outputDir?: string;\n archiveExisting?: boolean;\n dryRun?: boolean;\n parentScanId?: string;\n signal?: AbortSignal;\n}\n\nexport interface ImportScanPreview {\n dryRun: true;\n inputPath: string;\n format: \"csv\" | \"json\";\n findingCount: number;\n}\n\nexport interface ImportScanDependencies {\n environment?: ProcessEnvironment;\n runWorkbench?: typeof runWorkbench;\n resolvePluginPython?: typeof resolvePluginPython;\n onWarning?: (warning: string) => void;\n}\n\nconst IMPORT_DESCRIPTION =\n \"Imported findings; no security analysis was performed. Coverage is unknown. Source locations describe the imported reports.\";\n\nasync function readImportSource(\n inputPath: string,\n signal?: AbortSignal,\n): Promise<Buffer> {\n signal?.throwIfAborted();\n const selected = await lstat(inputPath, { bigint: true });\n if (!selected.isFile()) {\n throw new CodexSecurityError(\"Import source must be a regular file.\");\n }\n for (let parent = dirname(inputPath); ; parent = dirname(parent)) {\n signal?.throwIfAborted();\n if ((await lstat(parent)).isSymbolicLink()) {\n throw new CodexSecurityError(\n \"Import source must not traverse directory links. Use the direct filesystem path.\",\n );\n }\n if (dirname(parent) === parent) break;\n }\n const path = join(await realpath(dirname(inputPath)), basename(inputPath));\n const file = await open(\n path,\n constants.O_RDONLY |\n (constants.O_NOFOLLOW ?? 0) |\n (constants.O_NONBLOCK ?? 0),\n );\n try {\n signal?.throwIfAborted();\n const opened = await file.stat({ bigint: true });\n const current = await lstat(path, { bigint: true });\n if (\n !opened.isFile() ||\n !current.isFile() ||\n current.dev !== selected.dev ||\n current.ino !== selected.ino ||\n !(await sameCheckedFileDevice(file, { path, metadata: selected }, opened))\n ) {\n throw new CodexSecurityError(\n \"Import source must remain the selected regular file.\",\n );\n }\n return await file.readFile({ signal });\n } finally {\n await file.close();\n }\n}\n\n/** Save supplied findings through the normal scan completion and indexing flow. */\nexport async function importScan(\n options: ImportScanOptions,\n dependencies: ImportScanDependencies = {},\n): Promise<ScanResult | ImportScanPreview> {\n const { signal } = options;\n const environment = dependencies.environment ?? process.env;\n const inputPath = resolve(expandHome(options.sourcePath, environment));\n const source = await readImportSource(inputPath, signal);\n const workspace = await mkdtemp(\n join(await realpath(tmpdir()), \"codex-security-import-\"),\n );\n const workbench = dependencies.runWorkbench ?? runWorkbench;\n let activeScan: { id: string; options: WorkbenchCommandOptions } | undefined;\n let scanDir = \"\";\n try {\n const pluginRoot = await resolvePluginPath(\n options.config?.pluginPath,\n workspace,\n signal,\n );\n const findings = await parseImportedFindings(\n new TextDecoder(\"utf-8\", { fatal: true }).decode(source),\n options.format,\n pluginRoot,\n );\n const helper = (\n await import(\n pathToFileURL(join(await bundledPluginRoot(), \"mcp/helpers.mjs\")).href\n )\n ).default;\n try {\n helper.parseCurrentFindings(\n findings.map((finding) => {\n // Import assigns new identities and retains source metadata as provenance.\n const { findingId, occurrenceId, fingerprints, writeup, ...content } =\n finding;\n return {\n ...content,\n provenance: { source: `${options.format}_import` },\n };\n }),\n );\n } catch (error) {\n throw new CodexSecurityError(\n `Imported findings do not match the current scan-draft finding contract: ${errorMessage(error)}`,\n { cause: error },\n );\n }\n signal?.throwIfAborted();\n await validateOutputDir(options.outputDir, options.archiveExisting);\n if (options.dryRun) {\n return {\n dryRun: true,\n inputPath,\n format: options.format,\n findingCount: findings.length,\n };\n }\n const plugin = await pluginMetadata(pluginRoot);\n const stateDirectory = codexSecurityStateDirectory(environment);\n const digest = createHash(\"sha256\")\n .update(options.format)\n .update(\"\\0\")\n .update(source)\n .digest(\"hex\");\n // A retained input directory is the scan target, independent of the caller's repository.\n const repository = await preparePersistentOutputRoot(\n stateDirectory,\n \"imports\",\n `${options.format}-${digest}`,\n );\n requirePrivateOutputDirectory(await lstat(repository), repository);\n await requireSecureOutputAncestry(repository);\n const sourcePath = join(repository, `source.${options.format}`);\n try {\n await writeFile(sourcePath, source, { flag: \"wx\", signal });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n if (!(await readFile(sourcePath, { signal })).equals(source)) {\n throw new CodexSecurityError(\"The retained import source has changed.\");\n }\n }\n const python = await (\n dependencies.resolvePluginPython ?? resolvePluginPython\n )({\n configuredPath: options.config?.pythonPath,\n environment,\n protectedRoot: repository,\n signal,\n });\n const outputRoot =\n options.outputDir === undefined\n ? await preparePersistentOutputRoot(stateDirectory, \"scans\", \"imports\")\n : undefined;\n scanDir = await prepareScanRegistrationOutput(\n options.outputDir,\n \"import\",\n outputRoot,\n (path) => requireOutputOutsideRepository(repository, path),\n options.archiveExisting,\n );\n const workbenchOptions: WorkbenchCommandOptions = {\n python,\n pluginRoot,\n environment: { ...environment, CODEX_SECURITY_STATE_DIR: stateDirectory },\n signal,\n failureMessage: \"Could not save the imported scan\",\n };\n signal?.throwIfAborted();\n const registration = await workbench(\n workbenchOptions,\n workbenchArgs(\"register-cli-scan\", {\n repository,\n scanDir,\n registrationJsonStdin: true,\n archiveExisting: Boolean(options.archiveExisting),\n parentScanId: options.parentScanId,\n }),\n JSON.stringify({\n recipe: {\n repository,\n target: { kind: \"repository\", paths: [] },\n mode: \"standard\",\n pluginVersion: plugin.version,\n config: {},\n import: { format: options.format, sourcePath },\n },\n }),\n );\n const scanId = registration[\"scanId\"];\n const targetId = registration[\"targetId\"];\n if (\n typeof scanId !== \"string\" ||\n typeof targetId !== \"string\" ||\n registration[\"scanDir\"] !== scanDir\n ) {\n throw new CodexSecurityError(\n \"The workbench returned an invalid import scan registration.\",\n );\n }\n activeScan = { id: scanId, options: workbenchOptions };\n signal?.throwIfAborted();\n const bound = bindImportedFindings(\n findings,\n options.format,\n scanId,\n targetId,\n );\n const sourceRef = `artifacts/import/source.${options.format}`;\n await mkdir(join(scanDir, \"artifacts\", \"import\"), { recursive: true });\n await writeFile(join(scanDir, sourceRef), source, { flag: \"wx\", signal });\n const documents: Record<string, unknown> = {\n \"scan-manifest.json\": {\n scan: {\n target: { kind: \"directory_snapshot\" },\n scope: {\n summary: IMPORT_DESCRIPTION,\n runtimeStatus: \"imported\",\n limitations: [IMPORT_DESCRIPTION],\n },\n mode: \"repository\",\n reviewState: {\n surfaces: findings.length\n ? [\n {\n id: \"import\",\n label: basename(inputPath),\n disposition: \"reported\",\n receiptRefs: [sourceRef],\n notes: IMPORT_DESCRIPTION,\n },\n ]\n : [],\n explicitExclusions: [],\n deferred: [],\n },\n extensions: {\n import: {\n format: options.format,\n sourceRef,\n findingCount: findings.length,\n },\n },\n },\n },\n \"findings.json\": { findings: bound },\n };\n for (const [name, document] of Object.entries(documents)) {\n await writeFile(\n join(scanDir, name),\n `${JSON.stringify(document, null, 2)}\\n`,\n { flag: \"wx\", signal },\n );\n }\n await workbench(\n workbenchOptions,\n workbenchArgs(\"prepare-scan-completion\", { scanId }),\n );\n // Finalization normally recovers partial output. An import must retain every supplied row.\n const contract = await loadContract(scanDir, {\n pluginRoot,\n expectedScanId: scanId,\n workbenchValidated: true,\n signal,\n });\n const expectedIds = new Set(bound.map((finding) => finding.findingId));\n if (\n contract.findings.findings.length !== findings.length ||\n contract.findings.findings.some(\n (finding) => !expectedIds.delete(finding.findingId),\n )\n ) {\n throw new CodexSecurityError(\n \"Import finalization did not preserve every input finding; the scan was not completed.\",\n );\n }\n await workbench(workbenchOptions, [\"complete-scan\", \"--scan-id\", scanId]);\n activeScan = undefined;\n return new ScanResult({\n ...contract,\n scanDir,\n threadId: \"\",\n turnResult: {\n status: \"completed\",\n imported: true,\n finalResponse: IMPORT_DESCRIPTION,\n },\n });\n } catch (error) {\n if (activeScan !== undefined) {\n await workbench({ ...activeScan.options, signal: undefined }, [\n \"fail-scan\",\n \"--scan-id\",\n activeScan.id,\n `--message=${errorMessage(error)}`,\n ]).catch(() => undefined);\n }\n if (signal?.aborted) {\n throw new ScanInterruptedError(\n \"Codex Security import was interrupted.\",\n scanDir,\n { cause: error },\n );\n }\n throw error;\n } finally {\n await cleanupSdkDirectory(workspace).catch((error: unknown) => {\n void Promise.resolve()\n .then(() =>\n dependencies.onWarning?.(\n `Could not clean up after the Codex Security import: ${errorMessage(error)}`,\n ),\n )\n .catch(() => {});\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"import-scan.js","sourceRoot":"","sources":["../src/import-scan.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAC3B,UAAU,EACV,cAAc,EACd,6BAA6B,EAC7B,2BAA2B,EAC3B,8BAA8B,EAC9B,6BAA6B,EAC7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AC;QACT,MAAM,mBAAmB,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YAC5D,KAAK,OAAO,CAAC,OAAO,EAAE;iBACnB,IAAI,CAAC,GAAG,EAAE,CACT,YAAY,CAAC,SAAS,EAAE,CACtB,uDAAuD,YAAY,CAAC,KAAK,CAAC,EAAE,CAC7E,CACF;iBACA,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import { workbenchArgs } from \"./workbench-arguments.js\";\nimport { createHash } from \"node:crypto\";\nimport { constants } from \"node:fs\";\nimport {\n lstat,\n mkdir,\n mkdtemp,\n open,\n readFile,\n realpath,\n writeFile,\n} from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { CodexSecurityConfig } from \"./config.js\";\nimport { loadContract, sameCheckedFileDevice } from \"./contract.js\";\nimport {\n CodexSecurityError,\n ScanInterruptedError,\n errorMessage,\n} from \"./errors.js\";\nimport {\n bindImportedFindings,\n parseImportedFindings,\n} from \"./findings-import.js\";\nimport { ScanResult } from \"./result.js\";\nimport {\n bundledPluginRoot,\n cleanupSdkDirectory,\n codexSecurityStateDirectory,\n expandHome,\n pluginMetadata,\n prepareScanRegistrationOutput,\n preparePersistentOutputRoot,\n requireOutputOutsideRepository,\n requirePrivateOutputDirectory,\n requireSecureOutputAncestry,\n resolvePluginPath,\n resolvePluginPython,\n runWorkbench,\n validateOutputDir,\n type ProcessEnvironment,\n type WorkbenchCommandOptions,\n} from \"./runtime.js\";\nimport { VERSION } from \"./version.js\";\n\nexport interface ImportScanOptions {\n sourcePath: string;\n format: \"csv\" | \"json\";\n config?: CodexSecurityConfig;\n outputDir?: string;\n archiveExisting?: boolean;\n dryRun?: boolean;\n parentScanId?: string;\n signal?: AbortSignal;\n}\n\nexport interface ImportScanPreview {\n dryRun: true;\n inputPath: string;\n format: \"csv\" | \"json\";\n findingCount: number;\n}\n\nexport interface ImportScanDependencies {\n environment?: ProcessEnvironment;\n runWorkbench?: typeof runWorkbench;\n resolvePluginPython?: typeof resolvePluginPython;\n onWarning?: (warning: string) => void;\n}\n\nconst IMPORT_DESCRIPTION =\n \"Imported findings; no security analysis was performed. Coverage is unknown. Source locations describe the imported reports.\";\n\nasync function readImportSource(\n inputPath: string,\n signal?: AbortSignal,\n): Promise<Buffer> {\n signal?.throwIfAborted();\n const selected = await lstat(inputPath, { bigint: true });\n if (!selected.isFile()) {\n throw new CodexSecurityError(\"Import source must be a regular file.\");\n }\n for (let parent = dirname(inputPath); ; parent = dirname(parent)) {\n signal?.throwIfAborted();\n if ((await lstat(parent)).isSymbolicLink()) {\n throw new CodexSecurityError(\n \"Import source must not traverse directory links. Use the direct filesystem path.\",\n );\n }\n if (dirname(parent) === parent) break;\n }\n const path = join(await realpath(dirname(inputPath)), basename(inputPath));\n const file = await open(\n path,\n constants.O_RDONLY |\n (constants.O_NOFOLLOW ?? 0) |\n (constants.O_NONBLOCK ?? 0),\n );\n try {\n signal?.throwIfAborted();\n const opened = await file.stat({ bigint: true });\n const current = await lstat(path, { bigint: true });\n if (\n !opened.isFile() ||\n !current.isFile() ||\n current.dev !== selected.dev ||\n current.ino !== selected.ino ||\n !(await sameCheckedFileDevice(file, { path, metadata: selected }, opened))\n ) {\n throw new CodexSecurityError(\n \"Import source must remain the selected regular file.\",\n );\n }\n return await file.readFile({ signal });\n } finally {\n await file.close();\n }\n}\n\n/** Save supplied findings through the normal scan completion and indexing flow. */\nexport async function importScan(\n options: ImportScanOptions,\n dependencies: ImportScanDependencies = {},\n): Promise<ScanResult | ImportScanPreview> {\n const { signal } = options;\n const environment = dependencies.environment ?? process.env;\n const inputPath = resolve(expandHome(options.sourcePath, environment));\n const source = await readImportSource(inputPath, signal);\n const workspace = await mkdtemp(\n join(await realpath(tmpdir()), \"codex-security-import-\"),\n );\n const workbench = dependencies.runWorkbench ?? runWorkbench;\n let activeScan: { id: string; options: WorkbenchCommandOptions } | undefined;\n let scanDir = \"\";\n try {\n const pluginRoot = await resolvePluginPath(\n options.config?.pluginPath,\n workspace,\n signal,\n );\n const findings = await parseImportedFindings(\n new TextDecoder(\"utf-8\", { fatal: true }).decode(source),\n options.format,\n pluginRoot,\n );\n const helper = (\n await import(\n pathToFileURL(join(await bundledPluginRoot(), \"mcp/helpers.mjs\")).href\n )\n ).default;\n try {\n helper.parseCurrentFindings(\n findings.map((finding) => {\n // Import assigns new identities and retains source metadata as provenance.\n const { findingId, occurrenceId, fingerprints, writeup, ...content } =\n finding;\n return {\n ...content,\n provenance: { source: `${options.format}_import` },\n };\n }),\n );\n } catch (error) {\n throw new CodexSecurityError(\n `Imported findings do not match the current scan-draft finding contract: ${errorMessage(error)}`,\n { cause: error },\n );\n }\n signal?.throwIfAborted();\n await validateOutputDir(options.outputDir, options.archiveExisting);\n if (options.dryRun) {\n return {\n dryRun: true,\n inputPath,\n format: options.format,\n findingCount: findings.length,\n };\n }\n const plugin = await pluginMetadata(pluginRoot);\n const stateDirectory = codexSecurityStateDirectory(environment);\n const digest = createHash(\"sha256\")\n .update(options.format)\n .update(\"\\0\")\n .update(source)\n .digest(\"hex\");\n // A retained input directory is the scan target, independent of the caller's repository.\n const repository = await preparePersistentOutputRoot(\n stateDirectory,\n \"imports\",\n `${options.format}-${digest}`,\n );\n requirePrivateOutputDirectory(await lstat(repository), repository);\n await requireSecureOutputAncestry(repository);\n const sourcePath = join(repository, `source.${options.format}`);\n try {\n await writeFile(sourcePath, source, { flag: \"wx\", signal });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n if (!(await readFile(sourcePath, { signal })).equals(source)) {\n throw new CodexSecurityError(\"The retained import source has changed.\");\n }\n }\n const python = await (\n dependencies.resolvePluginPython ?? resolvePluginPython\n )({\n configuredPath: options.config?.pythonPath,\n environment,\n protectedRoot: repository,\n signal,\n });\n const outputRoot =\n options.outputDir === undefined\n ? await preparePersistentOutputRoot(stateDirectory, \"scans\", \"imports\")\n : undefined;\n scanDir = await prepareScanRegistrationOutput(\n options.outputDir,\n \"import\",\n outputRoot,\n (path) => requireOutputOutsideRepository(repository, path),\n options.archiveExisting,\n );\n const workbenchOptions: WorkbenchCommandOptions = {\n python,\n pluginRoot,\n environment: { ...environment, CODEX_SECURITY_STATE_DIR: stateDirectory },\n signal,\n failureMessage: \"Could not save the imported scan\",\n };\n signal?.throwIfAborted();\n const registration = await workbench(\n workbenchOptions,\n workbenchArgs(\"register-cli-scan\", {\n repository,\n scanDir,\n registrationJsonStdin: true,\n archiveExisting: Boolean(options.archiveExisting),\n parentScanId: options.parentScanId,\n }),\n JSON.stringify({\n surface: \"cli\",\n packageVersion: VERSION,\n recipe: {\n repository,\n target: { kind: \"repository\", paths: [] },\n mode: \"standard\",\n pluginVersion: plugin.version,\n config: {},\n import: { format: options.format, sourcePath },\n },\n }),\n );\n const scanId = registration[\"scanId\"];\n const targetId = registration[\"targetId\"];\n if (\n typeof scanId !== \"string\" ||\n typeof targetId !== \"string\" ||\n registration[\"scanDir\"] !== scanDir\n ) {\n throw new CodexSecurityError(\n \"The workbench returned an invalid import scan registration.\",\n );\n }\n activeScan = { id: scanId, options: workbenchOptions };\n signal?.throwIfAborted();\n const bound = bindImportedFindings(\n findings,\n options.format,\n scanId,\n targetId,\n );\n const sourceRef = `artifacts/import/source.${options.format}`;\n await mkdir(join(scanDir, \"artifacts\", \"import\"), { recursive: true });\n await writeFile(join(scanDir, sourceRef), source, { flag: \"wx\", signal });\n const documents: Record<string, unknown> = {\n \"scan-manifest.json\": {\n scan: {\n target: { kind: \"directory_snapshot\" },\n scope: {\n summary: IMPORT_DESCRIPTION,\n runtimeStatus: \"imported\",\n limitations: [IMPORT_DESCRIPTION],\n },\n mode: \"repository\",\n reviewState: {\n surfaces: findings.length\n ? [\n {\n id: \"import\",\n label: basename(inputPath),\n disposition: \"reported\",\n receiptRefs: [sourceRef],\n notes: IMPORT_DESCRIPTION,\n },\n ]\n : [],\n explicitExclusions: [],\n deferred: [],\n },\n extensions: {\n import: {\n format: options.format,\n sourceRef,\n findingCount: findings.length,\n },\n },\n },\n },\n \"findings.json\": { findings: bound },\n };\n for (const [name, document] of Object.entries(documents)) {\n await writeFile(\n join(scanDir, name),\n `${JSON.stringify(document, null, 2)}\\n`,\n { flag: \"wx\", signal },\n );\n }\n await workbench(\n workbenchOptions,\n workbenchArgs(\"prepare-scan-completion\", { scanId }),\n );\n // Finalization normally recovers partial output. An import must retain every supplied row.\n const contract = await loadContract(scanDir, {\n pluginRoot,\n expectedScanId: scanId,\n workbenchValidated: true,\n signal,\n });\n const expectedIds = new Set(bound.map((finding) => finding.findingId));\n if (\n contract.findings.findings.length !== findings.length ||\n contract.findings.findings.some(\n (finding) => !expectedIds.delete(finding.findingId),\n )\n ) {\n throw new CodexSecurityError(\n \"Import finalization did not preserve every input finding; the scan was not completed.\",\n );\n }\n await workbench(workbenchOptions, [\"complete-scan\", \"--scan-id\", scanId]);\n activeScan = undefined;\n return new ScanResult({\n ...contract,\n scanDir,\n threadId: \"\",\n turnResult: {\n status: \"completed\",\n imported: true,\n finalResponse: IMPORT_DESCRIPTION,\n },\n });\n } catch (error) {\n if (activeScan !== undefined) {\n await workbench({ ...activeScan.options, signal: undefined }, [\n \"fail-scan\",\n \"--scan-id\",\n activeScan.id,\n `--message=${errorMessage(error)}`,\n ]).catch(() => undefined);\n }\n if (signal?.aborted) {\n throw new ScanInterruptedError(\n \"Codex Security import was interrupted.\",\n scanDir,\n { cause: error },\n );\n }\n throw error;\n } finally {\n await cleanupSdkDirectory(workspace).catch((error: unknown) => {\n void Promise.resolve()\n .then(() =>\n dependencies.onWarning?.(\n `Could not clean up after the Codex Security import: ${errorMessage(error)}`,\n ),\n )\n .catch(() => {});\n });\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -24,14 +24,14 @@ export type { ComponentDeduplicationSummary, ComponentReceipt, ComponentScanOpti
|
|
|
24
24
|
export { normalizeComponentPlan, planComponents } from "./component-plan.js";
|
|
25
25
|
export type { ComponentPlan, ComponentPlanningOptions, } from "./component-plan.js";
|
|
26
26
|
export { estimateScanCost } from "./cost.js";
|
|
27
|
-
export type { ScanAccountRateLimit, ScanAccountRateLimitWindow, ScanCost, ScanSessionEvent, ScanUsageObservation, ScanWorkerEvent, } from "./cost.js";
|
|
28
|
-
export type { ScanTokenUsage } from "./cost-model.js";
|
|
27
|
+
export type { ScanAccountRateLimit, ScanAccountRateLimitWindow, ScanCost, ScanSessionEvent, ScanUsageMeasurement, ScanUsageObservation, ScanWorkerEvent, } from "./cost.js";
|
|
28
|
+
export type { ScanPricingContext, ScanTokenUsage } from "./cost-model.js";
|
|
29
29
|
export type { DeepScanProgress } from "./scan-progress.js";
|
|
30
30
|
export type { CustomValidationResult } from "./custom-validation.js";
|
|
31
31
|
export type { ScanActivity, ScanActivityStatus } from "./scan-activity.js";
|
|
32
32
|
export { matchScanFindings } from "./scan-comparison.js";
|
|
33
33
|
export type { ScanComparisonInput, ScanComparisonOptions, ScanComparisonProgress, ScanComparisonResult, } from "./scan-comparison.js";
|
|
34
|
-
export type { CodexSecurityMetadata, DeepScanOptions, PatchOptions, PatchResult, ScanAuthMode, ScanAuthentication, ScanBudget, ScanOptions, ScanPreflight, ScanReconnectDetails, ScanTrustedAccessStatus, ScanWarningDetails, ValidationOptions, ValidationResult, } from "./api.js";
|
|
34
|
+
export type { CodexSecurityMetadata, DeepScanOptions, PatchOptions, PatchResult, ScanAuthMode, ScanAuthentication, ScanBudget, ScanLifecycle, ScanOptions, ScanPreflight, ScanReconnectDetails, ScanTrustedAccessStatus, ScanWarningDetails, ValidationOptions, ValidationResult, } from "./api.js";
|
|
35
35
|
export type { ScanPhase, ScanProgress, ScanWorkerPhase, ScanWorkerStatus, } from "./worker-progress.js";
|
|
36
36
|
export { CodexLoginHandle } from "./auth.js";
|
|
37
37
|
export type { AccountStatus, LoginResult } from "./auth.js";
|
|
@@ -54,13 +54,14 @@ export { deduplicateScan, deduplicateScanDirectory, } from "./deduplication/scan
|
|
|
54
54
|
export type { DeduplicateScanDirectoryOptions, DeduplicateScanOptions, DeduplicateScanResult, } from "./deduplication/scan.js";
|
|
55
55
|
export type { DeduplicationRefusal } from "./deduplication/deduplication.js";
|
|
56
56
|
export type { FindingEmbeddingBinding } from "./deduplication/local.js";
|
|
57
|
+
export type { PublicationTelemetry, PublicationTelemetryObserver, } from "./publication-telemetry.js";
|
|
57
58
|
export type { DeduplicationDiagnostic, DeduplicationDiagnosticObserver, } from "./deduplication/diagnostics.js";
|
|
58
|
-
export type { FindingEmbedder } from "./server/embeddings.js";
|
|
59
|
+
export type { FindingEmbedder, EmbeddingUsageObservation, EmbeddingUsageObserver, } from "./server/embeddings.js";
|
|
59
60
|
export { ExternalPublicationError, prepareExternalPublication, prepareNormalizedExternalPublication, } from "./external-findings-publish.js";
|
|
60
61
|
export type { ExternalPublicationOptions, NormalizedExternalPublicationOptions, ExternalPublicationDependencies, ExternalPublicationPreview, ExternalPublicationProgress, ExternalPublicationResult, PreparedExternalPublication, } from "./external-findings-publish.js";
|
|
61
62
|
export { prepareNormalizedLocalImport, listLocalExternalFindings, } from "./external-findings-local.js";
|
|
62
63
|
export type { StoredExternalFinding, NormalizedLocalImportOptions, LocalExternalImportDependencies, LocalExternalImportPreview, LocalExternalImportResult, PreparedLocalExternalImport, } from "./external-findings-local.js";
|
|
63
|
-
export type
|
|
64
|
+
export { NoPublishableFindingsError, type ExternalFinding, type ExternalFindings, type ExternalSourceRepository, } from "./external-findings.js";
|
|
64
65
|
export type { ExternalFindingEvidence, FindingImportRequest, FindingImportReceipt, ImportRepository, SourceReport, } from "./external-import-models.js";
|
|
65
66
|
export { normalizeGitHubCodeScanningAlerts, normalizeGitHubAdvisories, readGitHubFindings, } from "./github-findings.js";
|
|
66
67
|
export { importGitHubAdvisories } from "./github-advisories.js";
|
|
@@ -81,16 +82,26 @@ export { classifySeverityRecords, classifySeverityRecordsInputSchema, } from "./
|
|
|
81
82
|
export type { ClassifySeverityRecordsInput, ClassifySeverityRecordsOptions, ClassifySeverityRecordsResult, CanonicalSeverityAssessment, SeverityClassificationReviewRequest, } from "./classify-severity-records.js";
|
|
82
83
|
export { validateRecords } from "./validation-records.js";
|
|
83
84
|
export type { ValidateRecordsInput, ValidateRecordsOptions, ValidationReviewRequest, } from "./validation-records.js";
|
|
84
|
-
export {
|
|
85
|
+
export { readOperationTelemetry, summarizeOperationTelemetry, } from "./operation-telemetry.js";
|
|
86
|
+
export type { OperationTelemetryEvent, OperationOutcome, OperationFailureCategory, } from "./operation-telemetry.js";
|
|
87
|
+
export { prepareLocalExternalImport, type LocalExternalImportOptions, } from "./external-findings-import.js";
|
|
88
|
+
export { readTenableFindings } from "./tenable-findings.js";
|
|
85
89
|
export { normalizeOpenGrepFindings, readOpenGrepFindings, type OpenGrepImportOptions, } from "./opengrep-findings.js";
|
|
86
90
|
export { readSonarFindings, type SonarCapture } from "./sonar-findings.js";
|
|
87
91
|
export { collectSonarIssues, type SonarCollectionOptions, } from "./sonar-collector.js";
|
|
88
92
|
export { normalizeVeracodeFindings, readVeracodeFindings, } from "./veracode-findings.js";
|
|
93
|
+
export { normalizeTrivyFindings, readTrivyFindings } from "./trivy-findings.js";
|
|
89
94
|
export { normalizeBlackDuckFindings, readBlackDuckFindings, } from "./blackduck-findings.js";
|
|
90
95
|
export { normalizeContinuumFindings, readContinuumFindings, } from "./continuum-findings.js";
|
|
96
|
+
export { readCheckmarxFindings } from "./checkmarx-findings.js";
|
|
91
97
|
export { normalizeInspectorFindings, readInspectorFindings, } from "./inspector-findings.js";
|
|
92
98
|
export { normalizeSnykFindingsExport, normalizeSnykJson, normalizeSnykSarif, readSnykFindings, } from "./snyk-findings.js";
|
|
93
|
-
export {
|
|
99
|
+
export { collectSnykIssues, normalizeSnykIssues, SNYK_REST_ISSUES_FORMAT, type CollectSnykIssuesOptions, type SnykIssuesExport, type SnykIssuesFindings, type SnykIssuesProduct, } from "./snyk-rest-findings.js";
|
|
94
100
|
export { normalizeSemgrepFindings, normalizeSemgrepSarif, readSemgrepFindings, type SemgrepImportOptions, } from "./semgrep-findings.js";
|
|
101
|
+
export { collectSemgrepPlatformFindings } from "./semgrep-platform-collector.js";
|
|
102
|
+
export { collectSelectedSemgrepGuardianFindings } from "./semgrep-guardian-findings.js";
|
|
103
|
+
export type { SemgrepPlatformOptions, SemgrepPlatformReport, } from "./semgrep-platform-collector.js";
|
|
104
|
+
export type { HostedScannerHttpOptions } from "./hosted-scanner-http.js";
|
|
105
|
+
export { normalizeSelectedSemgrepPlatformFindings, selectSemgrepPlatformFindings, normalizeSemgrepPlatformFindings, type SemgrepPlatformSelection, } from "./semgrep-platform-findings.js";
|
|
95
106
|
export { normalizeEndorFindings, normalizeEndorSarif, readEndorFindings, } from "./endor-findings.js";
|
|
96
107
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EACV,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,iCAAiC,GAClC,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,EACnB,2BAA2B,EAC3B,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAChF,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC1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wC,EACxC,6BAA6B,EAC7B,gCAAgC,EAChC,KAAK,wBAAwB,GAC9B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ export { deduplicateRecords } from "./deduplication/records.js";
|
|
|
22
22
|
export { deduplicateScan, deduplicateScanDirectory, } from "./deduplication/scan.js";
|
|
23
23
|
export { ExternalPublicationError, prepareExternalPublication, prepareNormalizedExternalPublication, } from "./external-findings-publish.js";
|
|
24
24
|
export { prepareNormalizedLocalImport, listLocalExternalFindings, } from "./external-findings-local.js";
|
|
25
|
+
export { NoPublishableFindingsError, } from "./external-findings.js";
|
|
25
26
|
export { normalizeGitHubCodeScanningAlerts, normalizeGitHubAdvisories, readGitHubFindings, } from "./github-findings.js";
|
|
26
27
|
export { importGitHubAdvisories } from "./github-advisories.js";
|
|
27
28
|
export { normalizeGitHubDependabotAlerts } from "./github-dependabot-findings.js";
|
|
@@ -32,16 +33,23 @@ export { DiffTarget, normalizeRepository, normalizeTarget, repositoryRevision, v
|
|
|
32
33
|
export { BUNDLED_PLUGIN_VERSION, VERSION } from "./version.js";
|
|
33
34
|
export { classifySeverityRecords, classifySeverityRecordsInputSchema, } from "./classify-severity-records.js";
|
|
34
35
|
export { validateRecords } from "./validation-records.js";
|
|
35
|
-
export {
|
|
36
|
+
export { readOperationTelemetry, summarizeOperationTelemetry, } from "./operation-telemetry.js";
|
|
37
|
+
export { prepareLocalExternalImport, } from "./external-findings-import.js";
|
|
38
|
+
export { readTenableFindings } from "./tenable-findings.js";
|
|
36
39
|
export { normalizeOpenGrepFindings, readOpenGrepFindings, } from "./opengrep-findings.js";
|
|
37
40
|
export { readSonarFindings } from "./sonar-findings.js";
|
|
38
41
|
export { collectSonarIssues, } from "./sonar-collector.js";
|
|
39
42
|
export { normalizeVeracodeFindings, readVeracodeFindings, } from "./veracode-findings.js";
|
|
43
|
+
export { normalizeTrivyFindings, readTrivyFindings } from "./trivy-findings.js";
|
|
40
44
|
export { normalizeBlackDuckFindings, readBlackDuckFindings, } from "./blackduck-findings.js";
|
|
41
45
|
export { normalizeContinuumFindings, readContinuumFindings, } from "./continuum-findings.js";
|
|
46
|
+
export { readCheckmarxFindings } from "./checkmarx-findings.js";
|
|
42
47
|
export { normalizeInspectorFindings, readInspectorFindings, } from "./inspector-findings.js";
|
|
43
48
|
export { normalizeSnykFindingsExport, normalizeSnykJson, normalizeSnykSarif, readSnykFindings, } from "./snyk-findings.js";
|
|
44
|
-
export {
|
|
49
|
+
export { collectSnykIssues, normalizeSnykIssues, SNYK_REST_ISSUES_FORMAT, } from "./snyk-rest-findings.js";
|
|
45
50
|
export { normalizeSemgrepFindings, normalizeSemgrepSarif, readSemgrepFindings, } from "./semgrep-findings.js";
|
|
51
|
+
export { collectSemgrepPlatformFindings } from "./semgrep-platform-collector.js";
|
|
52
|
+
export { collectSelectedSemgrepGuardianFindings } from "./semgrep-guardian-findings.js";
|
|
53
|
+
export { normalizeSelectedSemgrepPlatformFindings, selectSemgrepPlatformFindings, normalizeSemgrepPlatformFindings, } from "./semgrep-platform-findings.js";
|
|
46
54
|
export { normalizeEndorFindings, normalizeEndorSarif, readEndorFindings, } from "./endor-findings.js";
|
|
47
55
|
//# sourceMappingURL=index.js.map
|