@openai/codex-security 0.8.3 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -746
- package/_bundled_plugin/.codex-plugin/plugin.json +2 -0
- package/_bundled_plugin/.mcp.json +7 -1
- package/_bundled_plugin/examples/completed-scan/findings.json +16 -4
- package/_bundled_plugin/examples/completed-scan/report.md +11 -8
- package/_bundled_plugin/examples/completed-scan/scan-manifest.json +4 -2
- package/_bundled_plugin/mcp/fzstd-LICENSE.txt +21 -0
- package/_bundled_plugin/mcp/helpers.mjs +2 -11
- package/_bundled_plugin/mcp/helpers.mjs.br +0 -0
- package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +3 -210
- package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
- package/_bundled_plugin/mcp/package.json +1 -0
- package/_bundled_plugin/mcp/permission-profile-preflight.mjs +5 -2
- package/_bundled_plugin/mcp/server.mjs +2 -11
- package/_bundled_plugin/mcp/server.mjs.br +0 -0
- package/_bundled_plugin/mcp/session-decompression.mjs +712 -0
- package/_bundled_plugin/references/artifact-storage.md +1 -1
- package/_bundled_plugin/references/baseline-auditor.md +18 -0
- package/_bundled_plugin/references/core-scan.md +5 -42
- package/_bundled_plugin/references/default-severity-rubric.md +9 -4
- package/_bundled_plugin/references/final-report.md +5 -3
- package/_bundled_plugin/references/finding-detail-fields.md +18 -18
- package/_bundled_plugin/references/focused-investigator.md +13 -0
- package/_bundled_plugin/references/sarif-adapter.md +8 -2
- package/_bundled_plugin/references/scan-artifacts.md +21 -12
- package/_bundled_plugin/references/scan-contract.md +27 -33
- package/_bundled_plugin/references/scan-prologue.md +2 -2
- package/_bundled_plugin/references/scan-runtime.md +4 -2
- package/_bundled_plugin/references/security-guidance.md +14 -1
- package/_bundled_plugin/references/validate-scan-findings.md +3 -0
- package/_bundled_plugin/schemas/tools/scan-draft.schema.json +2 -2
- package/_bundled_plugin/scripts/check_deep_scan_target.py +97 -0
- package/_bundled_plugin/scripts/codex_profile.mjs +7 -1
- package/_bundled_plugin/scripts/deep_scan_config.py +20 -1
- package/_bundled_plugin/scripts/deep_scan_workbench.py +192 -352
- package/_bundled_plugin/scripts/dispatch_inventory_tool +7 -0
- package/_bundled_plugin/scripts/filesystem_identity.py +1 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +182 -230
- package/_bundled_plugin/scripts/finding_preview.py +20 -0
- package/_bundled_plugin/scripts/launch_codex_security_mcp +55 -16
- package/_bundled_plugin/scripts/legacy_findings.py +148 -0
- package/_bundled_plugin/scripts/posix_scan_local_files.py +37 -1
- package/_bundled_plugin/scripts/read_codex_session.mjs +21 -0
- package/_bundled_plugin/scripts/report_projection.py +81 -43
- package/_bundled_plugin/scripts/review_state.py +8 -2
- package/_bundled_plugin/scripts/servicenow_avit.py +20 -0
- package/_bundled_plugin/scripts/snapshot_sqlite.py +9 -2
- package/_bundled_plugin/scripts/threat_model_projection.py +22 -26
- package/_bundled_plugin/scripts/validate_scan_contract.py +7 -1
- package/_bundled_plugin/scripts/windows_scan_local_files.py +582 -20
- package/_bundled_plugin/scripts/workbench/__init__.py +1 -1
- package/_bundled_plugin/scripts/workbench/handoff.py +100 -23
- package/_bundled_plugin/scripts/workbench/retained_coverage.py +30 -51
- package/_bundled_plugin/scripts/workbench/retained_records.py +18 -30
- package/_bundled_plugin/scripts/workbench/runtime_toml.py +4 -1
- package/_bundled_plugin/scripts/workbench/saved_coverage.py +9 -17
- package/_bundled_plugin/scripts/workbench/saved_outputs.py +9 -0
- package/_bundled_plugin/scripts/workbench/saved_sources.py +47 -40
- package/_bundled_plugin/scripts/workbench/storage.py +91 -7
- package/_bundled_plugin/scripts/workbench_cli.py +54 -14
- package/_bundled_plugin/scripts/workbench_constants.py +12 -0
- package/_bundled_plugin/scripts/workbench_coverage_receipts.py +3 -3
- package/_bundled_plugin/scripts/workbench_db.py +562 -303
- package/_bundled_plugin/scripts/workbench_feedback.py +57 -11
- package/_bundled_plugin/scripts/workbench_finding_index.py +1 -0
- package/_bundled_plugin/scripts/workbench_finding_workflows.py +4 -0
- package/_bundled_plugin/scripts/workbench_native_indexes.py +238 -41
- package/_bundled_plugin/scripts/workbench_progress.py +169 -4
- package/_bundled_plugin/scripts/workbench_publication.py +16 -13
- package/_bundled_plugin/scripts/workbench_remediation.py +155 -2
- package/_bundled_plugin/scripts/workbench_saved_results.py +176 -81
- package/_bundled_plugin/scripts/workbench_scan_history.py +398 -174
- package/_bundled_plugin/scripts/workbench_scan_start.py +224 -31
- package/_bundled_plugin/scripts/workbench_scan_usage.py +675 -73
- package/_bundled_plugin/scripts/workbench_schema.py +258 -63
- package/_bundled_plugin/scripts/workbench_setup.py +14 -2
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +13 -0
- package/_bundled_plugin/scripts/workbench_source_scopes.py +18 -0
- package/_bundled_plugin/scripts/workbench_target.py +594 -136
- package/_bundled_plugin/scripts/workbench_target_state.py +1110 -21
- package/_bundled_plugin/scripts/workbench_validation.py +43 -3
- package/_bundled_plugin/shared/workbench-history-repairs.json +77 -35
- package/_bundled_plugin/shared/workbench-migrations.json +100 -0
- package/_bundled_plugin/skills/cloud-findings/SKILL.md +5 -5
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +7 -50
- package/_bundled_plugin/skills/fix-finding/SKILL.md +2 -1
- package/_bundled_plugin/skills/publish-findings/SKILL.md +24 -153
- package/_bundled_plugin/skills/publish-findings/agents/openai.yaml +2 -2
- package/_bundled_plugin/skills/publish-findings/references/checkmarx-import.md +37 -0
- package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +3 -3
- package/_bundled_plugin/skills/publish-findings/scripts/collect_checkmarx.py +409 -0
- package/_bundled_plugin/skills/publish-findings/scripts/collect_continuum.py +224 -0
- package/_bundled_plugin/skills/publish-findings/scripts/collector_paths.py +63 -0
- package/_bundled_plugin/skills/security-scan/SKILL.md +9 -46
- package/_bundled_plugin/skills/security-scan/agents/openai.yaml +2 -2
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +3 -21
- package/_bundled_plugin/skills/security-scan/references/managed-scan.md +11 -0
- package/_bundled_plugin/skills/security-scan/references/scan-results.md +15 -0
- package/_bundled_plugin/skills/security-scan/references/scoped-paths.md +23 -0
- package/_bundled_plugin/skills/security-scan/references/sdk-files.md +24 -0
- package/_bundled_plugin/skills/threat-model-visualize/scripts/build_explorer.py +22 -1
- package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +6 -2
- package/bin/codex-security.mjs +2 -2
- package/dist/api.d.ts +45 -5
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +1192 -427
- package/dist/api.js.map +1 -1
- package/dist/armorcode-findings.d.ts +9 -0
- package/dist/armorcode-findings.d.ts.map +1 -0
- package/dist/armorcode-findings.js +145 -0
- package/dist/armorcode-findings.js.map +1 -0
- package/dist/artifact-export.d.ts +2 -0
- package/dist/artifact-export.d.ts.map +1 -1
- package/dist/artifact-export.js +29 -13
- package/dist/artifact-export.js.map +1 -1
- package/dist/auth.d.ts +6 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +37 -18
- package/dist/auth.js.map +1 -1
- package/dist/batch-cost.d.ts +18 -0
- package/dist/batch-cost.d.ts.map +1 -0
- package/dist/batch-cost.js +41 -0
- package/dist/batch-cost.js.map +1 -0
- package/dist/bedrock-oss-pricing.d.ts +6 -0
- package/dist/bedrock-oss-pricing.d.ts.map +1 -0
- package/dist/bedrock-oss-pricing.js +58 -0
- package/dist/bedrock-oss-pricing.js.map +1 -0
- package/dist/bedrock-pricing.d.ts +15 -0
- package/dist/bedrock-pricing.d.ts.map +1 -0
- package/dist/bedrock-pricing.js +117 -0
- package/dist/bedrock-pricing.js.map +1 -0
- package/dist/blackduck-findings.d.ts +1 -1
- package/dist/blackduck-findings.d.ts.map +1 -1
- package/dist/blackduck-findings.js +24 -22
- package/dist/blackduck-findings.js.map +1 -1
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +4 -4
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/bundled-plugin.d.ts +4 -0
- package/dist/bundled-plugin.d.ts.map +1 -0
- package/dist/bundled-plugin.js +23 -0
- package/dist/bundled-plugin.js.map +1 -0
- package/dist/checkmarx-evidence.d.ts +19 -0
- package/dist/checkmarx-evidence.d.ts.map +1 -0
- package/dist/checkmarx-evidence.js +36 -0
- package/dist/checkmarx-evidence.js.map +1 -0
- package/dist/checkmarx-findings.d.ts +4 -0
- package/dist/checkmarx-findings.d.ts.map +1 -0
- package/dist/checkmarx-findings.js +27 -0
- package/dist/checkmarx-findings.js.map +1 -0
- package/dist/checkmarx-one.d.ts +4 -0
- package/dist/checkmarx-one.d.ts.map +1 -0
- package/dist/checkmarx-one.js +53 -0
- package/dist/checkmarx-one.js.map +1 -0
- package/dist/checkmarx-repository.d.ts +12 -0
- package/dist/checkmarx-repository.d.ts.map +1 -0
- package/dist/checkmarx-repository.js +181 -0
- package/dist/checkmarx-repository.js.map +1 -0
- package/dist/checkmarx-xml.d.ts +12 -0
- package/dist/checkmarx-xml.d.ts.map +1 -0
- package/dist/checkmarx-xml.js +196 -0
- package/dist/checkmarx-xml.js.map +1 -0
- package/dist/classify-scan-severity.d.ts +1 -1
- package/dist/classify-scan-severity.d.ts.map +1 -1
- package/dist/classify-scan-severity.js +11 -3
- package/dist/classify-scan-severity.js.map +1 -1
- package/dist/classify-severity-records.d.ts +1 -9
- package/dist/classify-severity-records.d.ts.map +1 -1
- package/dist/classify-severity-records.js +3 -13
- package/dist/classify-severity-records.js.map +1 -1
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +11 -10
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-argument.d.ts +4 -0
- package/dist/cli-argument.d.ts.map +1 -0
- package/dist/cli-argument.js +17 -0
- package/dist/cli-argument.js.map +1 -0
- package/dist/cli-help.d.ts +1 -1
- package/dist/cli-help.d.ts.map +1 -1
- package/dist/cli-help.js +71 -29
- package/dist/cli-help.js.map +1 -1
- package/dist/cli-hook.d.ts +3 -0
- package/dist/cli-hook.d.ts.map +1 -0
- package/dist/cli-hook.js +87 -0
- package/dist/cli-hook.js.map +1 -0
- package/dist/cli-integrations.d.ts +13 -0
- package/dist/cli-integrations.d.ts.map +1 -0
- package/dist/cli-integrations.js +333 -0
- package/dist/cli-integrations.js.map +1 -0
- package/dist/cli-mcp.d.ts +15 -0
- package/dist/cli-mcp.d.ts.map +1 -0
- package/dist/cli-mcp.js +178 -0
- package/dist/cli-mcp.js.map +1 -0
- package/dist/cli-token-view.d.ts +10 -0
- package/dist/cli-token-view.d.ts.map +1 -0
- package/dist/cli-token-view.js +41 -0
- package/dist/cli-token-view.js.map +1 -0
- package/dist/cli.d.ts +16 -8
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +3382 -2017
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +35 -33
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codex-sdk-environment.d.ts +6 -0
- package/dist/codex-sdk-environment.d.ts.map +1 -1
- package/dist/codex-sdk-environment.js +19 -0
- package/dist/codex-sdk-environment.js.map +1 -1
- package/dist/command-words.d.ts +3 -0
- package/dist/command-words.d.ts.map +1 -0
- package/dist/command-words.js +46 -0
- package/dist/command-words.js.map +1 -0
- package/dist/component-scan.d.ts +19 -4
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +67 -9
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +130 -67
- package/dist/config.js.map +1 -1
- package/dist/continuum-findings.d.ts +1 -1
- package/dist/continuum-findings.d.ts.map +1 -1
- package/dist/continuum-findings.js +149 -19
- package/dist/continuum-findings.js.map +1 -1
- package/dist/contract-values.d.ts +2 -0
- package/dist/contract-values.d.ts.map +1 -1
- package/dist/contract-values.js +12 -9
- package/dist/contract-values.js.map +1 -1
- package/dist/cost-model.d.ts +13 -1
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +66 -112
- package/dist/cost-model.js.map +1 -1
- package/dist/cost.d.ts +42 -3
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +484 -149
- package/dist/cost.js.map +1 -1
- package/dist/custom-publish.d.ts +4 -0
- package/dist/custom-publish.d.ts.map +1 -1
- package/dist/custom-publish.js +40 -3
- package/dist/custom-publish.js.map +1 -1
- package/dist/custom-validation-prompt.d.ts +1 -1
- package/dist/custom-validation-prompt.d.ts.map +1 -1
- package/dist/custom-validation-prompt.js +29 -19
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/deduplication/local.d.ts +4 -2
- package/dist/deduplication/local.d.ts.map +1 -1
- package/dist/deduplication/local.js +9 -2
- package/dist/deduplication/local.js.map +1 -1
- package/dist/deduplication/refusal.d.ts.map +1 -1
- package/dist/deduplication/refusal.js +26 -5
- package/dist/deduplication/refusal.js.map +1 -1
- package/dist/deduplication/scan.d.ts +5 -0
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +24 -7
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-config.d.ts +0 -1
- package/dist/deep-config.d.ts.map +1 -1
- package/dist/deep-config.js +22 -33
- package/dist/deep-config.js.map +1 -1
- package/dist/deep-scan-defaults.d.ts +2 -0
- package/dist/deep-scan-defaults.d.ts.map +1 -1
- package/dist/deep-scan-defaults.js +28 -1
- package/dist/deep-scan-defaults.js.map +1 -1
- package/dist/deep-scan.d.ts +2 -0
- package/dist/deep-scan.d.ts.map +1 -1
- package/dist/deep-scan.js +44 -19
- package/dist/deep-scan.js.map +1 -1
- package/dist/default-severity-rubric.d.ts +1 -1
- package/dist/default-severity-rubric.d.ts.map +1 -1
- package/dist/default-severity-rubric.js +1 -1
- package/dist/default-severity-rubric.js.map +1 -1
- package/dist/endor-findings.d.ts +3 -1
- package/dist/endor-findings.d.ts.map +1 -1
- package/dist/endor-findings.js +86 -45
- package/dist/endor-findings.js.map +1 -1
- package/dist/errors.d.ts +4 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +15 -4
- package/dist/errors.js.map +1 -1
- package/dist/executable-path.d.ts +3 -0
- package/dist/executable-path.d.ts.map +1 -1
- package/dist/executable-path.js +26 -0
- package/dist/executable-path.js.map +1 -1
- package/dist/external-findings-import.d.ts +5 -3
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +19 -7
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts +69 -5
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +537 -108
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +13 -6
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +895 -1142
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +21 -2
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +130 -68
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-findings.d.ts +15 -3
- package/dist/external-findings.d.ts.map +1 -1
- package/dist/external-findings.js +54 -2
- package/dist/external-findings.js.map +1 -1
- package/dist/external-import-contract.d.ts +8 -12
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +51 -184
- package/dist/external-import-contract.js.map +1 -1
- package/dist/external-import-models.d.ts +1 -1
- package/dist/external-import-models.d.ts.map +1 -1
- package/dist/external-import-models.js.map +1 -1
- package/dist/feedback.d.ts.map +1 -1
- package/dist/feedback.js +5 -4
- package/dist/feedback.js.map +1 -1
- package/dist/finding-prompt.d.ts +5 -0
- package/dist/finding-prompt.d.ts.map +1 -0
- package/dist/finding-prompt.js +32 -0
- package/dist/finding-prompt.js.map +1 -0
- package/dist/findings-client.d.ts +1 -0
- package/dist/findings-client.d.ts.map +1 -1
- package/dist/findings-client.js +27 -3
- package/dist/findings-client.js.map +1 -1
- package/dist/github-advisories.d.ts.map +1 -1
- package/dist/github-advisories.js +0 -2
- package/dist/github-advisories.js.map +1 -1
- package/dist/github-dependabot-findings.d.ts.map +1 -1
- package/dist/github-dependabot-findings.js +18 -8
- package/dist/github-dependabot-findings.js.map +1 -1
- package/dist/github-findings.d.ts +4 -1
- package/dist/github-findings.d.ts.map +1 -1
- package/dist/github-findings.js +73 -316
- package/dist/github-findings.js.map +1 -1
- package/dist/hosted-git-remotes.d.ts +5 -0
- package/dist/hosted-git-remotes.d.ts.map +1 -0
- package/dist/hosted-git-remotes.js +285 -0
- package/dist/hosted-git-remotes.js.map +1 -0
- package/dist/hosted-git-repository.d.ts +28 -0
- package/dist/hosted-git-repository.d.ts.map +1 -0
- package/dist/hosted-git-repository.js +222 -0
- package/dist/hosted-git-repository.js.map +1 -0
- package/dist/hosted-remediation.d.ts +1 -0
- package/dist/hosted-remediation.d.ts.map +1 -1
- package/dist/hosted-remediation.js +23 -3
- package/dist/hosted-remediation.js.map +1 -1
- package/dist/hosted-scan-protocol.js +2 -2
- package/dist/hosted-scan-protocol.js.map +1 -1
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +16 -11
- package/dist/hosted-scan.js.map +1 -1
- package/dist/hosted-scanner-http.d.ts +21 -0
- package/dist/hosted-scanner-http.d.ts.map +1 -0
- package/dist/hosted-scanner-http.js +204 -0
- package/dist/hosted-scanner-http.js.map +1 -0
- package/dist/import-scan.d.ts.map +1 -1
- package/dist/import-scan.js +3 -0
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +21 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/inspector-findings.d.ts.map +1 -1
- package/dist/inspector-findings.js +52 -86
- package/dist/inspector-findings.js.map +1 -1
- package/dist/knowledge-base.d.ts +1 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +102 -32
- package/dist/knowledge-base.js.map +1 -1
- package/dist/linear.d.ts +11 -0
- package/dist/linear.d.ts.map +1 -1
- package/dist/linear.js.map +1 -1
- package/dist/local-git-metadata.d.ts +5 -2
- package/dist/local-git-metadata.d.ts.map +1 -1
- package/dist/local-git-metadata.js +8 -5
- package/dist/local-git-metadata.js.map +1 -1
- package/dist/multiscan.d.ts +10 -4
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +217 -102
- package/dist/multiscan.js.map +1 -1
- package/dist/native-json-findings.d.ts +2 -1
- package/dist/native-json-findings.d.ts.map +1 -1
- package/dist/native-json-findings.js +12 -2
- package/dist/native-json-findings.js.map +1 -1
- package/dist/opengrep-findings.d.ts +5 -2
- package/dist/opengrep-findings.d.ts.map +1 -1
- package/dist/opengrep-findings.js +54 -33
- package/dist/opengrep-findings.js.map +1 -1
- package/dist/operation-telemetry.d.ts +104 -0
- package/dist/operation-telemetry.d.ts.map +1 -0
- package/dist/operation-telemetry.js +293 -0
- package/dist/operation-telemetry.js.map +1 -0
- package/dist/plugin-python-probe.d.ts +4 -0
- package/dist/plugin-python-probe.d.ts.map +1 -0
- package/dist/plugin-python-probe.js +10 -0
- package/dist/plugin-python-probe.js.map +1 -0
- package/dist/private-finding-import.d.ts +99 -9
- package/dist/private-finding-import.d.ts.map +1 -1
- package/dist/private-finding-import.js +116 -152
- package/dist/private-finding-import.js.map +1 -1
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +53 -13
- package/dist/project-config.js.map +1 -1
- package/dist/prompt-files.d.ts +7 -2
- package/dist/prompt-files.d.ts.map +1 -1
- package/dist/prompt-files.js +42 -20
- package/dist/prompt-files.js.map +1 -1
- package/dist/provider-profile.d.ts +1 -1
- package/dist/provider-profile.d.ts.map +1 -1
- package/dist/provider-profile.js +12 -10
- package/dist/provider-profile.js.map +1 -1
- package/dist/publication-telemetry.d.ts +45 -0
- package/dist/publication-telemetry.d.ts.map +1 -0
- package/dist/publication-telemetry.js +50 -0
- package/dist/publication-telemetry.js.map +1 -0
- package/dist/publication.d.ts +1 -1
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts +4 -0
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +42 -2
- package/dist/publish.js.map +1 -1
- package/dist/record.d.ts +1 -5
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +3 -51
- package/dist/record.js.map +1 -1
- package/dist/remediation.d.ts +1 -4
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +6 -8
- package/dist/remediation.js.map +1 -1
- package/dist/request-metadata.d.ts +3 -0
- package/dist/request-metadata.d.ts.map +1 -1
- package/dist/request-metadata.js +9 -0
- package/dist/request-metadata.js.map +1 -1
- package/dist/result.d.ts +4 -0
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +1 -1
- package/dist/result.js.map +1 -1
- package/dist/retry-windows-rename.d.ts +8 -0
- package/dist/retry-windows-rename.d.ts.map +1 -0
- package/dist/retry-windows-rename.js +24 -0
- package/dist/retry-windows-rename.js.map +1 -0
- package/dist/runtime.d.ts +54 -6
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +1084 -256
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan-bootstrap.d.ts +7 -1
- package/dist/saved-scan-bootstrap.d.ts.map +1 -1
- package/dist/saved-scan-bootstrap.js +269 -114
- package/dist/saved-scan-bootstrap.js.map +1 -1
- package/dist/scan-activity.d.ts.map +1 -1
- package/dist/scan-activity.js +141 -56
- package/dist/scan-activity.js.map +1 -1
- package/dist/scan-archive-path.d.ts +2 -0
- package/dist/scan-archive-path.d.ts.map +1 -0
- package/dist/scan-archive-path.js +5 -0
- package/dist/scan-archive-path.js.map +1 -0
- package/dist/scan-comparison.d.ts +10 -5
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +66 -17
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +7 -6
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +92 -43
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-executor.d.ts +10 -1
- package/dist/scan-executor.d.ts.map +1 -1
- package/dist/scan-executor.js +24 -2
- package/dist/scan-executor.js.map +1 -1
- package/dist/scan-history-renderer.d.ts +1 -0
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +34 -28
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts +12 -0
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +131 -78
- package/dist/scan-logs.js.map +1 -1
- package/dist/scan-measurement.d.ts +26 -0
- package/dist/scan-measurement.d.ts.map +1 -0
- package/dist/scan-measurement.js +77 -0
- package/dist/scan-measurement.js.map +1 -0
- package/dist/scan-progress.d.ts +1 -0
- package/dist/scan-progress.d.ts.map +1 -1
- package/dist/scan-progress.js +3 -0
- package/dist/scan-progress.js.map +1 -1
- package/dist/scan-sessions.d.ts.map +1 -1
- package/dist/scan-sessions.js +4 -1
- package/dist/scan-sessions.js.map +1 -1
- package/dist/scan-settings.d.ts +1 -1
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +1 -24
- package/dist/scan-settings.js.map +1 -1
- package/dist/scanner-import.d.ts +25 -13
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +216 -97
- package/dist/scanner-import.js.map +1 -1
- package/dist/scanner-repository-url.d.ts +4 -1
- package/dist/scanner-repository-url.d.ts.map +1 -1
- package/dist/scanner-repository-url.js +10 -6
- package/dist/scanner-repository-url.js.map +1 -1
- package/dist/security-policy.d.ts +1 -1
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js +26 -6
- package/dist/security-policy.js.map +1 -1
- package/dist/semgrep-findings.d.ts +6 -3
- package/dist/semgrep-findings.d.ts.map +1 -1
- package/dist/semgrep-findings.js +72 -42
- package/dist/semgrep-findings.js.map +1 -1
- package/dist/semgrep-guardian-findings.d.ts +38 -0
- package/dist/semgrep-guardian-findings.d.ts.map +1 -0
- package/dist/semgrep-guardian-findings.js +165 -0
- package/dist/semgrep-guardian-findings.js.map +1 -0
- package/dist/semgrep-platform-collector.d.ts +26 -0
- package/dist/semgrep-platform-collector.d.ts.map +1 -0
- package/dist/semgrep-platform-collector.js +108 -0
- package/dist/semgrep-platform-collector.js.map +1 -0
- package/dist/semgrep-platform-findings.d.ts +157 -6
- package/dist/semgrep-platform-findings.d.ts.map +1 -1
- package/dist/semgrep-platform-findings.js +766 -103
- package/dist/semgrep-platform-findings.js.map +1 -1
- package/dist/server/api.d.ts +1 -1
- package/dist/server/api.d.ts.map +1 -1
- package/dist/server/api.js.map +1 -1
- package/dist/server/embedding-tokenizer.cdx.json +33 -0
- package/dist/server/embedding-tokenizer.d.ts +2 -0
- package/dist/server/embedding-tokenizer.d.ts.map +1 -0
- package/dist/server/embedding-tokenizer.js +322 -0
- package/dist/server/embedding-tokenizer.js.map +6 -0
- package/dist/server/embeddings.d.ts +16 -2
- package/dist/server/embeddings.d.ts.map +1 -1
- package/dist/server/embeddings.js +35 -5
- package/dist/server/embeddings.js.map +1 -1
- package/dist/session-lines.d.ts +5 -0
- package/dist/session-lines.d.ts.map +1 -0
- package/dist/session-lines.js +60 -0
- package/dist/session-lines.js.map +1 -0
- package/dist/severity-review.d.ts +3 -1
- package/dist/severity-review.d.ts.map +1 -1
- package/dist/severity-review.js +3 -2
- package/dist/severity-review.js.map +1 -1
- package/dist/skill-authentication.d.ts +1 -0
- package/dist/skill-authentication.d.ts.map +1 -1
- package/dist/skill-authentication.js +1 -0
- package/dist/skill-authentication.js.map +1 -1
- package/dist/snyk-findings.d.ts +9 -2
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +90 -70
- package/dist/snyk-findings.js.map +1 -1
- package/dist/snyk-rest-findings.d.ts +59 -0
- package/dist/snyk-rest-findings.d.ts.map +1 -0
- package/dist/snyk-rest-findings.js +879 -0
- package/dist/snyk-rest-findings.js.map +1 -0
- package/dist/snyk-token-origin.d.ts +4 -0
- package/dist/snyk-token-origin.d.ts.map +1 -0
- package/dist/snyk-token-origin.js +82 -0
- package/dist/snyk-token-origin.js.map +1 -0
- package/dist/sonar-collector.d.ts.map +1 -1
- package/dist/sonar-collector.js +0 -3
- package/dist/sonar-collector.js.map +1 -1
- package/dist/sonar-findings.d.ts +1 -1
- package/dist/sonar-findings.d.ts.map +1 -1
- package/dist/sonar-findings.js +2 -4
- package/dist/sonar-findings.js.map +1 -1
- package/dist/sonar-import.d.ts +3 -0
- package/dist/sonar-import.d.ts.map +1 -1
- package/dist/sonar-import.js +30 -34
- package/dist/sonar-import.js.map +1 -1
- package/dist/stored-finding-projection.d.ts +6 -0
- package/dist/stored-finding-projection.d.ts.map +1 -0
- package/dist/stored-finding-projection.js +104 -0
- package/dist/stored-finding-projection.js.map +1 -0
- package/dist/stored-findings-publication.d.ts +23 -0
- package/dist/stored-findings-publication.d.ts.map +1 -0
- package/dist/stored-findings-publication.js +169 -0
- package/dist/stored-findings-publication.js.map +1 -0
- package/dist/target-drift.d.ts +9 -0
- package/dist/target-drift.d.ts.map +1 -0
- package/dist/target-drift.js +27 -0
- package/dist/target-drift.js.map +1 -0
- package/dist/targets.d.ts +8 -1
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +131 -42
- package/dist/targets.js.map +1 -1
- package/dist/tenable-findings.d.ts +6 -0
- package/dist/tenable-findings.d.ts.map +1 -0
- package/dist/tenable-findings.js +122 -0
- package/dist/tenable-findings.js.map +1 -0
- package/dist/terminal-stream.d.ts +13 -0
- package/dist/terminal-stream.d.ts.map +1 -0
- package/dist/terminal-stream.js +35 -0
- package/dist/terminal-stream.js.map +1 -0
- package/dist/trivy-findings.d.ts +19 -0
- package/dist/trivy-findings.d.ts.map +1 -0
- package/dist/trivy-findings.js +424 -0
- package/dist/trivy-findings.js.map +1 -0
- package/dist/trivy-import.d.ts +19 -0
- package/dist/trivy-import.d.ts.map +1 -0
- package/dist/trivy-import.js +151 -0
- package/dist/trivy-import.js.map +1 -0
- package/dist/trusted-executable.d.ts +6 -0
- package/dist/trusted-executable.d.ts.map +1 -1
- package/dist/trusted-executable.js +140 -37
- package/dist/trusted-executable.js.map +1 -1
- package/dist/validation-records.js +1 -1
- package/dist/validation-records.js.map +1 -1
- package/dist/veracode-findings.d.ts +1 -1
- package/dist/veracode-findings.d.ts.map +1 -1
- package/dist/veracode-findings.js +19 -6
- package/dist/veracode-findings.js.map +1 -1
- package/dist/version.d.ts +3 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +184 -32
- package/dist/version.js.map +1 -1
- package/dist/vertex-pricing.d.ts +8 -0
- package/dist/vertex-pricing.d.ts.map +1 -0
- package/dist/vertex-pricing.js +20 -0
- package/dist/vertex-pricing.js.map +1 -0
- package/dist/windows-path.d.ts +1 -0
- package/dist/windows-path.d.ts.map +1 -1
- package/dist/windows-path.js +26 -1
- package/dist/windows-path.js.map +1 -1
- package/dist/wiz-findings.d.ts +6 -2
- package/dist/wiz-findings.d.ts.map +1 -1
- package/dist/wiz-findings.js +65 -89
- package/dist/wiz-findings.js.map +1 -1
- package/docs/classify-severity-records.md +27 -12
- package/docs/cli.md +853 -639
- package/docs/dedupe-records.md +44 -24
- package/docs/findings-service.md +84 -44
- package/docs/hosted-remediation.md +27 -11
- package/docs/hosted-scans.md +50 -42
- package/docs/sdk.md +903 -0
- package/docs/telemetry.md +236 -0
- package/docs/validate-records.md +78 -44
- package/package.json +23 -16
- package/schemas/external-findings.schema.json +4 -1
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
- package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +0 -96
- package/dist/external-imports-feature.d.ts +0 -6
- package/dist/external-imports-feature.d.ts.map +0 -1
- package/dist/external-imports-feature.js +0 -51
- package/dist/external-imports-feature.js.map +0 -1
- package/dist/finding-normalization.d.ts +0 -5
- package/dist/finding-normalization.d.ts.map +0 -1
- package/dist/finding-normalization.js +0 -155
- package/dist/finding-normalization.js.map +0 -1
- package/dist/reader-selection.d.ts +0 -13
- package/dist/reader-selection.d.ts.map +0 -1
- package/dist/reader-selection.js +0 -81
- package/dist/reader-selection.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-telemetry.js","sourceRoot":"","sources":["../src/operation-telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACL,UAAU,EACV,KAAK,EACL,QAAQ,EACR,OAAO,EACP,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,mBAAmB,EACnB,gCAAgC,EAChC,2BAA2B,GAC5B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAkEvC,oFAAoF;AACpF,MAAM,OAAO,kBAAkB;IACpB,SAAS,GAAG,UAAU,EAAE,CAAC;IAClC,WAAW,CAAS;IACpB,WAAW,CAA6C;IACxD,YAAY,GA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C;QACtE,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC;YACpC,YAAY,CAAC,GAAG,CACd,KAAK,CAAC,YAAY,EAClB,IAAI,CAAC,GAAG,CACN,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,EACzC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CACpC,CACF,CAAC;YACF,cAAc,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,YAAY,CAAC,MAAM,EAAE;QAAE,eAAe,IAAI,IAAI,CAAC;IAClE,OAAO;QACL,UAAU,EAAE,UAAU,CAAC,IAAI;QAC3B,oBAAoB,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM;QACrE,QAAQ,EAAE,QAAQ,CAAC,IAAI;QACvB,QAAQ;QACR,aAAa;QACb,UAAU;QACV,eAAe;QACf,cAAc;QACd,cAAc;QACd,UAAU;KACX,CAAC;AACJ,CAAC","sourcesContent":["import { createHash, randomUUID } from \"node:crypto\";\nimport {\n appendFile,\n mkdir,\n readFile,\n readdir,\n writeFile,\n} from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport type { ScanUsageMeasurement } from \"./cost.js\";\nimport {\n canonicalConfigPath,\n requireOutputOutsideRepositories,\n requireSecureOutputAncestry,\n} from \"./runtime.js\";\nimport { gitProtectionRoots } from \"./targets.js\";\nimport { VERSION } from \"./version.js\";\n\nexport type OperationOutcome =\n \"completed\" | \"failed\" | \"canceled\" | \"unresolved\";\nexport type OperationFailureCategory =\n | \"configuration\"\n | \"authentication\"\n | \"input\"\n | \"budget\"\n | \"execution\"\n | \"canceled\";\n\n/** Content-free operational receipts. IDs are for joins, never metric labels. */\nexport interface OperationTelemetryEvent {\n schemaVersion: 1;\n eventId: string;\n operationId: string;\n attemptId: string;\n parentAttemptId?: string;\n /** Resumed scans share a cumulative measurement scope; never sum those receipts. */\n usageScopeId: string;\n occurredAt: string;\n observedAt: string;\n type: \"attempt_started\" | \"attempt_finished\";\n command:\n | \"scan\"\n | \"patch\"\n | \"validate\"\n | \"policy\"\n | \"verify-fix\"\n | \"assess-patch-risk\";\n surface: \"cli\" | \"sdk\";\n packageVersion: string;\n mode?: \"standard\" | \"deep\";\n resumed: boolean;\n /** True when this call returned a saved result without starting new work. */\n reusedResult?: boolean;\n outcome?: OperationOutcome;\n failureCategory?: OperationFailureCategory;\n durationMs?: number;\n measurement?: Readonly<ScanUsageMeasurement>;\n findingCount?: number;\n reviewedSurfaceCount?: number;\n deferredCount?: number;\n pluginVersion?: string;\n providerFamily?: string;\n validationDisposition?:\n \"reportable\" | \"suppressed\" | \"not_applicable\" | \"deferred\";\n artifactComplete?: boolean;\n collection: { persisted: number; writeFailures: number };\n}\n\ninterface OperationTelemetryOptions {\n directory: string;\n protectedRepository?: string;\n protectedOutput?: string;\n command: OperationTelemetryEvent[\"command\"];\n surface: OperationTelemetryEvent[\"surface\"];\n mode?: OperationTelemetryEvent[\"mode\"];\n resumeScanId?: string;\n deferPersistence?: boolean;\n context?: { operationId: string; parentAttemptId?: string };\n onEvent?: (event: Readonly<OperationTelemetryEvent>) => void;\n onError?: (error: unknown) => void;\n}\n\n/** Local journal only. Export, acknowledgement and retention belong to the host. */\nexport class OperationTelemetry {\n readonly attemptId = randomUUID();\n operationId: string;\n measurement: Readonly<ScanUsageMeasurement> | undefined;\n reusedResult = false;\n nativeTurnFailed = false;\n readonly #started = performance.now();\n readonly #startedAt = new Date().toISOString();\n readonly #options: OperationTelemetryOptions;\n readonly #directory: string;\n #persisted = 0;\n #writeFailures = 0;\n #ready = false;\n #runtime: Pick<OperationTelemetryEvent, \"pluginVersion\" | \"providerFamily\"> =\n {};\n #finished = false;\n #usageScopeId: string = this.attemptId;\n #deferred: boolean;\n #startedEvent: OperationTelemetryEvent | undefined;\n\n constructor(options: OperationTelemetryOptions) {\n this.#options = options;\n this.operationId = options.context?.operationId ?? randomUUID();\n this.#directory = join(options.directory, \"telemetry\");\n this.#deferred = options.deferPersistence === true;\n }\n\n get context() {\n return {\n operationId: this.operationId,\n attemptId: this.attemptId,\n ...(this.#options.context?.parentAttemptId === undefined\n ? {}\n : { parentAttemptId: this.#options.context.parentAttemptId }),\n };\n }\n\n async start(): Promise<void> {\n if (!this.#deferred) await this.#preparePersistence();\n await this.#emit(\"attempt_started\");\n }\n\n /** Callers establish repository and artifact protection before any writes. */\n async activatePersistence(\n protectedRoots: readonly string[],\n savedOutput?: string,\n ): Promise<void> {\n if (!this.#deferred || this.#finished) return;\n this.#deferred = false;\n await this.#preparePersistence(protectedRoots, savedOutput);\n if (this.#startedEvent !== undefined) {\n const event = {\n ...this.#startedEvent,\n ...this.context,\n usageScopeId: this.#usageScopeId,\n collection: {\n persisted: this.#persisted + (this.#ready ? 1 : 0),\n writeFailures: this.#writeFailures,\n },\n };\n if (this.#ready) await this.#persist(event);\n if (this.#options.resumeScanId !== undefined) this.#notify(event);\n }\n this.#startedEvent = undefined;\n }\n\n async #preparePersistence(\n additionalRoots: readonly string[] = [],\n savedOutput?: string,\n ): Promise<void> {\n try {\n const protectedRoots = [...additionalRoots];\n for (const output of [this.#options.protectedOutput, savedOutput]) {\n if (output !== undefined)\n protectedRoots.push(await canonicalConfigPath(output));\n }\n if (this.#options.protectedRepository !== undefined) {\n const repository = await canonicalConfigPath(\n this.#options.protectedRepository,\n );\n protectedRoots.push(\n repository,\n ...(await gitProtectionRoots(this.#options.protectedRepository)),\n );\n }\n if (protectedRoots.length > 0) {\n requireOutputOutsideRepositories(\n protectedRoots,\n await canonicalConfigPath(this.#directory),\n \"runtime\",\n );\n }\n await requireSecureOutputAncestry(this.#directory);\n await mkdir(this.#directory, { recursive: true, mode: 0o700 });\n this.#ready = true;\n if (this.#options.resumeScanId !== undefined) {\n try {\n const saved = JSON.parse(\n await readFile(\n this.#bindingPath(this.#options.resumeScanId),\n \"utf8\",\n ),\n ) as { operationId: string; usageScopeId: string };\n this.operationId = saved.operationId;\n this.#usageScopeId = saved.usageScopeId;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\")\n this.#error(error);\n }\n }\n } catch (error) {\n this.#error(error);\n }\n }\n\n async bindScan(scanId: string): Promise<void> {\n if (!this.#ready) return;\n try {\n await writeFile(\n this.#bindingPath(scanId),\n JSON.stringify({\n ...this.context,\n usageScopeId: this.#usageScopeId,\n }),\n {\n mode: 0o600,\n },\n );\n } catch (error) {\n this.#error(error);\n }\n }\n\n describe(\n runtime: Pick<OperationTelemetryEvent, \"pluginVersion\" | \"providerFamily\">,\n ): void {\n this.#runtime = runtime;\n }\n\n async finish(\n outcome: OperationOutcome,\n details: Pick<\n OperationTelemetryEvent,\n | \"failureCategory\"\n | \"findingCount\"\n | \"artifactComplete\"\n | \"reviewedSurfaceCount\"\n | \"deferredCount\"\n | \"validationDisposition\"\n > = {},\n ): Promise<void> {\n if (this.#finished) return;\n this.#finished = true;\n if (\n this.#startedEvent !== undefined &&\n this.#options.resumeScanId !== undefined\n ) {\n this.#notify(this.#startedEvent);\n this.#startedEvent = undefined;\n }\n await this.#emit(\"attempt_finished\", {\n outcome,\n reusedResult: this.reusedResult,\n durationMs: Math.max(0, performance.now() - this.#started),\n ...(this.measurement === undefined\n ? {}\n : { measurement: this.measurement }),\n ...this.#runtime,\n ...details,\n });\n }\n\n #bindingPath(scanId: string): string {\n return join(\n this.#directory,\n `${createHash(\"sha256\").update(scanId).digest(\"hex\")}.binding.json`,\n );\n }\n\n #error(error: unknown): void {\n this.#writeFailures++;\n try {\n this.#options.onError?.(error);\n } catch {}\n }\n\n async #persist(event: OperationTelemetryEvent): Promise<void> {\n try {\n await appendFile(\n join(this.#directory, `${this.attemptId}.jsonl`),\n `${JSON.stringify(event)}\\n`,\n { mode: 0o600 },\n );\n this.#persisted++;\n } catch (error) {\n this.#error(error);\n event.collection = {\n persisted: this.#persisted,\n writeFailures: this.#writeFailures,\n };\n }\n }\n\n async #emit(\n type: OperationTelemetryEvent[\"type\"],\n details: Partial<OperationTelemetryEvent> = {},\n ): Promise<void> {\n const time = new Date().toISOString();\n const event: OperationTelemetryEvent = {\n schemaVersion: 1,\n eventId: `${this.attemptId}:${type}`,\n ...this.context,\n usageScopeId: this.#usageScopeId,\n occurredAt: type === \"attempt_started\" ? this.#startedAt : time,\n observedAt: time,\n type,\n command: this.#options.command,\n surface: this.#options.surface,\n packageVersion: VERSION,\n ...(this.#options.mode === undefined ? {} : { mode: this.#options.mode }),\n resumed: this.#options.resumeScanId !== undefined,\n ...details,\n collection: {\n persisted: this.#persisted + (this.#ready ? 1 : 0),\n writeFailures: this.#writeFailures,\n },\n };\n if (this.#ready) await this.#persist(event);\n else if (this.#deferred && type === \"attempt_started\") {\n this.#startedEvent = event;\n // Resume identity is restored only after the caller protects output paths.\n if (this.#options.resumeScanId !== undefined) return;\n }\n this.#notify(event);\n }\n\n #notify(event: OperationTelemetryEvent): void {\n // Observers cannot delay or fail the operation. Replay uses the same event ID.\n void Promise.resolve()\n .then(() => this.#options.onEvent?.(event))\n .catch(() => {});\n }\n}\n\n/** Read durable receipts, retaining explicit evidence of truncated/corrupt records. */\nexport async function readOperationTelemetry(stateDirectory: string): Promise<{\n events: OperationTelemetryEvent[];\n parseFailures: number;\n}> {\n const directory = join(stateDirectory, \"telemetry\");\n const events: OperationTelemetryEvent[] = [];\n let parseFailures = 0;\n const names = await readdir(directory).catch(\n (error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\") return [];\n throw error;\n },\n );\n for (const name of names.filter((name) => name.endsWith(\".jsonl\")).sort()) {\n for (const line of (await readFile(join(directory, name), \"utf8\")).split(\n \"\\n\",\n )) {\n if (!line) continue;\n try {\n const event = JSON.parse(line) as OperationTelemetryEvent;\n if (\n event.schemaVersion !== 1 ||\n typeof event.eventId !== \"string\" ||\n typeof event.attemptId !== \"string\" ||\n typeof event.operationId !== \"string\" ||\n typeof event.usageScopeId !== \"string\" ||\n ![\"attempt_started\", \"attempt_finished\"].includes(event.type) ||\n ((event.type === \"attempt_finished\" || event.outcome !== undefined) &&\n ![\"completed\", \"failed\", \"canceled\", \"unresolved\"].includes(\n event.outcome ?? \"\",\n )) ||\n (event.measurement !== undefined &&\n ![\"complete\", \"partial\", \"unavailable\"].includes(\n event.measurement?.coverage,\n ))\n ) {\n parseFailures++;\n } else events.push(event);\n } catch {\n parseFailures++;\n }\n }\n }\n return { events, parseFailures };\n}\n\n/** Attempts without a terminal receipt remain unresolved, including process loss. */\nexport function summarizeOperationTelemetry(\n events: readonly OperationTelemetryEvent[],\n) {\n const seen = new Set<string>();\n const attempts = new Map<string, OperationTelemetryEvent>();\n let duplicates = 0;\n for (const event of events) {\n if (seen.has(event.eventId)) {\n duplicates++;\n continue;\n }\n seen.add(event.eventId);\n const previous = attempts.get(event.attemptId);\n if (\n previous?.type !== \"attempt_finished\" ||\n event.type === \"attempt_finished\"\n )\n attempts.set(event.attemptId, event);\n }\n const operations = new Map<string, boolean>();\n const outcomes = { completed: 0, failed: 0, canceled: 0, unresolved: 0 };\n const usageCoverage = { complete: 0, partial: 0, unavailable: 0 };\n const durationMs: number[] = [];\n let observedCostUsd = 0;\n let pricedAttempts = 0;\n let reusedAttempts = 0;\n const costsByScope = new Map<string, number>();\n for (const event of attempts.values()) {\n operations.set(\n event.operationId,\n operations.get(event.operationId) === true ||\n event.outcome === \"completed\",\n );\n outcomes[event.outcome ?? \"unresolved\"]++;\n if (event.reusedResult === true) reusedAttempts++;\n else usageCoverage[event.measurement?.coverage ?? \"unavailable\"]++;\n if (event.durationMs !== undefined) durationMs.push(event.durationMs);\n if (event.measurement?.cost != null) {\n costsByScope.set(\n event.usageScopeId,\n Math.max(\n costsByScope.get(event.usageScopeId) ?? 0,\n event.measurement.cost.estimatedUsd,\n ),\n );\n pricedAttempts++;\n }\n }\n for (const cost of costsByScope.values()) observedCostUsd += cost;\n return {\n operations: operations.size,\n successfulOperations: [...operations.values()].filter(Boolean).length,\n attempts: attempts.size,\n outcomes,\n usageCoverage,\n durationMs,\n observedCostUsd,\n pricedAttempts,\n reusedAttempts,\n duplicates,\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-python-probe.d.ts","sourceRoot":"","sources":["../src/plugin-python-probe.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,6BAA6B,CAAC;AAE9D,eAAO,MAAM,8BAA8B,QAAS,CAAC;AAErD,eAAO,MAAM,mBAAmB,QAKpB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const PLUGIN_PYTHON_READY = "codex-security-python-ok";
|
|
2
|
+
// Cold Python startup can exceed five seconds on busy Windows hosts.
|
|
3
|
+
export const PLUGIN_PYTHON_PROBE_TIMEOUT_MS = 30_000;
|
|
4
|
+
export const PLUGIN_PYTHON_PROBE = [
|
|
5
|
+
"import importlib.util,sys",
|
|
6
|
+
"if sys.version_info < (3, 10): raise SystemExit(1)",
|
|
7
|
+
"if sys.version_info < (3, 11) and importlib.util.find_spec('tomli') is None: raise SystemExit(1)",
|
|
8
|
+
`print('${PLUGIN_PYTHON_READY}')`,
|
|
9
|
+
].join("\n");
|
|
10
|
+
//# sourceMappingURL=plugin-python-probe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-python-probe.js","sourceRoot":"","sources":["../src/plugin-python-probe.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAC9D,qEAAqE;AACrE,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAM,CAAC;AAErD,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,2BAA2B;IAC3B,oDAAoD;IACpD,kGAAkG;IAClG,UAAU,mBAAmB,IAAI;CAClC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC","sourcesContent":["export const PLUGIN_PYTHON_READY = \"codex-security-python-ok\";\n// Cold Python startup can exceed five seconds on busy Windows hosts.\nexport const PLUGIN_PYTHON_PROBE_TIMEOUT_MS = 30_000;\n\nexport const PLUGIN_PYTHON_PROBE = [\n \"import importlib.util,sys\",\n \"if sys.version_info < (3, 10): raise SystemExit(1)\",\n \"if sys.version_info < (3, 11) and importlib.util.find_spec('tomli') is None: raise SystemExit(1)\",\n `print('${PLUGIN_PYTHON_READY}')`,\n].join(\"\\n\");\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
import type { ExternalFinding, ExternalFindings } from "./external-findings.js";
|
|
2
|
+
import type { ExternalFinding } from "./external-findings.js";
|
|
4
3
|
import type { ImportSource } from "./external-import-models.js";
|
|
5
4
|
declare const privateFormat: z.ZodEnum<{
|
|
6
5
|
"endor.findings_json.v1": "endor.findings_json.v1";
|
|
@@ -8,6 +7,9 @@ declare const privateFormat: z.ZodEnum<{
|
|
|
8
7
|
"wiz.vulnerability_json.v1": "wiz.vulnerability_json.v1";
|
|
9
8
|
}>;
|
|
10
9
|
export type PrivateImportFormat = z.infer<typeof privateFormat>;
|
|
10
|
+
declare const jobVersion: z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>]>;
|
|
11
|
+
export type PrivateJobVersion = z.infer<typeof jobVersion>;
|
|
12
|
+
export declare const privateJobVersions: Partial<Record<ImportSource["provider"], PrivateJobVersion>>;
|
|
11
13
|
declare const contextSchema: z.ZodObject<{
|
|
12
14
|
object: z.ZodLiteral<"security.finding_import_context">;
|
|
13
15
|
context_version: z.ZodString;
|
|
@@ -71,9 +73,98 @@ export declare function privateReport(findings: ExternalFinding[], limits: Priva
|
|
|
71
73
|
bytes: string;
|
|
72
74
|
digest: string;
|
|
73
75
|
};
|
|
74
|
-
|
|
76
|
+
/** Encode only the reviewed occurrences, whether they came from a file or the workbench. */
|
|
77
|
+
export declare function selectPrivateReport(findings: ExternalFinding[], provider: string, context: PrivateImportContext, approvedFormat?: PrivateImportFormat): ReturnType<typeof privateReport>;
|
|
75
78
|
export declare function unsuccessfulJob(job: PrivateImportJob | undefined): boolean;
|
|
76
|
-
export declare function
|
|
79
|
+
export declare function parsePrivateCheckpoint(serialized: string | undefined): {
|
|
80
|
+
format: "endor.findings_json.v1" | "security.findings.v1" | "wiz.vulnerability_json.v1";
|
|
81
|
+
apiBaseUrl: string;
|
|
82
|
+
accountId: string;
|
|
83
|
+
contextVersion: string;
|
|
84
|
+
sha256: string;
|
|
85
|
+
source: {
|
|
86
|
+
provider: string;
|
|
87
|
+
source_key: string;
|
|
88
|
+
};
|
|
89
|
+
repository: {
|
|
90
|
+
id: string;
|
|
91
|
+
repo_connector_id: string;
|
|
92
|
+
};
|
|
93
|
+
uploadRequestId: string;
|
|
94
|
+
jobRequestId: string;
|
|
95
|
+
jobApiVersion?: 2 | 3 | undefined;
|
|
96
|
+
approvedRepositoryUrl: string;
|
|
97
|
+
approvedRepositoryPlatform?: "other" | undefined;
|
|
98
|
+
fileId?: string | undefined;
|
|
99
|
+
jobId?: string | undefined;
|
|
100
|
+
receipt?: {
|
|
101
|
+
object: "security.finding_import_job";
|
|
102
|
+
id: string;
|
|
103
|
+
request_id: string;
|
|
104
|
+
source: {
|
|
105
|
+
provider: string;
|
|
106
|
+
source_key: string;
|
|
107
|
+
};
|
|
108
|
+
input: {
|
|
109
|
+
type: "file";
|
|
110
|
+
file_id: string;
|
|
111
|
+
format: "endor.findings_json.v1" | "security.findings.v1" | "wiz.vulnerability_json.v1";
|
|
112
|
+
};
|
|
113
|
+
default_targets: {
|
|
114
|
+
type: "repository";
|
|
115
|
+
repo_id: string;
|
|
116
|
+
repo_connector_id: string;
|
|
117
|
+
}[];
|
|
118
|
+
status: "cancelled" | "cancelling" | "completed" | "failed" | "in_progress" | "queued";
|
|
119
|
+
counts: {
|
|
120
|
+
total: number | null;
|
|
121
|
+
discovered: number;
|
|
122
|
+
created: number;
|
|
123
|
+
updated: number;
|
|
124
|
+
unchanged: number;
|
|
125
|
+
error: number;
|
|
126
|
+
unprocessed: number;
|
|
127
|
+
};
|
|
128
|
+
poll_after_seconds: number | null;
|
|
129
|
+
error: {
|
|
130
|
+
message: string;
|
|
131
|
+
} | null;
|
|
132
|
+
} | undefined;
|
|
133
|
+
previousReceipt?: {
|
|
134
|
+
object: "security.finding_import_job";
|
|
135
|
+
id: string;
|
|
136
|
+
request_id: string;
|
|
137
|
+
source: {
|
|
138
|
+
provider: string;
|
|
139
|
+
source_key: string;
|
|
140
|
+
};
|
|
141
|
+
input: {
|
|
142
|
+
type: "file";
|
|
143
|
+
file_id: string;
|
|
144
|
+
format: "endor.findings_json.v1" | "security.findings.v1" | "wiz.vulnerability_json.v1";
|
|
145
|
+
};
|
|
146
|
+
default_targets: {
|
|
147
|
+
type: "repository";
|
|
148
|
+
repo_id: string;
|
|
149
|
+
repo_connector_id: string;
|
|
150
|
+
}[];
|
|
151
|
+
status: "cancelled" | "cancelling" | "completed" | "failed" | "in_progress" | "queued";
|
|
152
|
+
counts: {
|
|
153
|
+
total: number | null;
|
|
154
|
+
discovered: number;
|
|
155
|
+
created: number;
|
|
156
|
+
updated: number;
|
|
157
|
+
unchanged: number;
|
|
158
|
+
error: number;
|
|
159
|
+
unprocessed: number;
|
|
160
|
+
};
|
|
161
|
+
poll_after_seconds: number | null;
|
|
162
|
+
error: {
|
|
163
|
+
message: string;
|
|
164
|
+
} | null;
|
|
165
|
+
} | undefined;
|
|
166
|
+
} | undefined;
|
|
167
|
+
export declare function readPrivateCheckpoint(checkpoint: ReturnType<typeof parsePrivateCheckpoint>, expected: {
|
|
77
168
|
format: PrivateImportFormat;
|
|
78
169
|
apiBaseUrl: string;
|
|
79
170
|
accountId: string;
|
|
@@ -100,6 +191,9 @@ export declare function readPrivateCheckpoint(serialized: string, expected: {
|
|
|
100
191
|
};
|
|
101
192
|
uploadRequestId: string;
|
|
102
193
|
jobRequestId: string;
|
|
194
|
+
jobApiVersion?: 2 | 3 | undefined;
|
|
195
|
+
approvedRepositoryUrl: string;
|
|
196
|
+
approvedRepositoryPlatform?: "other" | undefined;
|
|
103
197
|
fileId?: string | undefined;
|
|
104
198
|
jobId?: string | undefined;
|
|
105
199
|
receipt?: {
|
|
@@ -169,11 +263,6 @@ export declare function readPrivateCheckpoint(serialized: string, expected: {
|
|
|
169
263
|
} | null;
|
|
170
264
|
} | undefined;
|
|
171
265
|
} | undefined;
|
|
172
|
-
export declare class PrivateImportRequestError extends CodexSecurityError {
|
|
173
|
-
readonly status: number;
|
|
174
|
-
readonly code: string | undefined;
|
|
175
|
-
constructor(status: number, code: string | undefined, message: string);
|
|
176
|
-
}
|
|
177
266
|
export declare function privateImportClient(base: string, credentials: {
|
|
178
267
|
access_token: string;
|
|
179
268
|
account_id: string;
|
|
@@ -208,6 +297,7 @@ export declare function privateImportClient(base: string, credentials: {
|
|
|
208
297
|
repo_connector_id: string;
|
|
209
298
|
};
|
|
210
299
|
jobId?: string;
|
|
300
|
+
jobApiVersion?: PrivateJobVersion;
|
|
211
301
|
}, accepted: (id: string) => Promise<void>): Promise<{
|
|
212
302
|
object: "security.finding_import_job";
|
|
213
303
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private-finding-import.d.ts","sourceRoot":"","sources":["../src/private-finding-import.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"private-finding-import.d.ts","sourceRoot":"","sources":["../src/private-finding-import.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAKhE,QAAA,MAAM,aAAa;;;;EAIjB,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAChE,QAAA,MAAM,UAAU,yDAAwC,CAAC;AAC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1,26 @@
|
|
|
1
1
|
import { hash } from "node:crypto";
|
|
2
|
-
import { constants } from "node:fs";
|
|
3
|
-
import { open } from "node:fs/promises";
|
|
4
2
|
import { setTimeout as delay } from "node:timers/promises";
|
|
5
3
|
import { z } from "zod";
|
|
6
4
|
import { CodexSecurityError } from "./errors.js";
|
|
5
|
+
import { normalizeEndorFindings, requiresStructuredEndorReport, } from "./endor-findings.js";
|
|
7
6
|
import { canonicalJson, isRecord } from "./record.js";
|
|
7
|
+
import { normalizeWizJson } from "./wiz-findings.js";
|
|
8
8
|
const structuredFormat = "security.findings.v1";
|
|
9
9
|
const privateFormat = z.enum([
|
|
10
10
|
structuredFormat,
|
|
11
11
|
"endor.findings_json.v1",
|
|
12
12
|
"wiz.vulnerability_json.v1",
|
|
13
13
|
]);
|
|
14
|
+
const jobVersion = z.union([z.literal(2), z.literal(3)]);
|
|
15
|
+
export const privateJobVersions = {
|
|
16
|
+
inspector: 2,
|
|
17
|
+
continuum: 2,
|
|
18
|
+
blackduck: 3,
|
|
19
|
+
checkmarx: 3,
|
|
20
|
+
sonar: 3,
|
|
21
|
+
trivy: 3,
|
|
22
|
+
veracode: 3,
|
|
23
|
+
};
|
|
14
24
|
const fileId = z.string().regex(/^aifile_[0-9a-f]{32}$/u);
|
|
15
25
|
const contextSchema = z.object({
|
|
16
26
|
object: z.literal("security.finding_import_context"),
|
|
@@ -66,6 +76,8 @@ const jobSchema = z.object({
|
|
|
66
76
|
poll_after_seconds: z.int().positive().nullable(),
|
|
67
77
|
error: z.object({ message: z.string() }).nullable(),
|
|
68
78
|
});
|
|
79
|
+
class PrivateReportSizeError extends CodexSecurityError {
|
|
80
|
+
}
|
|
69
81
|
export function privateReport(findings, limits) {
|
|
70
82
|
if (findings.length > 10_000)
|
|
71
83
|
throw new CodexSecurityError("A structured report accepts up to 10,000 findings. Split this selection.");
|
|
@@ -87,151 +99,97 @@ export function privateReport(findings, limits) {
|
|
|
87
99
|
},
|
|
88
100
|
};
|
|
89
101
|
if (Buffer.byteLength(canonicalJson(record)) > limits.max_record_bytes)
|
|
90
|
-
throw new
|
|
102
|
+
throw new PrivateReportSizeError(`Finding ${JSON.stringify(source_finding_id)} exceeds the private import record limit.`);
|
|
91
103
|
return record;
|
|
92
104
|
});
|
|
93
105
|
const bytes = canonicalJson({ format: structuredFormat, findings: records });
|
|
94
106
|
if (Buffer.byteLength(bytes) > limits.max_direct_file_bytes)
|
|
95
|
-
throw new
|
|
107
|
+
throw new PrivateReportSizeError("The selected report exceeds the Cloud direct-upload limit. Split this selection.");
|
|
96
108
|
return {
|
|
97
109
|
format: structuredFormat,
|
|
98
110
|
bytes,
|
|
99
111
|
digest: hash("sha256", bytes),
|
|
100
112
|
};
|
|
101
113
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
response: z
|
|
106
|
-
.strictObject({
|
|
107
|
-
next_page_id: z.literal(["", null]).optional(),
|
|
108
|
-
next_page_token: z.literal(["", "0", 0, null]).optional(),
|
|
109
|
-
total_size: z.union([z.string(), z.number()]).optional(),
|
|
110
|
-
})
|
|
111
|
-
.optional(),
|
|
112
|
-
}),
|
|
113
|
-
});
|
|
114
|
-
const wizExport = z.strictObject({
|
|
115
|
-
vulnerabilityFindings: z.strictObject({
|
|
116
|
-
nodes: z.array(z.unknown()),
|
|
117
|
-
pageInfo: z
|
|
118
|
-
.strictObject({
|
|
119
|
-
hasNextPage: z.literal(false).optional(),
|
|
120
|
-
hasPreviousPage: z.literal(false).optional(),
|
|
121
|
-
startCursor: z.string().nullable().optional(),
|
|
122
|
-
endCursor: z.string().nullable().optional(),
|
|
123
|
-
})
|
|
124
|
-
.optional(),
|
|
125
|
-
}),
|
|
126
|
-
});
|
|
127
|
-
// Only complete, known envelopes can be sent byte for byte. Unreviewed sibling
|
|
128
|
-
// collections, metadata or partial pages keep the normalized projection.
|
|
129
|
-
function nativeRecords(payload, provider) {
|
|
130
|
-
if (provider === "wiz" && Array.isArray(payload))
|
|
131
|
-
return payload;
|
|
132
|
-
if (!isRecord(payload))
|
|
133
|
-
return;
|
|
134
|
-
if (provider === "endor") {
|
|
135
|
-
if (isRecord(payload["spec"]))
|
|
136
|
-
return [payload];
|
|
137
|
-
return endorExport.safeParse(payload).data?.list.objects;
|
|
138
|
-
}
|
|
139
|
-
if (typeof payload["id"] === "string")
|
|
140
|
-
return [payload];
|
|
141
|
-
const data = Object.keys(payload).length === 1 && "data" in payload
|
|
142
|
-
? payload["data"]
|
|
143
|
-
: payload;
|
|
144
|
-
return wizExport.safeParse(data).data?.vulnerabilityFindings.nodes;
|
|
145
|
-
}
|
|
146
|
-
export async function selectPrivateReport(selection, provider, path, context, saved) {
|
|
147
|
-
const checkpoint = saved === undefined ? undefined : checkpointSchema.parse(JSON.parse(saved));
|
|
148
|
-
const originalFormat = checkpoint?.contextVersion === context.context_version
|
|
149
|
-
? checkpoint.format
|
|
150
|
-
: undefined;
|
|
151
|
-
const format = provider === "endor"
|
|
114
|
+
/** Encode only the reviewed occurrences, whether they came from a file or the workbench. */
|
|
115
|
+
export function selectPrivateReport(findings, provider, context, approvedFormat) {
|
|
116
|
+
const nativeFormat = provider === "endor"
|
|
152
117
|
? "endor.findings_json.v1"
|
|
153
118
|
: provider === "wiz"
|
|
154
119
|
? "wiz.vulnerability_json.v1"
|
|
155
120
|
: undefined;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
? originalFormat === format
|
|
163
|
-
: context.formats.includes(format))) {
|
|
164
|
-
const handle = await open(path, constants.O_RDONLY | (constants.O_NONBLOCK ?? 0));
|
|
165
|
-
let bytes;
|
|
121
|
+
let format = approvedFormat ??
|
|
122
|
+
(context.formats.includes(structuredFormat)
|
|
123
|
+
? structuredFormat
|
|
124
|
+
: nativeFormat);
|
|
125
|
+
let sizeError;
|
|
126
|
+
if (!nativeFormat || !format || format === structuredFormat) {
|
|
166
127
|
try {
|
|
167
|
-
|
|
168
|
-
if (info.isFile() &&
|
|
169
|
-
info.size > 0 &&
|
|
170
|
-
info.size <= context.limits.max_direct_file_bytes) {
|
|
171
|
-
const buffer = Buffer.alloc(info.size + 1);
|
|
172
|
-
let count = 0;
|
|
173
|
-
while (count < buffer.length) {
|
|
174
|
-
const { bytesRead } = await handle.read(buffer, count, buffer.length - count);
|
|
175
|
-
if (bytesRead === 0)
|
|
176
|
-
break;
|
|
177
|
-
count += bytesRead;
|
|
178
|
-
}
|
|
179
|
-
if (count === info.size) {
|
|
180
|
-
try {
|
|
181
|
-
bytes = new TextDecoder("utf-8", {
|
|
182
|
-
fatal: true,
|
|
183
|
-
ignoreBOM: true,
|
|
184
|
-
}).decode(buffer.subarray(0, count));
|
|
185
|
-
}
|
|
186
|
-
catch {
|
|
187
|
-
/* Binary exports use the normalized selection. */
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
128
|
+
return privateReport(findings, context.limits);
|
|
191
129
|
}
|
|
192
|
-
|
|
193
|
-
|
|
130
|
+
catch (error) {
|
|
131
|
+
if (!(error instanceof PrivateReportSizeError) ||
|
|
132
|
+
approvedFormat ||
|
|
133
|
+
!nativeFormat ||
|
|
134
|
+
!context.formats.includes(nativeFormat))
|
|
135
|
+
throw error;
|
|
136
|
+
sizeError = error;
|
|
137
|
+
format = nativeFormat;
|
|
194
138
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
139
|
+
}
|
|
140
|
+
if (!approvedFormat && !context.formats.includes(format))
|
|
141
|
+
throw new CodexSecurityError("Private findings import is unavailable for this report format.");
|
|
142
|
+
// The native endpoint derives its own evidence. Verify that it will receive
|
|
143
|
+
// the selected occurrences with exactly the fields the user reviewed.
|
|
144
|
+
const rows = findings.map(({ evidence }) => evidence.source_data);
|
|
145
|
+
const endor = provider === "endor";
|
|
146
|
+
const payload = endor ? { list: { objects: rows } } : rows;
|
|
147
|
+
let totalRowBytes = 0;
|
|
148
|
+
if (format === nativeFormat &&
|
|
149
|
+
findings.length > 0 &&
|
|
150
|
+
findings.length <= 10_000 &&
|
|
151
|
+
rows.every((row, i) => {
|
|
152
|
+
if (!isRecord(row))
|
|
153
|
+
return false;
|
|
154
|
+
const id = findings[i].source_finding_id;
|
|
155
|
+
const bytes = Buffer.byteLength(canonicalJson(row));
|
|
156
|
+
totalRowBytes += bytes;
|
|
157
|
+
return (row[endor ? "uuid" : "id"] === id &&
|
|
158
|
+
id === id.trim() &&
|
|
159
|
+
(endor || !("source_finding_id" in row)) &&
|
|
160
|
+
bytes <= context.limits.max_record_bytes &&
|
|
161
|
+
totalRowBytes <= context.limits.max_direct_file_bytes);
|
|
162
|
+
})) {
|
|
163
|
+
const projected = endor
|
|
164
|
+
? normalizeEndorFindings(payload)
|
|
165
|
+
: normalizeWizJson(payload, "cloud");
|
|
166
|
+
if (!projected.excluded.length &&
|
|
167
|
+
!requiresStructuredEndorReport(projected) &&
|
|
168
|
+
projected.findings.length === findings.length &&
|
|
169
|
+
projected.findings.every((row, i) => row.source_finding_id === findings[i].source_finding_id &&
|
|
170
|
+
canonicalJson(row.evidence) === canonicalJson(findings[i].evidence))) {
|
|
171
|
+
const bytes = canonicalJson(payload);
|
|
172
|
+
if (Buffer.byteLength(bytes) <= context.limits.max_direct_file_bytes)
|
|
218
173
|
return { format, bytes, digest: hash("sha256", bytes) };
|
|
219
174
|
}
|
|
220
175
|
}
|
|
221
|
-
if (
|
|
222
|
-
throw
|
|
223
|
-
|
|
176
|
+
if (sizeError)
|
|
177
|
+
throw sizeError;
|
|
178
|
+
throw new CodexSecurityError(`The selection cannot be represented exactly within the limits of ${nativeFormat}. This Cloud service must support ${structuredFormat} to publish it.`);
|
|
224
179
|
}
|
|
225
180
|
const checkpointSchema = z.object({
|
|
226
|
-
format: privateFormat
|
|
181
|
+
format: privateFormat,
|
|
227
182
|
apiBaseUrl: z.string(),
|
|
228
183
|
accountId: z.string(),
|
|
229
184
|
contextVersion: z.string(),
|
|
230
185
|
sha256: z.string(),
|
|
231
|
-
source:
|
|
186
|
+
source: jobSchema.shape.source,
|
|
232
187
|
repository: z.object({ id: z.string(), repo_connector_id: z.string() }),
|
|
233
188
|
uploadRequestId: z.uuid(),
|
|
234
189
|
jobRequestId: z.uuid(),
|
|
190
|
+
jobApiVersion: jobVersion.optional(),
|
|
191
|
+
approvedRepositoryUrl: z.string(),
|
|
192
|
+
approvedRepositoryPlatform: z.literal("other").optional(),
|
|
235
193
|
fileId: fileId.optional(),
|
|
236
194
|
jobId: jobSchema.shape.id.optional(),
|
|
237
195
|
receipt: jobSchema
|
|
@@ -239,33 +197,45 @@ const checkpointSchema = z.object({
|
|
|
239
197
|
.optional(),
|
|
240
198
|
previousReceipt: jobSchema.refine(unsuccessfulJob).optional(),
|
|
241
199
|
});
|
|
200
|
+
function matchesJobScope(job, scope) {
|
|
201
|
+
const [target] = job.default_targets;
|
|
202
|
+
return (job.input.format === scope.format &&
|
|
203
|
+
job.source.provider === scope.source.provider &&
|
|
204
|
+
job.source.source_key === scope.source.source_key &&
|
|
205
|
+
job.default_targets.length === 1 &&
|
|
206
|
+
target?.repo_id === scope.repository.id &&
|
|
207
|
+
target.repo_connector_id === scope.repository.repo_connector_id);
|
|
208
|
+
}
|
|
242
209
|
export function unsuccessfulJob(job) {
|
|
243
210
|
return job?.status === "failed" || job?.status === "cancelled";
|
|
244
211
|
}
|
|
245
|
-
export function
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
212
|
+
export function parsePrivateCheckpoint(serialized) {
|
|
213
|
+
return serialized === undefined
|
|
214
|
+
? undefined
|
|
215
|
+
: checkpointSchema.parse(JSON.parse(serialized));
|
|
216
|
+
}
|
|
217
|
+
export function readPrivateCheckpoint(checkpoint, expected) {
|
|
218
|
+
if (!checkpoint)
|
|
219
|
+
return;
|
|
220
|
+
const { fileId, jobId, receipt, previousReceipt } = checkpoint;
|
|
221
|
+
const { apiBaseUrl, accountId, source, repository } = checkpoint;
|
|
222
|
+
const { contextVersion, format, sha256, ...scope } = expected;
|
|
223
|
+
const sameContext = checkpoint.contextVersion === contextVersion;
|
|
224
|
+
if (canonicalJson({ apiBaseUrl, accountId, source, repository }) !==
|
|
225
|
+
canonicalJson(scope) ||
|
|
226
|
+
(sameContext &&
|
|
227
|
+
(checkpoint.format !== format || checkpoint.sha256 !== sha256)) ||
|
|
252
228
|
(jobId && !fileId) ||
|
|
253
|
-
[receipt, previousReceipt].some((job) => job &&
|
|
254
|
-
(job.input.format !== format ||
|
|
255
|
-
canonicalJson(job.source) !== canonicalJson(scope.source) ||
|
|
256
|
-
job.default_targets.length !== 1 ||
|
|
257
|
-
job.default_targets[0]?.repo_id !== scope.repository.id ||
|
|
258
|
-
job.default_targets[0]?.repo_connector_id !==
|
|
259
|
-
scope.repository.repo_connector_id)) ||
|
|
229
|
+
[receipt, previousReceipt].some((job) => job && !matchesJobScope(job, checkpoint)) ||
|
|
260
230
|
(receipt &&
|
|
261
231
|
(receipt.id !== jobId ||
|
|
262
|
-
receipt.request_id !== jobRequestId ||
|
|
232
|
+
receipt.request_id !== checkpoint.jobRequestId ||
|
|
263
233
|
receipt.input.file_id !== fileId)) ||
|
|
264
|
-
uploadRequestId === jobRequestId)
|
|
234
|
+
checkpoint.uploadRequestId === checkpoint.jobRequestId)
|
|
265
235
|
throw new CodexSecurityError("Saved private import does not match this account, repository or report.");
|
|
266
236
|
return sameContext ? checkpoint : undefined;
|
|
267
237
|
}
|
|
268
|
-
|
|
238
|
+
class PrivateImportRequestError extends CodexSecurityError {
|
|
269
239
|
status;
|
|
270
240
|
code;
|
|
271
241
|
constructor(status, code, message) {
|
|
@@ -277,7 +247,7 @@ export class PrivateImportRequestError extends CodexSecurityError {
|
|
|
277
247
|
export function privateImportClient(base, credentials, fetch, signal) {
|
|
278
248
|
async function request(path, body) {
|
|
279
249
|
const timeout = AbortSignal.timeout(body === undefined ? 30_000 : 60_000);
|
|
280
|
-
const response = await fetch(`${base}
|
|
250
|
+
const response = await fetch(`${base}${path}`, {
|
|
281
251
|
method: body === undefined ? "GET" : "POST",
|
|
282
252
|
body,
|
|
283
253
|
redirect: "error",
|
|
@@ -305,13 +275,13 @@ export function privateImportClient(base, credentials, fetch, signal) {
|
|
|
305
275
|
}
|
|
306
276
|
return {
|
|
307
277
|
async context() {
|
|
308
|
-
return contextSchema.parse(await (await request("context")).json());
|
|
278
|
+
return contextSchema.parse(await (await request("/finding-imports/context")).json());
|
|
309
279
|
},
|
|
310
280
|
async upload(input) {
|
|
311
281
|
let response;
|
|
312
282
|
if (input.recovering) {
|
|
313
283
|
try {
|
|
314
|
-
response = await request(
|
|
284
|
+
response = await request(`/finding-imports/file-requests/${input.requestId}`);
|
|
315
285
|
}
|
|
316
286
|
catch (error) {
|
|
317
287
|
if (!(error instanceof PrivateImportRequestError) ||
|
|
@@ -326,7 +296,7 @@ export function privateImportClient(base, credentials, fetch, signal) {
|
|
|
326
296
|
form.set("context_version", input.contextVersion);
|
|
327
297
|
form.set("purpose", "report");
|
|
328
298
|
form.set("file", new Blob([input.bytes], { type: "application/json" }), "findings.json");
|
|
329
|
-
response = await request("files", form);
|
|
299
|
+
response = await request("/finding-imports/files", form);
|
|
330
300
|
}
|
|
331
301
|
const file = fileSchema.parse(await response.json());
|
|
332
302
|
if (file.sha256 !== input.digest ||
|
|
@@ -335,10 +305,12 @@ export function privateImportClient(base, credentials, fetch, signal) {
|
|
|
335
305
|
return file.id;
|
|
336
306
|
},
|
|
337
307
|
async job(input, accepted) {
|
|
308
|
+
const prefix = input.jobApiVersion ? `/v${input.jobApiVersion}` : "";
|
|
309
|
+
const jobs = prefix + "/finding-imports/jobs";
|
|
338
310
|
let id = input.jobId;
|
|
339
311
|
let response = id
|
|
340
|
-
? await request(
|
|
341
|
-
: await request(
|
|
312
|
+
? await request(`${jobs}/${id}`)
|
|
313
|
+
: await request(jobs, JSON.stringify({
|
|
342
314
|
request_id: input.requestId,
|
|
343
315
|
context_version: input.contextVersion,
|
|
344
316
|
source: input.source,
|
|
@@ -360,17 +332,9 @@ export function privateImportClient(base, credentials, fetch, signal) {
|
|
|
360
332
|
if ((id !== undefined && job.id !== id) ||
|
|
361
333
|
job.request_id !== input.requestId ||
|
|
362
334
|
job.input.file_id !== input.fileId ||
|
|
363
|
-
job
|
|
364
|
-
job.source.provider !== input.source.provider ||
|
|
365
|
-
job.source.source_key !== input.source.source_key ||
|
|
366
|
-
job.default_targets.length !== 1 ||
|
|
367
|
-
job.default_targets[0]?.repo_id !== input.repository.id ||
|
|
368
|
-
job.default_targets[0]?.repo_connector_id !==
|
|
369
|
-
input.repository.repo_connector_id)
|
|
335
|
+
!matchesJobScope(job, input))
|
|
370
336
|
throw new CodexSecurityError("Cloud returned a job for a different private import.");
|
|
371
|
-
if (job.status === "completed" ||
|
|
372
|
-
job.status === "failed" ||
|
|
373
|
-
job.status === "cancelled")
|
|
337
|
+
if (job.status === "completed" || unsuccessfulJob(job))
|
|
374
338
|
return job;
|
|
375
339
|
if (!id) {
|
|
376
340
|
id = job.id;
|
|
@@ -379,7 +343,7 @@ export function privateImportClient(base, credentials, fetch, signal) {
|
|
|
379
343
|
const retry = response.headers.get("Retry-After");
|
|
380
344
|
const seconds = retry === null ? 0 : Number(retry);
|
|
381
345
|
await delay(Math.max(Number.isFinite(seconds) ? seconds : 0, job.poll_after_seconds ?? 1) * 1000, undefined, { signal });
|
|
382
|
-
response = await request(
|
|
346
|
+
response = await request(`${jobs}/${id}`);
|
|
383
347
|
}
|
|
384
348
|
},
|
|
385
349
|
};
|