@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
package/dist/deep-config.js
CHANGED
|
@@ -4,9 +4,9 @@ import { basename, dirname, join } from "node:path";
|
|
|
4
4
|
import { parse as parseToml } from "smol-toml";
|
|
5
5
|
import { writeCodexConfig } from "./config.js";
|
|
6
6
|
import { canonicalConfigPath } from "./runtime.js";
|
|
7
|
-
import { DEFAULT_DEEP_SCAN_SETTINGS } from "./deep-scan-defaults.js";
|
|
7
|
+
import { DEEP_SCAN_SETTINGS, DEFAULT_DEEP_SCAN_SETTINGS, hoursConflict, } from "./deep-scan-defaults.js";
|
|
8
8
|
import { CodexSecurityError } from "./errors.js";
|
|
9
|
-
import { DEFAULT_SCAN_MODE,
|
|
9
|
+
import { DEFAULT_SCAN_MODE, DeepScanSettingsSchema, ScanSettingsSchema, } from "./scan-settings.js";
|
|
10
10
|
export function deepScanOptions(options) {
|
|
11
11
|
const selected = {};
|
|
12
12
|
const minutes = ScanSettingsSchema.shape.maxTimeMinutes.safeParse(options.maxTimeMinutes);
|
|
@@ -27,9 +27,7 @@ export function deepScanOptions(options) {
|
|
|
27
27
|
throw new CodexSecurityError("Deep scan maxTimeMinutes / --max-time must be no greater than 5760 minutes.");
|
|
28
28
|
}
|
|
29
29
|
const hours = minutes.data / 60;
|
|
30
|
-
if (selected.maxTimeHours
|
|
31
|
-
Math.abs(selected.maxTimeHours - hours) >
|
|
32
|
-
Number.EPSILON * Math.max(selected.maxTimeHours, hours)) {
|
|
30
|
+
if (hoursConflict(hours, selected.maxTimeHours)) {
|
|
33
31
|
throw new CodexSecurityError("Conflicting maxTimeMinutes / --max-time and maxTimeHours / --max-time-hours settings.");
|
|
34
32
|
}
|
|
35
33
|
selected.maxTimeHours = hours;
|
|
@@ -66,32 +64,27 @@ export async function resolveDeepScanConfig(options, source, signal) {
|
|
|
66
64
|
if (unknown.length > 0) {
|
|
67
65
|
throw new CodexSecurityError(`Unknown Codex Security Deep Scan configuration ${unknown.join(", ")} in ${source}.`);
|
|
68
66
|
}
|
|
69
|
-
const settings = {
|
|
70
|
-
...DEFAULT_DEEP_SCAN_SETTINGS,
|
|
71
|
-
};
|
|
67
|
+
const settings = { ...DEFAULT_DEEP_SCAN_SETTINGS };
|
|
72
68
|
const sources = {};
|
|
73
69
|
for (const [name, key] of DEEP_SCAN_SETTINGS) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
: DEFAULT_DEEP_SCAN_SETTINGS[name];
|
|
77
|
-
if (name === "workers" && value === "auto")
|
|
78
|
-
value = DEFAULT_DEEP_SCAN_SETTINGS.workers;
|
|
79
|
-
if (explicit[name] !== undefined)
|
|
80
|
-
value = explicit[name];
|
|
70
|
+
const legacy = Object.hasOwn(configured, key) ? configured[key] : undefined;
|
|
71
|
+
const override = explicit[name];
|
|
81
72
|
sources[name] =
|
|
82
|
-
|
|
73
|
+
override !== undefined
|
|
83
74
|
? "override"
|
|
84
|
-
:
|
|
75
|
+
: legacy !== undefined
|
|
85
76
|
? "legacy"
|
|
86
77
|
: "default";
|
|
87
|
-
|
|
78
|
+
const value = override ?? legacy ?? settings[name];
|
|
79
|
+
settings[name] = requireDeepScanValue(name, name === "workers" && value === "auto"
|
|
80
|
+
? DEFAULT_DEEP_SCAN_SETTINGS.workers
|
|
81
|
+
: value, sources[name] === "legacy" ? `${key} in ${source}` : name);
|
|
88
82
|
}
|
|
89
83
|
return {
|
|
90
84
|
settings,
|
|
91
85
|
sources,
|
|
92
86
|
source,
|
|
93
87
|
document,
|
|
94
|
-
overrides: explicit,
|
|
95
88
|
};
|
|
96
89
|
}
|
|
97
90
|
export async function writeDeepScanConfig(destination, resolved, workerRuntime) {
|
|
@@ -99,26 +92,22 @@ export async function writeDeepScanConfig(destination, resolved, workerRuntime)
|
|
|
99
92
|
canonicalConfigPath(resolved.source),
|
|
100
93
|
runtimeConfigPath(destination),
|
|
101
94
|
]);
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
//
|
|
110
|
-
// inherited defaults unset so future releases can still update them.
|
|
111
|
-
const settings = sameFile ? resolved.overrides : resolved.settings;
|
|
112
|
-
const retainAmbientSettings = sameFile &&
|
|
113
|
-
DEEP_SCAN_SETTINGS.some(([name]) => settings[name] === undefined);
|
|
95
|
+
const ambient = source === target;
|
|
96
|
+
const fields = DEEP_SCAN_SETTINGS.filter(([name]) => !ambient || resolved.sources[name] === "override");
|
|
97
|
+
if (fields.length === 0)
|
|
98
|
+
return;
|
|
99
|
+
const document = ambient
|
|
100
|
+
? await readDeepScanDocument(destination)
|
|
101
|
+
: resolved.document;
|
|
102
|
+
// A complete snapshot replaces the Deep table. Partial ambient writes preserve other keys.
|
|
114
103
|
await writeCodexConfig(destination, {
|
|
115
104
|
...document,
|
|
116
105
|
...(workerRuntime === undefined ? {} : { worker_runtime: workerRuntime }),
|
|
117
106
|
deep_scan: {
|
|
118
|
-
...(
|
|
107
|
+
...(fields.length < DEEP_SCAN_SETTINGS.length
|
|
119
108
|
? document["deep_scan"]
|
|
120
109
|
: {}),
|
|
121
|
-
...Object.fromEntries(
|
|
110
|
+
...Object.fromEntries(fields.map(([name, key]) => [key, resolved.settings[name]])),
|
|
122
111
|
},
|
|
123
112
|
});
|
|
124
113
|
}
|
package/dist/deep-config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-config.js","sourceRoot":"","sources":["../src/deep-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,KAAK,IAAI,SAAS,EAAkB,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAmB,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,GAEnB,MAAM,oBAAoB,CAAC;AAe5B,MAAM,UAAU,eAAe,CAC7B,OAAuE;IAEvE,MAAM,QAAQ,GAAoB,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAC/D,OAAO,CAAC,cAAc,CACvB,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;AAED,KAAK,UAAU,oBAAoB,CACjC,MAAc,EACd,MAAoB;IAEpB,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,MAAM,QAAQ,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IACzE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvD,MAAM,IAAI,kBAAkB,CAC1B,+CAA+C,MAAM,GAAG,EACxD,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC","sourcesContent":["import { isRecord } from \"./record.js\";\nimport { lstat, readFile } from \"node:fs/promises\";\nimport { basename, dirname, join } from \"node:path\";\nimport { parse as parseToml, type TomlTable } from \"smol-toml\";\nimport { writeCodexConfig, type JsonObject } from \"./config.js\";\nimport { canonicalConfigPath } from \"./runtime.js\";\nimport { DEFAULT_DEEP_SCAN_SETTINGS } from \"./deep-scan-defaults.js\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport {\n DEFAULT_SCAN_MODE,\n DEEP_SCAN_SETTINGS,\n DeepScanSettingsSchema,\n ScanSettingsSchema,\n type DeepScanOptions,\n} from \"./scan-settings.js\";\nimport type { ScanMode } from \"./scan-modes.js\";\n\nexport type DeepScanSources = Record<\n keyof DeepScanOptions,\n \"default\" | \"legacy\" | \"override\"\n>;\nexport interface ResolvedDeepScanConfig {\n settings: Required<DeepScanOptions>;\n sources: DeepScanSources;\n source: string;\n document: TomlTable;\n overrides: DeepScanOptions;\n}\n\nexport function deepScanOptions(\n options: DeepScanOptions & { mode?: ScanMode; maxTimeMinutes?: number },\n): DeepScanOptions {\n const selected: DeepScanOptions = {};\n const minutes = ScanSettingsSchema.shape.maxTimeMinutes.safeParse(\n options.maxTimeMinutes,\n );\n if (!minutes.success) {\n throw new CodexSecurityError(\n \"maxTimeMinutes / --max-time must be a finite positive number of minutes.\",\n );\n }\n for (const [name] of DEEP_SCAN_SETTINGS) {\n const value = options[name];\n if (value === undefined) continue;\n if ((options.mode ?? DEFAULT_SCAN_MODE) !== \"deep\") {\n throw new CodexSecurityError(\"Deep scan settings require deep mode.\");\n }\n selected[name] = requireDeepScanValue(name, value, name);\n }\n if (minutes.data !== undefined && options.mode === \"deep\") {\n if (minutes.data > 5760) {\n throw new CodexSecurityError(\n \"Deep scan maxTimeMinutes / --max-time must be no greater than 5760 minutes.\",\n );\n }\n const hours = minutes.data / 60;\n if (\n selected.maxTimeHours !== undefined &&\n Math.abs(selected.maxTimeHours - hours) >\n Number.EPSILON * Math.max(selected.maxTimeHours, hours)\n ) {\n throw new CodexSecurityError(\n \"Conflicting maxTimeMinutes / --max-time and maxTimeHours / --max-time-hours settings.\",\n );\n }\n selected.maxTimeHours = hours;\n }\n if (\n minutes.data !== undefined &&\n !Number.isFinite(new Date(Date.now() + minutes.data * 60_000).getTime())\n ) {\n throw new CodexSecurityError(\n \"maxTimeMinutes / --max-time must produce a deadline within the supported date range.\",\n );\n }\n return selected;\n}\n\nfunction requireDeepScanValue(\n name: keyof DeepScanOptions,\n value: unknown,\n label: string,\n): number {\n const parsed = DeepScanSettingsSchema.shape[name].unwrap().safeParse(value);\n if (!parsed.success) {\n throw new CodexSecurityError(\n `Deep scan ${label} ${parsed.error.issues[0]!.message}.`,\n );\n }\n return parsed.data;\n}\n\nexport async function resolveDeepScanConfig(\n options: DeepScanOptions & { maxTimeMinutes?: number },\n source: string,\n signal?: AbortSignal,\n): Promise<ResolvedDeepScanConfig> {\n const explicit = deepScanOptions({ ...options, mode: \"deep\" });\n let document: TomlTable = {};\n // Complete saved settings do not depend on today's ambient configuration.\n if (!DEEP_SCAN_SETTINGS.every(([name]) => explicit[name] !== undefined)) {\n document = await readDeepScanDocument(source, signal);\n }\n const existing = document[\"deep_scan\"];\n if (\n existing !== undefined &&\n (!isRecord(existing) ||\n ![Object.prototype, null].includes(Object.getPrototypeOf(existing)))\n ) {\n throw new CodexSecurityError(\n `Codex Security configuration [deep_scan] at ${source} must be a TOML table.`,\n );\n }\n const configured = (existing ?? {}) as TomlTable;\n const keys = new Set<string>(DEEP_SCAN_SETTINGS.map(([, key]) => key));\n const unknown = Object.keys(configured).filter((key) => !keys.has(key));\n if (unknown.length > 0) {\n throw new CodexSecurityError(\n `Unknown Codex Security Deep Scan configuration ${unknown.join(\", \")} in ${source}.`,\n );\n }\n const settings = {\n ...DEFAULT_DEEP_SCAN_SETTINGS,\n } as Required<DeepScanOptions>;\n const sources = {} as DeepScanSources;\n for (const [name, key] of DEEP_SCAN_SETTINGS) {\n let value = Object.hasOwn(configured, key)\n ? configured[key]\n : DEFAULT_DEEP_SCAN_SETTINGS[name];\n if (name === \"workers\" && value === \"auto\")\n value = DEFAULT_DEEP_SCAN_SETTINGS.workers;\n if (explicit[name] !== undefined) value = explicit[name];\n sources[name] =\n explicit[name] !== undefined\n ? \"override\"\n : Object.hasOwn(configured, key)\n ? \"legacy\"\n : \"default\";\n settings[name] = requireDeepScanValue(\n name,\n value,\n sources[name] === \"legacy\" ? `${key} in ${source}` : name,\n );\n }\n return {\n settings,\n sources,\n source,\n document,\n overrides: explicit,\n };\n}\n\nexport async function writeDeepScanConfig(\n destination: string,\n resolved: ResolvedDeepScanConfig,\n workerRuntime?: JsonObject,\n): Promise<void> {\n const [source, target] = await Promise.all([\n canonicalConfigPath(resolved.source),\n runtimeConfigPath(destination),\n ]);\n let document = resolved.document;\n const sameFile = source === target;\n if (sameFile) {\n if (Object.keys(resolved.overrides).length === 0) return;\n document = await readDeepScanDocument(destination);\n }\n // An isolated runtime needs a complete snapshot. An ambient file keeps\n // inherited defaults unset so future releases can still update them.\n const settings = sameFile ? resolved.overrides : resolved.settings;\n const retainAmbientSettings =\n sameFile &&\n DEEP_SCAN_SETTINGS.some(([name]) => settings[name] === undefined);\n await writeCodexConfig(destination, {\n ...document,\n ...(workerRuntime === undefined ? {} : { worker_runtime: workerRuntime }),\n deep_scan: {\n ...(retainAmbientSettings\n ? (document[\"deep_scan\"] as TomlTable | undefined)\n : {}),\n ...Object.fromEntries(\n DEEP_SCAN_SETTINGS.filter(([name]) => settings[name] !== undefined).map(\n ([name, key]) => [key, settings[name]],\n ),\n ),\n },\n } as JsonObject);\n}\n\nasync function runtimeConfigPath(path: string): Promise<string> {\n try {\n return await canonicalConfigPath(path);\n } catch (error) {\n if (\n (error as NodeJS.ErrnoException).code !== \"ELOOP\" ||\n !(await lstat(path)).isSymbolicLink()\n )\n throw error;\n // A stale cyclic file link is replaced by writeCodexConfig's atomic rename.\n // Errors resolving its parent (or the ambient source) still fail the write.\n return join(await canonicalConfigPath(dirname(path)), basename(path));\n }\n}\n\nasync function readDeepScanDocument(\n source: string,\n signal?: AbortSignal,\n): Promise<TomlTable> {\n try {\n return parseToml(await readFile(source, { encoding: \"utf8\", signal }));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw new CodexSecurityError(\n `Cannot read Codex Security configuration at ${source}.`,\n { cause: error },\n );\n }\n return {};\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"deep-config.js","sourceRoot":"","sources":["../src/deep-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,KAAK,IAAI,SAAS,EAAkB,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAmB,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB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E,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IACzE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvD,MAAM,IAAI,kBAAkB,CAC1B,+CAA+C,MAAM,GAAG,EACxD,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC","sourcesContent":["import { isRecord } from \"./record.js\";\nimport { lstat, readFile } from \"node:fs/promises\";\nimport { basename, dirname, join } from \"node:path\";\nimport { parse as parseToml, type TomlTable } from \"smol-toml\";\nimport { writeCodexConfig, type JsonObject } from \"./config.js\";\nimport { canonicalConfigPath } from \"./runtime.js\";\nimport {\n DEEP_SCAN_SETTINGS,\n DEFAULT_DEEP_SCAN_SETTINGS,\n hoursConflict,\n} from \"./deep-scan-defaults.js\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport {\n DEFAULT_SCAN_MODE,\n DeepScanSettingsSchema,\n ScanSettingsSchema,\n type DeepScanOptions,\n} from \"./scan-settings.js\";\nimport type { ScanMode } from \"./scan-modes.js\";\n\nexport type DeepScanSources = Record<\n keyof DeepScanOptions,\n \"default\" | \"legacy\" | \"override\"\n>;\nexport interface ResolvedDeepScanConfig {\n settings: Required<DeepScanOptions>;\n sources: DeepScanSources;\n source: string;\n document: TomlTable;\n}\n\nexport function deepScanOptions(\n options: DeepScanOptions & { mode?: ScanMode; maxTimeMinutes?: number },\n): DeepScanOptions {\n const selected: DeepScanOptions = {};\n const minutes = ScanSettingsSchema.shape.maxTimeMinutes.safeParse(\n options.maxTimeMinutes,\n );\n if (!minutes.success) {\n throw new CodexSecurityError(\n \"maxTimeMinutes / --max-time must be a finite positive number of minutes.\",\n );\n }\n for (const [name] of DEEP_SCAN_SETTINGS) {\n const value = options[name];\n if (value === undefined) continue;\n if ((options.mode ?? DEFAULT_SCAN_MODE) !== \"deep\") {\n throw new CodexSecurityError(\"Deep scan settings require deep mode.\");\n }\n selected[name] = requireDeepScanValue(name, value, name);\n }\n if (minutes.data !== undefined && options.mode === \"deep\") {\n if (minutes.data > 5760) {\n throw new CodexSecurityError(\n \"Deep scan maxTimeMinutes / --max-time must be no greater than 5760 minutes.\",\n );\n }\n const hours = minutes.data / 60;\n if (hoursConflict(hours, selected.maxTimeHours)) {\n throw new CodexSecurityError(\n \"Conflicting maxTimeMinutes / --max-time and maxTimeHours / --max-time-hours settings.\",\n );\n }\n selected.maxTimeHours = hours;\n }\n if (\n minutes.data !== undefined &&\n !Number.isFinite(new Date(Date.now() + minutes.data * 60_000).getTime())\n ) {\n throw new CodexSecurityError(\n \"maxTimeMinutes / --max-time must produce a deadline within the supported date range.\",\n );\n }\n return selected;\n}\n\nfunction requireDeepScanValue(\n name: keyof DeepScanOptions,\n value: unknown,\n label: string,\n): number {\n const parsed = DeepScanSettingsSchema.shape[name].unwrap().safeParse(value);\n if (!parsed.success) {\n throw new CodexSecurityError(\n `Deep scan ${label} ${parsed.error.issues[0]!.message}.`,\n );\n }\n return parsed.data;\n}\n\nexport async function resolveDeepScanConfig(\n options: DeepScanOptions & { maxTimeMinutes?: number },\n source: string,\n signal?: AbortSignal,\n): Promise<ResolvedDeepScanConfig> {\n const explicit = deepScanOptions({ ...options, mode: \"deep\" });\n let document: TomlTable = {};\n // Complete saved settings do not depend on today's ambient configuration.\n if (!DEEP_SCAN_SETTINGS.every(([name]) => explicit[name] !== undefined)) {\n document = await readDeepScanDocument(source, signal);\n }\n const existing = document[\"deep_scan\"];\n if (\n existing !== undefined &&\n (!isRecord(existing) ||\n ![Object.prototype, null].includes(Object.getPrototypeOf(existing)))\n ) {\n throw new CodexSecurityError(\n `Codex Security configuration [deep_scan] at ${source} must be a TOML table.`,\n );\n }\n const configured = (existing ?? {}) as TomlTable;\n const keys = new Set<string>(DEEP_SCAN_SETTINGS.map(([, key]) => key));\n const unknown = Object.keys(configured).filter((key) => !keys.has(key));\n if (unknown.length > 0) {\n throw new CodexSecurityError(\n `Unknown Codex Security Deep Scan configuration ${unknown.join(\", \")} in ${source}.`,\n );\n }\n const settings: Required<DeepScanOptions> = { ...DEFAULT_DEEP_SCAN_SETTINGS };\n const sources = {} as DeepScanSources;\n for (const [name, key] of DEEP_SCAN_SETTINGS) {\n const legacy = Object.hasOwn(configured, key) ? configured[key] : undefined;\n const override = explicit[name];\n sources[name] =\n override !== undefined\n ? \"override\"\n : legacy !== undefined\n ? \"legacy\"\n : \"default\";\n const value = override ?? legacy ?? settings[name];\n settings[name] = requireDeepScanValue(\n name,\n name === \"workers\" && value === \"auto\"\n ? DEFAULT_DEEP_SCAN_SETTINGS.workers\n : value,\n sources[name] === \"legacy\" ? `${key} in ${source}` : name,\n );\n }\n return {\n settings,\n sources,\n source,\n document,\n };\n}\n\nexport async function writeDeepScanConfig(\n destination: string,\n resolved: ResolvedDeepScanConfig,\n workerRuntime?: JsonObject,\n): Promise<void> {\n const [source, target] = await Promise.all([\n canonicalConfigPath(resolved.source),\n runtimeConfigPath(destination),\n ]);\n const ambient = source === target;\n const fields = DEEP_SCAN_SETTINGS.filter(\n ([name]) => !ambient || resolved.sources[name] === \"override\",\n );\n if (fields.length === 0) return;\n const document = ambient\n ? await readDeepScanDocument(destination)\n : resolved.document;\n // A complete snapshot replaces the Deep table. Partial ambient writes preserve other keys.\n await writeCodexConfig(destination, {\n ...document,\n ...(workerRuntime === undefined ? {} : { worker_runtime: workerRuntime }),\n deep_scan: {\n ...(fields.length < DEEP_SCAN_SETTINGS.length\n ? (document[\"deep_scan\"] as TomlTable | undefined)\n : {}),\n ...Object.fromEntries(\n fields.map(([name, key]) => [key, resolved.settings[name]]),\n ),\n },\n } as JsonObject);\n}\n\nasync function runtimeConfigPath(path: string): Promise<string> {\n try {\n return await canonicalConfigPath(path);\n } catch (error) {\n if (\n (error as NodeJS.ErrnoException).code !== \"ELOOP\" ||\n !(await lstat(path)).isSymbolicLink()\n )\n throw error;\n // A stale cyclic file link is replaced by writeCodexConfig's atomic rename.\n // Errors resolving its parent (or the ambient source) still fail the write.\n return join(await canonicalConfigPath(dirname(path)), basename(path));\n }\n}\n\nasync function readDeepScanDocument(\n source: string,\n signal?: AbortSignal,\n): Promise<TomlTable> {\n try {\n return parseToml(await readFile(source, { encoding: \"utf8\", signal }));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw new CodexSecurityError(\n `Cannot read Codex Security configuration at ${source}.`,\n { cause: error },\n );\n }\n return {};\n }\n}\n"]}
|
|
@@ -6,4 +6,6 @@ export declare const DEFAULT_DEEP_SCAN_SETTINGS: {
|
|
|
6
6
|
readonly maxDiscoveryRuns: 40;
|
|
7
7
|
readonly maxTimeHours: 96;
|
|
8
8
|
};
|
|
9
|
+
export declare const DEEP_SCAN_SETTINGS: readonly [readonly ["workers", "workers", "workers", "--workers"], readonly ["subagents", "subagents", "subagents_per_worker", "--subagents"], readonly ["stopAfterNoNew", "stop_after_no_new", "stop_after_no_new", "--stop-after-no-new"], readonly ["stopAfterConsecutiveErrors", "stop_after_consecutive_errors", "stop_after_consecutive_errors", null], readonly ["maxDiscoveryRuns", "max_discovery_runs", "max_discovery_runs", "--max-discovery-runs"], readonly ["maxTimeHours", "max_time_hours", "max_time_hours", "--max-time-hours"]];
|
|
10
|
+
export declare function hoursConflict(hours: number, prior?: number): boolean;
|
|
9
11
|
//# sourceMappingURL=deep-scan-defaults.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-scan-defaults.d.ts","sourceRoot":"","sources":["../src/deep-scan-defaults.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,0BAA0B;aACrC,OAAO,EAAE,CAAC;aACV,SAAS,EAAE,CAAC;aACZ,cAAc,EAAE,CAAC;aACjB,0BAA0B,EAAE,CAAC;aAC7B,gBAAgB,EAAE,EAAE;aACpB,YAAY,EAAE,EAAE;CACR,CAAC"}
|
|
1
|
+
{"version":3,"file":"deep-scan-defaults.d.ts","sourceRoot":"","sources":["../src/deep-scan-defaults.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,0BAA0B;aACrC,OAAO,EAAE,CAAC;aACV,SAAS,EAAE,CAAC;aACZ,cAAc,EAAE,CAAC;aACjB,0BAA0B,EAAE,CAAC;aAC7B,gBAAgB,EAAE,EAAE;aACpB,YAAY,EAAE,EAAE;CACR,CAAC;AAGX,eAAO,MAAM,kBAAkB,sBAC5B,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,aAC5C,WAAW,EAAE,WAAW,EAAE,sBAAsB,EAAE,aAAa,aAE9D,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,aAGrB,4BAA4B,EAC5B,+BAA+B,EAC/B,+BAA+B,mBAI/B,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,aAEvB,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAC/D,CAAC;AAEX,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAQ,WAEzD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated from the plugin
|
|
1
|
+
// Generated from the plugin Deep Scan defaults and settings. Run pnpm build.
|
|
2
2
|
export const DEFAULT_DEEP_SCAN_SETTINGS = {
|
|
3
3
|
workers: 4,
|
|
4
4
|
subagents: 3,
|
|
@@ -7,4 +7,31 @@ export const DEFAULT_DEEP_SCAN_SETTINGS = {
|
|
|
7
7
|
maxDiscoveryRuns: 40,
|
|
8
8
|
maxTimeHours: 96,
|
|
9
9
|
};
|
|
10
|
+
// SDK name, legacy TOML key, project key, and CLI flag (when exposed).
|
|
11
|
+
export const DEEP_SCAN_SETTINGS = [
|
|
12
|
+
["workers", "workers", "workers", "--workers"],
|
|
13
|
+
["subagents", "subagents", "subagents_per_worker", "--subagents"],
|
|
14
|
+
[
|
|
15
|
+
"stopAfterNoNew",
|
|
16
|
+
"stop_after_no_new",
|
|
17
|
+
"stop_after_no_new",
|
|
18
|
+
"--stop-after-no-new",
|
|
19
|
+
],
|
|
20
|
+
[
|
|
21
|
+
"stopAfterConsecutiveErrors",
|
|
22
|
+
"stop_after_consecutive_errors",
|
|
23
|
+
"stop_after_consecutive_errors",
|
|
24
|
+
null,
|
|
25
|
+
],
|
|
26
|
+
[
|
|
27
|
+
"maxDiscoveryRuns",
|
|
28
|
+
"max_discovery_runs",
|
|
29
|
+
"max_discovery_runs",
|
|
30
|
+
"--max-discovery-runs",
|
|
31
|
+
],
|
|
32
|
+
["maxTimeHours", "max_time_hours", "max_time_hours", "--max-time-hours"],
|
|
33
|
+
];
|
|
34
|
+
export function hoursConflict(hours, prior = hours) {
|
|
35
|
+
return Math.abs(prior - hours) > Number.EPSILON * Math.max(prior, hours);
|
|
36
|
+
}
|
|
10
37
|
//# sourceMappingURL=deep-scan-defaults.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-scan-defaults.js","sourceRoot":"","sources":["../src/deep-scan-defaults.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"deep-scan-defaults.js","sourceRoot":"","sources":["../src/deep-scan-defaults.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,OAAO,EAAE,CAAC;IACV,SAAS,EAAE,CAAC;IACZ,cAAc,EAAE,CAAC;IACjB,0BAA0B,EAAE,CAAC;IAC7B,gBAAgB,EAAE,EAAE;IACpB,YAAY,EAAE,EAAE;CACR,CAAC;AAEX,uEAAuE;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC;IAC9C,CAAC,WAAW,EAAE,WAAW,EAAE,sBAAsB,EAAE,aAAa,CAAC;IACjE;QACE,gBAAgB;QAChB,mBAAmB;QACnB,mBAAmB;QACnB,qBAAqB;KACtB;IACD;QACE,4BAA4B;QAC5B,+BAA+B;QAC/B,+BAA+B;QAC/B,IAAI;KACL;IACD;QACE,kBAAkB;QAClB,oBAAoB;QACpB,oBAAoB;QACpB,sBAAsB;KACvB;IACD,CAAC,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,CAAC;CAChE,CAAC;AAEX,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,KAAK,GAAG,KAAK;IACxD,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["// Generated from the plugin Deep Scan defaults and settings. Run pnpm build.\nexport const DEFAULT_DEEP_SCAN_SETTINGS = {\n workers: 4,\n subagents: 3,\n stopAfterNoNew: 4,\n stopAfterConsecutiveErrors: 3,\n maxDiscoveryRuns: 40,\n maxTimeHours: 96,\n} as const;\n\n// SDK name, legacy TOML key, project key, and CLI flag (when exposed).\nexport const DEEP_SCAN_SETTINGS = [\n [\"workers\", \"workers\", \"workers\", \"--workers\"],\n [\"subagents\", \"subagents\", \"subagents_per_worker\", \"--subagents\"],\n [\n \"stopAfterNoNew\",\n \"stop_after_no_new\",\n \"stop_after_no_new\",\n \"--stop-after-no-new\",\n ],\n [\n \"stopAfterConsecutiveErrors\",\n \"stop_after_consecutive_errors\",\n \"stop_after_consecutive_errors\",\n null,\n ],\n [\n \"maxDiscoveryRuns\",\n \"max_discovery_runs\",\n \"max_discovery_runs\",\n \"--max-discovery-runs\",\n ],\n [\"maxTimeHours\", \"max_time_hours\", \"max_time_hours\", \"--max-time-hours\"],\n] as const;\n\nexport function hoursConflict(hours: number, prior = hours) {\n return Math.abs(prior - hours) > Number.EPSILON * Math.max(prior, hours);\n}\n"]}
|
package/dist/deep-scan.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { CodexOptions } from "@openai/codex-sdk";
|
|
2
2
|
import { type JsonObject } from "./config.js";
|
|
3
3
|
import { type CodexCommand } from "./runtime.js";
|
|
4
|
+
export type DeepScanDiagnostic = Readonly<Record<string, string | number>>;
|
|
4
5
|
export interface DirectDeepScanOptions {
|
|
6
|
+
onDiagnostic?: (event: DeepScanDiagnostic) => void;
|
|
5
7
|
codexOptions: CodexOptions & {
|
|
6
8
|
nativeProfile?: string;
|
|
7
9
|
};
|
package/dist/deep-scan.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-scan.d.ts","sourceRoot":"","sources":["../src/deep-scan.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAOtD,OAAO,EAGL,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AAErB,OAAO,
|
|
1
|
+
{"version":3,"file":"deep-scan.d.ts","sourceRoot":"","sources":["../src/deep-scan.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAOtD,OAAO,EAGL,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AAErB,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAQtB,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;AAE3E,MAAM,WAAW,qBAAqB;IACpC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACnD,YAAY,EAAE,YAAY,GAAG;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACxD,gBAAgB,EAAE,YAAY,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,WAAW,CAAC;CACrB;AA+DD,0FAA0F;AAC1F,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,IAAI,CACX,qBAAqB,EACrB,cAAc,GAAG,kBAAkB,GAAG,SAAS,GAAG,QAAQ,CAC3D,GAAG;IACF,MAAM,CAAC,EAAE;QAAE,eAAe,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC,GACA,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CA+DjC;AA8DD,uFAAuF;AACvF,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,UAAU,EAClB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACrC,MAAM,EAAE,CAkGV;AAGD,eAAO,MAAM,8BAA8B;aACzC,YAAY,EAAE,CAAC;aACf,mBAAmB,EAAE,CAAC;aACtB,wBAAwB,EAAE,CAAC;aAC3B,aAAa,EAAE,CAAC;CACR,CAAC;AAEX,2EAA2E;AAC3E,wBAAuB,WAAW,CAChC,OAAO,EAAE,qBAAqB,GAC7B,cAAc,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC,CA6ED"}
|
package/dist/deep-scan.js
CHANGED
|
@@ -15,7 +15,7 @@ import { bundledCodexSdkEnvironment, resolveBundledCodexExecutable, } from "./co
|
|
|
15
15
|
import { CodexSecurityError } from "./errors.js";
|
|
16
16
|
import { deepMerge, inlineToml, } from "./config.js";
|
|
17
17
|
import { isRecord } from "./record.js";
|
|
18
|
-
import { executablePathForSpawn, PLUGIN_NAME, runCodexCommand, } from "./runtime.js";
|
|
18
|
+
import { executablePathForSpawn, isDisconnectedChildStdin, PLUGIN_NAME, runCodexCommand, } from "./runtime.js";
|
|
19
19
|
import { resolveTrustedExecutable } from "./trusted-executable.js";
|
|
20
20
|
import { nativePermissionPreflight, nativeProfileClient, withCodexPreflightLock, } from "./provider-profile.js";
|
|
21
21
|
// The stock SDK emits one flag per leaf, including literal dotted keys in order.
|
|
@@ -286,7 +286,11 @@ export async function* runDeepScan(options) {
|
|
|
286
286
|
: undefined;
|
|
287
287
|
if (node === null)
|
|
288
288
|
throw new CodexSecurityError("Node.js is not available on PATH.");
|
|
289
|
-
const output = await runEngine(node?.executable ?? process.execPath, [join(options.pluginRoot, "mcp", "server.mjs"), "--deep-scan-engine"], node?.environment ?? environment, JSON.stringify({
|
|
289
|
+
const output = await runEngine(node?.executable ?? process.execPath, [join(options.pluginRoot, "mcp", "server.mjs"), "--deep-scan-engine"], node?.environment ?? environment, JSON.stringify({
|
|
290
|
+
scanId: options.scanId,
|
|
291
|
+
...session,
|
|
292
|
+
...(options.onDiagnostic && { diagnosticsVersion: 1 }),
|
|
293
|
+
}), options.signal, options.onDiagnostic);
|
|
290
294
|
const completed = JSON.parse(output);
|
|
291
295
|
if (completed.scanId !== options.scanId ||
|
|
292
296
|
completed.manifestPath !== join(options.scanDir, "scan-manifest.json")) {
|
|
@@ -299,12 +303,32 @@ export async function* runDeepScan(options) {
|
|
|
299
303
|
usage: { ...DIRECT_DEEP_SCAN_CONTROL_USAGE },
|
|
300
304
|
};
|
|
301
305
|
}
|
|
302
|
-
function runEngine(command, args, env, request, signal) {
|
|
306
|
+
function runEngine(command, args, env, request, signal, onDiagnostic) {
|
|
303
307
|
signal.throwIfAborted();
|
|
304
308
|
const child = spawn(executablePathForSpawn(command), args, {
|
|
305
309
|
env,
|
|
306
310
|
windowsHide: true,
|
|
311
|
+
serialization: "json",
|
|
312
|
+
stdio: onDiagnostic ? ["pipe", "pipe", "pipe", "ipc"] : "pipe",
|
|
307
313
|
});
|
|
314
|
+
if (onDiagnostic) {
|
|
315
|
+
child.on("message", (message) => {
|
|
316
|
+
if (!isRecord(message) || typeof message["event"] !== "string")
|
|
317
|
+
return;
|
|
318
|
+
const fields = {};
|
|
319
|
+
for (const [name, value] of Object.entries(message)) {
|
|
320
|
+
if (/^[a-zA-Z][a-zA-Z0-9]*$/u.test(name) &&
|
|
321
|
+
(typeof value === "number" || typeof value === "string"))
|
|
322
|
+
fields[name] = value;
|
|
323
|
+
}
|
|
324
|
+
try {
|
|
325
|
+
void Promise.resolve(onDiagnostic(fields)).catch(() => { });
|
|
326
|
+
}
|
|
327
|
+
catch {
|
|
328
|
+
// The optional diagnostic sink cannot stop the scan.
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}
|
|
308
332
|
// EOF requests graceful coordinator/worker cleanup on Windows as well as Unix.
|
|
309
333
|
// Keep the control pipe open until completion or explicit cancellation.
|
|
310
334
|
const cancel = () => child.stdin.end();
|
|
@@ -321,7 +345,7 @@ function runEngine(command, args, env, request, signal) {
|
|
|
321
345
|
processError = error;
|
|
322
346
|
});
|
|
323
347
|
child.stdin.on("error", (error) => {
|
|
324
|
-
if (!
|
|
348
|
+
if (!isDisconnectedChildStdin(error))
|
|
325
349
|
processError = error;
|
|
326
350
|
});
|
|
327
351
|
const result = new Promise((resolve, reject) => {
|
package/dist/deep-scan.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-scan.js","sourceRoot":"","sources":["../src/deep-scan.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;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AAI,EAAE,EAAE;YAC3B,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC5C,IAAI,MAAM,CAAC,OAAO;gBAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;iBACrC,IAAI,YAAY;gBAAE,MAAM,CAAC,YAAY,CAAC,CAAC;iBACvC,IAAI,IAAI,KAAK,CAAC;gBACjB,MAAM,CACJ,IAAI,kBAAkB,CACpB,MAAM,CAAC,IAAI,EAAE,IAAI,qCAAqC,IAAI,GAAG,CAC9D,CACF,CAAC;;gBACC,OAAO,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAClC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,IAAI,MAAM,CAAC,OAAO;QAAE,MAAM,EAAE,CAAC;IAC7B,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { spawn } from \"node:child_process\";\nimport { realpathSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { CodexOptions } from \"@openai/codex-sdk\";\nimport { parse } from \"smol-toml\";\nimport {\n bundledCodexSdkEnvironment,\n resolveBundledCodexExecutable,\n} from \"./codex-sdk-environment.js\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport {\n deepMerge,\n inlineToml,\n type JsonObject,\n type JsonValue,\n} from \"./config.js\";\nimport { isRecord } from \"./record.js\";\nimport {\n executablePathForSpawn,\n PLUGIN_NAME,\n runCodexCommand,\n type CodexCommand,\n} from \"./runtime.js\";\nimport { resolveTrustedExecutable } from \"./trusted-executable.js\";\nimport {\n nativePermissionPreflight,\n nativeProfileClient,\n withCodexPreflightLock,\n} from \"./provider-profile.js\";\n\nexport interface DirectDeepScanOptions {\n codexOptions: CodexOptions & { nativeProfile?: string };\n preflightCommand: CodexCommand;\n pluginRoot: string;\n repository: string;\n scanDir: string;\n scanId: string;\n prompt: string;\n signal: AbortSignal;\n}\n\n// The stock SDK emits one flag per leaf, including literal dotted keys in order.\nfunction sdkConfigFlags(config: JsonObject, prefix = \"\"): string[] {\n return Object.entries(config).flatMap(([key, value]) => {\n const path = prefix ? `${prefix}.${key}` : key;\n return isRecord(value) && Object.keys(value).length\n ? sdkConfigFlags(value, path)\n : [`${path}=${inlineToml(value)}`];\n });\n}\n\n// An older custom launcher must start in the caller's directory. Only use\n// supplied routing when its app-server cannot read the scan at startup.\nfunction suppliedParentRouting(\n overrides: readonly string[],\n): JsonObject | undefined {\n try {\n const config: JsonObject = Object.create(null);\n for (const override of overrides) {\n const equals = override.indexOf(\"=\");\n const key = override.slice(0, equals).trim();\n if (!/^(?:features|mcp_servers)(?:\\.|$)/u.test(key)) continue;\n const path = key.split(\".\");\n const leaf = path.pop()!;\n let table = config;\n for (const part of path) {\n const next = Object.hasOwn(table, part) ? table[part] : undefined;\n const child =\n table === config[\"features\"] && part === \"code_mode\"\n ? codeModeTable(next)\n : next;\n table = table[part] = Object.assign(\n Object.create(null),\n isRecord(child) ? child : {},\n );\n }\n const value = parse(`value=${override.slice(equals + 1)}`)[\n \"value\"\n ] as JsonValue;\n const priorMode =\n key === \"features.code_mode\" ? codeModeTable(table[leaf]) : undefined;\n const newMode = priorMode && codeModeTable(value);\n table[leaf] =\n priorMode && newMode ? deepMerge({ ...priorMode }, newMode) : value;\n }\n const servers = config[\"mcp_servers\"];\n const owner = isRecord(servers) ? servers[PLUGIN_NAME] : undefined;\n // Even a supplied transport can inherit a machine-level direct opt-out.\n if (isRecord(owner) && !Array.isArray(owner[\"omit_tools_from\"])) return;\n return config;\n } catch {\n // Leave malformed settings for exec's own parser.\n return undefined;\n }\n}\n\n// Codex merges a structured Code Mode setting with its boolean shorthand.\nfunction codeModeTable(value: JsonValue | undefined): JsonObject | undefined {\n if (typeof value === \"boolean\") return { enabled: value };\n return isRecord(value) ? value : undefined;\n}\n\n/** Read the same native layers and CLI overrides as the parent before adding its tool. */\nexport async function readDeepScanParentConfig(\n options: Pick<\n DirectDeepScanOptions,\n \"codexOptions\" | \"preflightCommand\" | \"scanDir\" | \"signal\"\n > & {\n plugin?: { marketplacePath: string; pluginName: string };\n pluginServers?: Record<string, unknown>;\n },\n): Promise<JsonObject | undefined> {\n const { codexOptions, preflightCommand: command } = options;\n const config = codexOptions.config ?? {};\n // The provider-profile launcher emits whole top-level tables instead.\n const overrides =\n codexOptions.nativeProfile === undefined\n ? sdkConfigFlags(config)\n : (await nativeProfileClient()).profileConfigOverrides(config);\n const environment = bundledCodexSdkEnvironment(command.command, {\n ...codexOptions.env,\n ...(codexOptions.apiKey === undefined\n ? {}\n : { CODEX_API_KEY: codexOptions.apiKey }),\n });\n const configOverrides = [\n ...overrides,\n ...(codexOptions.configOverrides ?? []),\n ];\n // Subcommand help does not load a project. A global --cd is ignored by\n // older app-servers, so require support on the subcommand itself.\n const help = await runCodexCommand(\n command,\n [\"app-server\", \"--cd\", options.scanDir, \"--help\"],\n environment,\n undefined,\n options.signal,\n );\n const supportsCd =\n help.success && /^\\s*(?:-C,\\s*)?--cd\\s+<[^>\\n]+>/mu.test(help.stdout);\n if (!supportsCd) {\n // The bundled command is the native executable itself. A custom launcher\n // can use its own working directory to resolve scripts and other inputs.\n if (\n resolve(options.scanDir) !== process.cwd() &&\n !isBundledExecutable(command.command)\n )\n return options.plugin\n ? undefined\n : suppliedParentRouting(configOverrides);\n if (environment[\"CODEX_HOME\"])\n environment[\"CODEX_HOME\"] = resolve(environment[\"CODEX_HOME\"]);\n }\n\n const native = await nativePermissionPreflight();\n return withCodexPreflightLock(environment, options.signal, () =>\n native.readDeepScanRuntimeConfig(\n {\n codexPath: command.command,\n commandArgs: command.args,\n cwd: supportsCd ? process.cwd() : options.scanDir,\n ...(supportsCd && { configCwd: options.scanDir }),\n configOverrides,\n env: environment,\n signal: options.signal,\n context: \"parent-config\",\n plugin: options.plugin,\n },\n (\n config: JsonObject,\n hasEmptyCatalog: (server: string) => Promise<boolean>,\n ) => inspectFilteredPeers(config, options.pluginServers, hasEmptyCatalog),\n ),\n );\n}\n\nfunction isBundledExecutable(command: string): boolean {\n try {\n return (\n realpathSync.native(command) ===\n realpathSync.native(resolveBundledCodexExecutable())\n );\n } catch {\n return false; // An installation may supply only an external launcher.\n }\n}\n\nasync function inspectFilteredPeers(\n config: JsonObject,\n pluginServers: Record<string, unknown> | undefined,\n hasEmptyCatalog: (server: string) => Promise<boolean>,\n): Promise<JsonObject> {\n const configured = isRecord(config[\"mcp_servers\"])\n ? config[\"mcp_servers\"]\n : {};\n const owner = configured[PLUGIN_NAME];\n if (\n isRecord(owner) &&\n (owner[\"command\"] ||\n owner[\"url\"] ||\n Array.isArray(owner[\"omit_tools_from\"]))\n )\n return config;\n const servers = { ...pluginServers, ...configured };\n const registration = servers[PLUGIN_NAME];\n if (!isRecord(registration) || registration[\"enabled\"] === false)\n return config;\n const routing = { ...configured };\n for (const [name, settings] of Object.entries(servers)) {\n if (\n name === PLUGIN_NAME ||\n !isRecord(settings) ||\n settings[\"enabled\"] === false ||\n ![\"codex_security\", \"mcp__codex_security\"].includes(\n normalizedServerName(name),\n )\n )\n continue;\n if (\n ![settings[\"enabled_tools\"], settings[\"disabled_tools\"]].some(\n (tools) => Array.isArray(tools) && tools.length > 0,\n )\n )\n continue;\n if (await hasEmptyCatalog(name)) {\n // This view is used only to select a namespace. Never change the peer's config.\n routing[name] = { enabled_tools: [] };\n }\n }\n return { ...config, mcp_servers: routing };\n}\n\nfunction normalizedServerName(server: string): string {\n return server.replace(/[-.:@/]/gu, \"_\");\n}\n\n/** Keep direct dispatch scoped to the original SDK coordinator turn and MCP server. */\nexport function deepScanParentToolOverrides(\n config: JsonObject,\n pluginServers: Record<string, unknown>,\n): string[] {\n const features = config[\"features\"] ?? {};\n if (!isRecord(features)) return [];\n const mode = features[\"code_mode\"];\n if (mode !== undefined && typeof mode !== \"boolean\" && !isRecord(mode))\n return [];\n const direct =\n (isRecord(mode) ? mode[\"direct_only_tool_namespaces\"] : undefined) ?? [];\n if (!Array.isArray(direct)) return [];\n\n const owner = PLUGIN_NAME;\n const bare = \"codex_security\";\n const prefixed = \"mcp__codex_security\";\n let required = [prefixed, bare];\n const overrides: string[] = [];\n const configured = config[\"mcp_servers\"];\n // Native registrations take precedence over the selected plugin's entries.\n const servers: Record<string, unknown> = {\n ...pluginServers,\n ...(isRecord(configured) ? configured : {}),\n };\n const ownerConfig = servers[owner];\n if (!isRecord(ownerConfig) || ownerConfig[\"enabled\"] === false) return [];\n const omitted = ownerConfig[\"omit_tools_from\"];\n if (Array.isArray(omitted) && omitted.includes(\"direct\")) return [];\n // A raw transport or an existing omission leaf can be updated in place.\n // Adding a new registration would shadow a plugin's transport and policy.\n if (\n isRecord(configured) &&\n Object.hasOwn(configured, owner) &&\n (Array.isArray(omitted) ||\n typeof ownerConfig[\"command\"] === \"string\" ||\n typeof ownerConfig[\"url\"] === \"string\")\n ) {\n if (omitted != null && !Array.isArray(omitted)) return [];\n const surfaces = omitted ?? [];\n if (surfaces.includes(\"code_mode\") && surfaces.includes(\"deferred\"))\n return [];\n return [\n `mcp_servers.${owner}.omit_tools_from=${inlineToml([...new Set([...surfaces, \"code_mode\", \"deferred\"])])}`,\n ];\n }\n const option = features[\"non_prefixed_mcp_tool_names\"];\n const enabled =\n option === true || (isRecord(option) && option[\"enabled\"] === true);\n const selected = isRecord(option) ? option[\"server_names\"] : undefined;\n function namespace(server: string): string {\n const name = normalizedServerName(server);\n const omitPrefix =\n enabled && (!Array.isArray(selected) || selected.includes(server));\n return omitPrefix || name.startsWith(\"mcp__\") ? name : `mcp__${name}`;\n }\n const occupied = new Set(\n Object.entries(servers)\n .filter(\n ([server, settings]) =>\n server !== owner &&\n isRecord(settings) &&\n settings[\"enabled\"] !== false &&\n (!Array.isArray(settings[\"enabled_tools\"]) ||\n settings[\"enabled_tools\"].length > 0),\n )\n .map(([server]) => namespace(server)),\n );\n const current = namespace(owner);\n if (occupied.has(current)) {\n const excluded = isRecord(mode) ? mode[\"excluded_tool_namespaces\"] : null;\n const routed = Array.isArray(excluded) ? [...direct, ...excluded] : direct;\n // Moving the owner also renames its peers. Keep names that the caller\n // explicitly routed or excluded from Code Mode.\n if (\n current === bare ||\n occupied.has(bare) ||\n routed.some(\n (name) =>\n name === current ||\n (typeof name === \"string\" &&\n /^mcp__codex_security_[0-9a-f]{12}$/u.test(name)),\n ) ||\n (option != null && !enabled)\n )\n return [];\n overrides.push(\n `features.non_prefixed_mcp_tool_names=${inlineToml({\n enabled: true,\n server_names: [...(Array.isArray(selected) ? selected : []), owner],\n })}`,\n );\n required = [bare];\n } else if (occupied.has(prefixed) || occupied.has(bare)) {\n required = [current];\n }\n if (!required.every((name) => direct.includes(name))) {\n overrides.push(\n `features.code_mode.direct_only_tool_namespaces=${inlineToml([...new Set([...direct, ...required])])}`,\n );\n }\n return overrides;\n}\n\n// The direct coordinator records context but never calls a model itself.\nexport const DIRECT_DEEP_SCAN_CONTROL_USAGE = {\n input_tokens: 0,\n cached_input_tokens: 0,\n cache_write_input_tokens: 0,\n output_tokens: 0,\n} as const;\n\n/** Run the same coordinator as the plugin, without a parent model turn. */\nexport async function* runDeepScan(\n options: DirectDeepScanOptions,\n): AsyncGenerator<{\n type: string;\n [key: string]: unknown;\n}> {\n const native = await import(\n pathToFileURL(\n join(options.pluginRoot, \"mcp\", \"permission-profile-preflight.mjs\"),\n ).href\n );\n const profile = await import(\n pathToFileURL(join(options.pluginRoot, \"scripts\", \"codex_profile.mjs\")).href\n );\n const configured = options.codexOptions;\n const command = options.preflightCommand;\n const environment = bundledCodexSdkEnvironment(command.command, {\n ...configured.env,\n ...(configured.apiKey === undefined\n ? {}\n : { CODEX_API_KEY: configured.apiKey }),\n });\n const session = (await withCodexPreflightLock(\n environment,\n options.signal,\n () =>\n native.prepareCliDeepScanSession({\n codexPath: command.command,\n commandArgs: command.args,\n cwd: options.scanDir,\n env: environment,\n configOverrides: [\n ...profile.profileConfigOverrides(configured.config ?? {}),\n ...(configured.configOverrides ?? []),\n // This session only records native context; workers keep their own snapshot.\n \"features.plugins=false\",\n ],\n signal: options.signal,\n prompt:\n options.prompt +\n \"\\n\\nThe host runs this Deep Scan coordinator directly and owns finalization. This saved request supplies context for later follow-up; do not start a replacement scan.\",\n }),\n )) as {\n threadId: string;\n model: string;\n reasoningEffort?: string;\n permissionProfile: unknown;\n };\n yield { type: \"thread.started\", thread_id: session.threadId };\n options.signal.throwIfAborted();\n const node = process.versions[\"bun\"]\n ? await resolveTrustedExecutable(\"node\", environment, [options.repository])\n : undefined;\n if (node === null)\n throw new CodexSecurityError(\"Node.js is not available on PATH.\");\n const output = await runEngine(\n node?.executable ?? process.execPath,\n [join(options.pluginRoot, \"mcp\", \"server.mjs\"), \"--deep-scan-engine\"],\n node?.environment ?? environment,\n JSON.stringify({ scanId: options.scanId, ...session }),\n options.signal,\n );\n const completed = JSON.parse(output);\n if (\n completed.scanId !== options.scanId ||\n completed.manifestPath !== join(options.scanDir, \"scan-manifest.json\")\n ) {\n throw new CodexSecurityError(\n \"Deep Scan engine returned results for a different scan.\",\n );\n }\n // The control session makes no model calls. Worker usage is read by the\n // existing scan tracker from the native sessions below this scan directory.\n yield {\n type: \"turn.completed\",\n usage: { ...DIRECT_DEEP_SCAN_CONTROL_USAGE },\n };\n}\n\nfunction runEngine(\n command: string,\n args: string[],\n env: NodeJS.ProcessEnv,\n request: string,\n signal: AbortSignal,\n): Promise<string> {\n signal.throwIfAborted();\n const child = spawn(executablePathForSpawn(command), args, {\n env,\n windowsHide: true,\n });\n // EOF requests graceful coordinator/worker cleanup on Windows as well as Unix.\n // Keep the control pipe open until completion or explicit cancellation.\n const cancel = () => child.stdin.end();\n let stdout = \"\";\n let stderr = \"\";\n let processError: Error | undefined;\n child.stdout.setEncoding(\"utf8\").on(\"data\", (chunk) => {\n stdout += chunk;\n });\n child.stderr.setEncoding(\"utf8\").on(\"data\", (chunk) => {\n stderr += chunk;\n });\n child.once(\"error\", (error) => {\n processError = error;\n });\n child.stdin.on(\"error\", (error: NodeJS.ErrnoException) => {\n if (\n ![\"EPIPE\", \"ECONNRESET\", \"EOF\", \"ERR_STREAM_DESTROYED\"].includes(\n error.code ?? \"\",\n )\n )\n processError = error;\n });\n const result = new Promise<string>((resolve, reject) => {\n child.once(\"close\", (code) => {\n signal.removeEventListener(\"abort\", cancel);\n if (signal.aborted) reject(signal.reason);\n else if (processError) reject(processError);\n else if (code !== 0)\n reject(\n new CodexSecurityError(\n stderr.trim() || `Deep Scan engine exited with code ${code}.`,\n ),\n );\n else resolve(stdout);\n });\n });\n child.stdin.write(request + \"\\n\");\n signal.addEventListener(\"abort\", cancel, { once: true });\n if (signal.aborted) cancel();\n return result;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"deep-scan.js","sourceRoot":"","sources":["../src/deep-scan.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAuC,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,SAAS,EACT,UAAU,GAGX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,WAAW,EACX,eAAe,GAEhB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,wBA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AAI,CAAC,CAAC;IAClC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,IAAI,MAAM,CAAC,OAAO;QAAE,MAAM,EAAE,CAAC;IAC7B,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { spawn, type ChildProcessWithoutNullStreams } from \"node:child_process\";\nimport { realpathSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { CodexOptions } from \"@openai/codex-sdk\";\nimport { parse } from \"smol-toml\";\nimport {\n bundledCodexSdkEnvironment,\n resolveBundledCodexExecutable,\n} from \"./codex-sdk-environment.js\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport {\n deepMerge,\n inlineToml,\n type JsonObject,\n type JsonValue,\n} from \"./config.js\";\nimport { isRecord } from \"./record.js\";\nimport {\n executablePathForSpawn,\n isDisconnectedChildStdin,\n PLUGIN_NAME,\n runCodexCommand,\n type CodexCommand,\n} from \"./runtime.js\";\nimport { resolveTrustedExecutable } from \"./trusted-executable.js\";\nimport {\n nativePermissionPreflight,\n nativeProfileClient,\n withCodexPreflightLock,\n} from \"./provider-profile.js\";\n\nexport type DeepScanDiagnostic = Readonly<Record<string, string | number>>;\n\nexport interface DirectDeepScanOptions {\n onDiagnostic?: (event: DeepScanDiagnostic) => void;\n codexOptions: CodexOptions & { nativeProfile?: string };\n preflightCommand: CodexCommand;\n pluginRoot: string;\n repository: string;\n scanDir: string;\n scanId: string;\n prompt: string;\n signal: AbortSignal;\n}\n\n// The stock SDK emits one flag per leaf, including literal dotted keys in order.\nfunction sdkConfigFlags(config: JsonObject, prefix = \"\"): string[] {\n return Object.entries(config).flatMap(([key, value]) => {\n const path = prefix ? `${prefix}.${key}` : key;\n return isRecord(value) && Object.keys(value).length\n ? sdkConfigFlags(value, path)\n : [`${path}=${inlineToml(value)}`];\n });\n}\n\n// An older custom launcher must start in the caller's directory. Only use\n// supplied routing when its app-server cannot read the scan at startup.\nfunction suppliedParentRouting(\n overrides: readonly string[],\n): JsonObject | undefined {\n try {\n const config: JsonObject = Object.create(null);\n for (const override of overrides) {\n const equals = override.indexOf(\"=\");\n const key = override.slice(0, equals).trim();\n if (!/^(?:features|mcp_servers)(?:\\.|$)/u.test(key)) continue;\n const path = key.split(\".\");\n const leaf = path.pop()!;\n let table = config;\n for (const part of path) {\n const next = Object.hasOwn(table, part) ? table[part] : undefined;\n const child =\n table === config[\"features\"] && part === \"code_mode\"\n ? codeModeTable(next)\n : next;\n table = table[part] = Object.assign(\n Object.create(null),\n isRecord(child) ? child : {},\n );\n }\n const value = parse(`value=${override.slice(equals + 1)}`)[\n \"value\"\n ] as JsonValue;\n const priorMode =\n key === \"features.code_mode\" ? codeModeTable(table[leaf]) : undefined;\n const newMode = priorMode && codeModeTable(value);\n table[leaf] =\n priorMode && newMode ? deepMerge({ ...priorMode }, newMode) : value;\n }\n const servers = config[\"mcp_servers\"];\n const owner = isRecord(servers) ? servers[PLUGIN_NAME] : undefined;\n // Even a supplied transport can inherit a machine-level direct opt-out.\n if (isRecord(owner) && !Array.isArray(owner[\"omit_tools_from\"])) return;\n return config;\n } catch {\n // Leave malformed settings for exec's own parser.\n return undefined;\n }\n}\n\n// Codex merges a structured Code Mode setting with its boolean shorthand.\nfunction codeModeTable(value: JsonValue | undefined): JsonObject | undefined {\n if (typeof value === \"boolean\") return { enabled: value };\n return isRecord(value) ? value : undefined;\n}\n\n/** Read the same native layers and CLI overrides as the parent before adding its tool. */\nexport async function readDeepScanParentConfig(\n options: Pick<\n DirectDeepScanOptions,\n \"codexOptions\" | \"preflightCommand\" | \"scanDir\" | \"signal\"\n > & {\n plugin?: { marketplacePath: string; pluginName: string };\n pluginServers?: Record<string, unknown>;\n },\n): Promise<JsonObject | undefined> {\n const { codexOptions, preflightCommand: command } = options;\n const config = codexOptions.config ?? {};\n // The provider-profile launcher emits whole top-level tables instead.\n const overrides =\n codexOptions.nativeProfile === undefined\n ? sdkConfigFlags(config)\n : (await nativeProfileClient()).profileConfigOverrides(config);\n const environment = bundledCodexSdkEnvironment(command.command, {\n ...codexOptions.env,\n ...(codexOptions.apiKey === undefined\n ? {}\n : { CODEX_API_KEY: codexOptions.apiKey }),\n });\n const configOverrides = [\n ...overrides,\n ...(codexOptions.configOverrides ?? []),\n ];\n // Subcommand help does not load a project. A global --cd is ignored by\n // older app-servers, so require support on the subcommand itself.\n const help = await runCodexCommand(\n command,\n [\"app-server\", \"--cd\", options.scanDir, \"--help\"],\n environment,\n undefined,\n options.signal,\n );\n const supportsCd =\n help.success && /^\\s*(?:-C,\\s*)?--cd\\s+<[^>\\n]+>/mu.test(help.stdout);\n if (!supportsCd) {\n // The bundled command is the native executable itself. A custom launcher\n // can use its own working directory to resolve scripts and other inputs.\n if (\n resolve(options.scanDir) !== process.cwd() &&\n !isBundledExecutable(command.command)\n )\n return options.plugin\n ? undefined\n : suppliedParentRouting(configOverrides);\n if (environment[\"CODEX_HOME\"])\n environment[\"CODEX_HOME\"] = resolve(environment[\"CODEX_HOME\"]);\n }\n\n const native = await nativePermissionPreflight();\n return withCodexPreflightLock(environment, options.signal, () =>\n native.readDeepScanRuntimeConfig(\n {\n codexPath: command.command,\n commandArgs: command.args,\n cwd: supportsCd ? process.cwd() : options.scanDir,\n ...(supportsCd && { configCwd: options.scanDir }),\n configOverrides,\n env: environment,\n signal: options.signal,\n context: \"parent-config\",\n plugin: options.plugin,\n },\n (\n config: JsonObject,\n hasEmptyCatalog: (server: string) => Promise<boolean>,\n ) => inspectFilteredPeers(config, options.pluginServers, hasEmptyCatalog),\n ),\n );\n}\n\nfunction isBundledExecutable(command: string): boolean {\n try {\n return (\n realpathSync.native(command) ===\n realpathSync.native(resolveBundledCodexExecutable())\n );\n } catch {\n return false; // An installation may supply only an external launcher.\n }\n}\n\nasync function inspectFilteredPeers(\n config: JsonObject,\n pluginServers: Record<string, unknown> | undefined,\n hasEmptyCatalog: (server: string) => Promise<boolean>,\n): Promise<JsonObject> {\n const configured = isRecord(config[\"mcp_servers\"])\n ? config[\"mcp_servers\"]\n : {};\n const owner = configured[PLUGIN_NAME];\n if (\n isRecord(owner) &&\n (owner[\"command\"] ||\n owner[\"url\"] ||\n Array.isArray(owner[\"omit_tools_from\"]))\n )\n return config;\n const servers = { ...pluginServers, ...configured };\n const registration = servers[PLUGIN_NAME];\n if (!isRecord(registration) || registration[\"enabled\"] === false)\n return config;\n const routing = { ...configured };\n for (const [name, settings] of Object.entries(servers)) {\n if (\n name === PLUGIN_NAME ||\n !isRecord(settings) ||\n settings[\"enabled\"] === false ||\n ![\"codex_security\", \"mcp__codex_security\"].includes(\n normalizedServerName(name),\n )\n )\n continue;\n if (\n ![settings[\"enabled_tools\"], settings[\"disabled_tools\"]].some(\n (tools) => Array.isArray(tools) && tools.length > 0,\n )\n )\n continue;\n if (await hasEmptyCatalog(name)) {\n // This view is used only to select a namespace. Never change the peer's config.\n routing[name] = { enabled_tools: [] };\n }\n }\n return { ...config, mcp_servers: routing };\n}\n\nfunction normalizedServerName(server: string): string {\n return server.replace(/[-.:@/]/gu, \"_\");\n}\n\n/** Keep direct dispatch scoped to the original SDK coordinator turn and MCP server. */\nexport function deepScanParentToolOverrides(\n config: JsonObject,\n pluginServers: Record<string, unknown>,\n): string[] {\n const features = config[\"features\"] ?? {};\n if (!isRecord(features)) return [];\n const mode = features[\"code_mode\"];\n if (mode !== undefined && typeof mode !== \"boolean\" && !isRecord(mode))\n return [];\n const direct =\n (isRecord(mode) ? mode[\"direct_only_tool_namespaces\"] : undefined) ?? [];\n if (!Array.isArray(direct)) return [];\n\n const owner = PLUGIN_NAME;\n const bare = \"codex_security\";\n const prefixed = \"mcp__codex_security\";\n let required = [prefixed, bare];\n const overrides: string[] = [];\n const configured = config[\"mcp_servers\"];\n // Native registrations take precedence over the selected plugin's entries.\n const servers: Record<string, unknown> = {\n ...pluginServers,\n ...(isRecord(configured) ? configured : {}),\n };\n const ownerConfig = servers[owner];\n if (!isRecord(ownerConfig) || ownerConfig[\"enabled\"] === false) return [];\n const omitted = ownerConfig[\"omit_tools_from\"];\n if (Array.isArray(omitted) && omitted.includes(\"direct\")) return [];\n // A raw transport or an existing omission leaf can be updated in place.\n // Adding a new registration would shadow a plugin's transport and policy.\n if (\n isRecord(configured) &&\n Object.hasOwn(configured, owner) &&\n (Array.isArray(omitted) ||\n typeof ownerConfig[\"command\"] === \"string\" ||\n typeof ownerConfig[\"url\"] === \"string\")\n ) {\n if (omitted != null && !Array.isArray(omitted)) return [];\n const surfaces = omitted ?? [];\n if (surfaces.includes(\"code_mode\") && surfaces.includes(\"deferred\"))\n return [];\n return [\n `mcp_servers.${owner}.omit_tools_from=${inlineToml([...new Set([...surfaces, \"code_mode\", \"deferred\"])])}`,\n ];\n }\n const option = features[\"non_prefixed_mcp_tool_names\"];\n const enabled =\n option === true || (isRecord(option) && option[\"enabled\"] === true);\n const selected = isRecord(option) ? option[\"server_names\"] : undefined;\n function namespace(server: string): string {\n const name = normalizedServerName(server);\n const omitPrefix =\n enabled && (!Array.isArray(selected) || selected.includes(server));\n return omitPrefix || name.startsWith(\"mcp__\") ? name : `mcp__${name}`;\n }\n const occupied = new Set(\n Object.entries(servers)\n .filter(\n ([server, settings]) =>\n server !== owner &&\n isRecord(settings) &&\n settings[\"enabled\"] !== false &&\n (!Array.isArray(settings[\"enabled_tools\"]) ||\n settings[\"enabled_tools\"].length > 0),\n )\n .map(([server]) => namespace(server)),\n );\n const current = namespace(owner);\n if (occupied.has(current)) {\n const excluded = isRecord(mode) ? mode[\"excluded_tool_namespaces\"] : null;\n const routed = Array.isArray(excluded) ? [...direct, ...excluded] : direct;\n // Moving the owner also renames its peers. Keep names that the caller\n // explicitly routed or excluded from Code Mode.\n if (\n current === bare ||\n occupied.has(bare) ||\n routed.some(\n (name) =>\n name === current ||\n (typeof name === \"string\" &&\n /^mcp__codex_security_[0-9a-f]{12}$/u.test(name)),\n ) ||\n (option != null && !enabled)\n )\n return [];\n overrides.push(\n `features.non_prefixed_mcp_tool_names=${inlineToml({\n enabled: true,\n server_names: [...(Array.isArray(selected) ? selected : []), owner],\n })}`,\n );\n required = [bare];\n } else if (occupied.has(prefixed) || occupied.has(bare)) {\n required = [current];\n }\n if (!required.every((name) => direct.includes(name))) {\n overrides.push(\n `features.code_mode.direct_only_tool_namespaces=${inlineToml([...new Set([...direct, ...required])])}`,\n );\n }\n return overrides;\n}\n\n// The direct coordinator records context but never calls a model itself.\nexport const DIRECT_DEEP_SCAN_CONTROL_USAGE = {\n input_tokens: 0,\n cached_input_tokens: 0,\n cache_write_input_tokens: 0,\n output_tokens: 0,\n} as const;\n\n/** Run the same coordinator as the plugin, without a parent model turn. */\nexport async function* runDeepScan(\n options: DirectDeepScanOptions,\n): AsyncGenerator<{\n type: string;\n [key: string]: unknown;\n}> {\n const native = await import(\n pathToFileURL(\n join(options.pluginRoot, \"mcp\", \"permission-profile-preflight.mjs\"),\n ).href\n );\n const profile = await import(\n pathToFileURL(join(options.pluginRoot, \"scripts\", \"codex_profile.mjs\")).href\n );\n const configured = options.codexOptions;\n const command = options.preflightCommand;\n const environment = bundledCodexSdkEnvironment(command.command, {\n ...configured.env,\n ...(configured.apiKey === undefined\n ? {}\n : { CODEX_API_KEY: configured.apiKey }),\n });\n const session = (await withCodexPreflightLock(\n environment,\n options.signal,\n () =>\n native.prepareCliDeepScanSession({\n codexPath: command.command,\n commandArgs: command.args,\n cwd: options.scanDir,\n env: environment,\n configOverrides: [\n ...profile.profileConfigOverrides(configured.config ?? {}),\n ...(configured.configOverrides ?? []),\n // This session only records native context; workers keep their own snapshot.\n \"features.plugins=false\",\n ],\n signal: options.signal,\n prompt:\n options.prompt +\n \"\\n\\nThe host runs this Deep Scan coordinator directly and owns finalization. This saved request supplies context for later follow-up; do not start a replacement scan.\",\n }),\n )) as {\n threadId: string;\n model: string;\n reasoningEffort?: string;\n permissionProfile: unknown;\n };\n yield { type: \"thread.started\", thread_id: session.threadId };\n options.signal.throwIfAborted();\n const node = process.versions[\"bun\"]\n ? await resolveTrustedExecutable(\"node\", environment, [options.repository])\n : undefined;\n if (node === null)\n throw new CodexSecurityError(\"Node.js is not available on PATH.\");\n const output = await runEngine(\n node?.executable ?? process.execPath,\n [join(options.pluginRoot, \"mcp\", \"server.mjs\"), \"--deep-scan-engine\"],\n node?.environment ?? environment,\n JSON.stringify({\n scanId: options.scanId,\n ...session,\n ...(options.onDiagnostic && { diagnosticsVersion: 1 }),\n }),\n options.signal,\n options.onDiagnostic,\n );\n const completed = JSON.parse(output);\n if (\n completed.scanId !== options.scanId ||\n completed.manifestPath !== join(options.scanDir, \"scan-manifest.json\")\n ) {\n throw new CodexSecurityError(\n \"Deep Scan engine returned results for a different scan.\",\n );\n }\n // The control session makes no model calls. Worker usage is read by the\n // existing scan tracker from the native sessions below this scan directory.\n yield {\n type: \"turn.completed\",\n usage: { ...DIRECT_DEEP_SCAN_CONTROL_USAGE },\n };\n}\n\nfunction runEngine(\n command: string,\n args: string[],\n env: NodeJS.ProcessEnv,\n request: string,\n signal: AbortSignal,\n onDiagnostic: DirectDeepScanOptions[\"onDiagnostic\"],\n): Promise<string> {\n signal.throwIfAborted();\n const child = spawn(executablePathForSpawn(command), args, {\n env,\n windowsHide: true,\n serialization: \"json\",\n stdio: onDiagnostic ? [\"pipe\", \"pipe\", \"pipe\", \"ipc\"] : \"pipe\",\n }) as ChildProcessWithoutNullStreams;\n if (onDiagnostic) {\n child.on(\"message\", (message) => {\n if (!isRecord(message) || typeof message[\"event\"] !== \"string\") return;\n const fields: Record<string, string | number> = {};\n for (const [name, value] of Object.entries(message)) {\n if (\n /^[a-zA-Z][a-zA-Z0-9]*$/u.test(name) &&\n (typeof value === \"number\" || typeof value === \"string\")\n )\n fields[name] = value;\n }\n try {\n void Promise.resolve(onDiagnostic(fields)).catch(() => {});\n } catch {\n // The optional diagnostic sink cannot stop the scan.\n }\n });\n }\n // EOF requests graceful coordinator/worker cleanup on Windows as well as Unix.\n // Keep the control pipe open until completion or explicit cancellation.\n const cancel = () => child.stdin.end();\n let stdout = \"\";\n let stderr = \"\";\n let processError: Error | undefined;\n child.stdout.setEncoding(\"utf8\").on(\"data\", (chunk) => {\n stdout += chunk;\n });\n child.stderr.setEncoding(\"utf8\").on(\"data\", (chunk) => {\n stderr += chunk;\n });\n child.once(\"error\", (error) => {\n processError = error;\n });\n child.stdin.on(\"error\", (error: NodeJS.ErrnoException) => {\n if (!isDisconnectedChildStdin(error)) processError = error;\n });\n const result = new Promise<string>((resolve, reject) => {\n child.once(\"close\", (code) => {\n signal.removeEventListener(\"abort\", cancel);\n if (signal.aborted) reject(signal.reason);\n else if (processError) reject(processError);\n else if (code !== 0)\n reject(\n new CodexSecurityError(\n stderr.trim() || `Deep Scan engine exited with code ${code}.`,\n ),\n );\n else resolve(stdout);\n });\n });\n child.stdin.write(request + \"\\n\");\n signal.addEventListener(\"abort\", cancel, { once: true });\n if (signal.aborted) cancel();\n return result;\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const defaultSeverityRubric = "# Severity guidance\n\nJudge the attacker's actual starting access, the security boundary crossed, and the additional unauthorized harm. Keep confidence separate from severity and identify the missing fact that could change the assessment. Missing proof alone does not establish that a broader attack is impossible; do not invent an attack path or downgrade merely because exploitation was not demonstrated.\n\n## Critical\n\nReserve Critical for consequential, strongly supported compromise meeting all three conditions:\n- Access
|
|
1
|
+
export declare const defaultSeverityRubric = "# Severity guidance\n\nJudge the attacker's actual starting access, the security boundary crossed, and the additional unauthorized harm. Keep confidence separate from severity and identify the missing fact that could change the assessment. Missing proof alone does not establish that a broader attack is impossible; do not invent an attack path or downgrade merely because exploitation was not demonstrated.\n\n## Critical\n\nReserve Critical for consequential, strongly supported compromise meeting all three conditions:\n\n- **Access.** An unauthenticated internet attacker, ordinary external user, or publicly admitted untrusted workload can exploit the interface without employee-only access, an invitation, an approved business relationship, or compromise of a trusted supplier.\n- **Impact.** Crossing an important security boundary enables consequential access to protected data, privileged actions, meaningful code execution, workload escape, or comparable compromise of the affected system.\n- **Evidence.** Demonstrated exploitation or strong source-backed validation establishes the complete attack path.\n\nSecond-order attacks can qualify: an external attacker plants data that a trusted user or system later processes, causing consequential unauthorized access or privileged actions.\n\n## High\n\nAssign High when the evidence establishes all three conditions:\n\n- **Access.** A lower-trust actor can reach the affected operation. Internal users, partners, invited collaborators, and admitted untrusted workloads can qualify.\n- **Impact.** Crossing the boundary grants a substantial new capability. Examples include access to sensitive customer or business data or reusable credentials, account takeover, meaningful cross-tenant access or actions as another user, control of production workloads or deployments, privileged identities, encryption keys or important isolation boundaries, and significant repeatable disruption of a critical or shared service.\n- **Evidence.** Identify a realistic path from the actor's existing access to the new capability. A dangerous function, production label, internal access, or privileged credential alone leaves that path unproven.\n\n## Medium\n\nAssign Medium to a credible vulnerability with concretely bounded impact, such as nonsecret operational information, narrow unauthorized changes, contained disruption of a noncritical service, or isolated development or staging systems without a consequential pivot. A fully demonstrated vulnerability can still be Medium. Base a downgrade on verified constraints, not on an assumption that missing evidence rules out broader harm.\n\n## Low\n\nAssign Low to a supported security weakness with minor additional unauthorized harm and verified limits on its scope, sensitivity, or duration, such as a small information exposure with little security value or a narrowly contained nuisance. Do not use Low as a substitute for uncertainty about a potentially serious path.\n\n## Informational\n\nAssign Informational to a hardening opportunity or observation for which the supplied evidence establishes no additional unauthorized capability or security impact. Explain why it is informational rather than treating missing proof of exploitation as proof of safety. Administrative records that do not describe a security finding may be excluded; exclusion is distinct from severity.\n";
|
|
2
2
|
//# sourceMappingURL=default-severity-rubric.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-severity-rubric.d.ts","sourceRoot":"","sources":["../src/default-severity-rubric.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"default-severity-rubric.d.ts","sourceRoot":"","sources":["../src/default-severity-rubric.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,qBAAqB,0zGACuxG,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Generated from the plugin references/default-severity-rubric.md. Run pnpm build.
|
|
2
|
-
export const defaultSeverityRubric = "# Severity guidance\n\nJudge the attacker's actual starting access, the security boundary crossed, and the additional unauthorized harm. Keep confidence separate from severity and identify the missing fact that could change the assessment. Missing proof alone does not establish that a broader attack is impossible; do not invent an attack path or downgrade merely because exploitation was not demonstrated.\n\n## Critical\n\nReserve Critical for consequential, strongly supported compromise meeting all three conditions:\n- Access
|
|
2
|
+
export const defaultSeverityRubric = "# Severity guidance\n\nJudge the attacker's actual starting access, the security boundary crossed, and the additional unauthorized harm. Keep confidence separate from severity and identify the missing fact that could change the assessment. Missing proof alone does not establish that a broader attack is impossible; do not invent an attack path or downgrade merely because exploitation was not demonstrated.\n\n## Critical\n\nReserve Critical for consequential, strongly supported compromise meeting all three conditions:\n\n- **Access.** An unauthenticated internet attacker, ordinary external user, or publicly admitted untrusted workload can exploit the interface without employee-only access, an invitation, an approved business relationship, or compromise of a trusted supplier.\n- **Impact.** Crossing an important security boundary enables consequential access to protected data, privileged actions, meaningful code execution, workload escape, or comparable compromise of the affected system.\n- **Evidence.** Demonstrated exploitation or strong source-backed validation establishes the complete attack path.\n\nSecond-order attacks can qualify: an external attacker plants data that a trusted user or system later processes, causing consequential unauthorized access or privileged actions.\n\n## High\n\nAssign High when the evidence establishes all three conditions:\n\n- **Access.** A lower-trust actor can reach the affected operation. Internal users, partners, invited collaborators, and admitted untrusted workloads can qualify.\n- **Impact.** Crossing the boundary grants a substantial new capability. Examples include access to sensitive customer or business data or reusable credentials, account takeover, meaningful cross-tenant access or actions as another user, control of production workloads or deployments, privileged identities, encryption keys or important isolation boundaries, and significant repeatable disruption of a critical or shared service.\n- **Evidence.** Identify a realistic path from the actor's existing access to the new capability. A dangerous function, production label, internal access, or privileged credential alone leaves that path unproven.\n\n## Medium\n\nAssign Medium to a credible vulnerability with concretely bounded impact, such as nonsecret operational information, narrow unauthorized changes, contained disruption of a noncritical service, or isolated development or staging systems without a consequential pivot. A fully demonstrated vulnerability can still be Medium. Base a downgrade on verified constraints, not on an assumption that missing evidence rules out broader harm.\n\n## Low\n\nAssign Low to a supported security weakness with minor additional unauthorized harm and verified limits on its scope, sensitivity, or duration, such as a small information exposure with little security value or a narrowly contained nuisance. Do not use Low as a substitute for uncertainty about a potentially serious path.\n\n## Informational\n\nAssign Informational to a hardening opportunity or observation for which the supplied evidence establishes no additional unauthorized capability or security impact. Explain why it is informational rather than treating missing proof of exploitation as proof of safety. Administrative records that do not describe a security finding may be excluded; exclusion is distinct from severity.\n";
|
|
3
3
|
//# sourceMappingURL=default-severity-rubric.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-severity-rubric.js","sourceRoot":"","sources":["../src/default-severity-rubric.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,CAAC,MAAM,qBAAqB,GAChC,
|
|
1
|
+
{"version":3,"file":"default-severity-rubric.js","sourceRoot":"","sources":["../src/default-severity-rubric.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,CAAC,MAAM,qBAAqB,GAChC,uzGAAuzG,CAAC","sourcesContent":["// Generated from the plugin references/default-severity-rubric.md. Run pnpm build.\nexport const defaultSeverityRubric =\n \"# Severity guidance\\n\\nJudge the attacker's actual starting access, the security boundary crossed, and the additional unauthorized harm. Keep confidence separate from severity and identify the missing fact that could change the assessment. Missing proof alone does not establish that a broader attack is impossible; do not invent an attack path or downgrade merely because exploitation was not demonstrated.\\n\\n## Critical\\n\\nReserve Critical for consequential, strongly supported compromise meeting all three conditions:\\n\\n- **Access.** An unauthenticated internet attacker, ordinary external user, or publicly admitted untrusted workload can exploit the interface without employee-only access, an invitation, an approved business relationship, or compromise of a trusted supplier.\\n- **Impact.** Crossing an important security boundary enables consequential access to protected data, privileged actions, meaningful code execution, workload escape, or comparable compromise of the affected system.\\n- **Evidence.** Demonstrated exploitation or strong source-backed validation establishes the complete attack path.\\n\\nSecond-order attacks can qualify: an external attacker plants data that a trusted user or system later processes, causing consequential unauthorized access or privileged actions.\\n\\n## High\\n\\nAssign High when the evidence establishes all three conditions:\\n\\n- **Access.** A lower-trust actor can reach the affected operation. Internal users, partners, invited collaborators, and admitted untrusted workloads can qualify.\\n- **Impact.** Crossing the boundary grants a substantial new capability. Examples include access to sensitive customer or business data or reusable credentials, account takeover, meaningful cross-tenant access or actions as another user, control of production workloads or deployments, privileged identities, encryption keys or important isolation boundaries, and significant repeatable disruption of a critical or shared service.\\n- **Evidence.** Identify a realistic path from the actor's existing access to the new capability. A dangerous function, production label, internal access, or privileged credential alone leaves that path unproven.\\n\\n## Medium\\n\\nAssign Medium to a credible vulnerability with concretely bounded impact, such as nonsecret operational information, narrow unauthorized changes, contained disruption of a noncritical service, or isolated development or staging systems without a consequential pivot. A fully demonstrated vulnerability can still be Medium. Base a downgrade on verified constraints, not on an assumption that missing evidence rules out broader harm.\\n\\n## Low\\n\\nAssign Low to a supported security weakness with minor additional unauthorized harm and verified limits on its scope, sensitivity, or duration, such as a small information exposure with little security value or a narrowly contained nuisance. Do not use Low as a substitute for uncertainty about a potentially serious path.\\n\\n## Informational\\n\\nAssign Informational to a hardening opportunity or observation for which the supplied evidence establishes no additional unauthorized capability or security impact. Explain why it is informational rather than treating missing proof of exploitation as proof of safety. Administrative records that do not describe a security finding may be excluded; exclusion is distinct from severity.\\n\";\n"]}
|
package/dist/endor-findings.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ExternalImportTarget } from "./external-import-contract.js";
|
|
2
2
|
import type { ExternalFindings } from "./external-findings.js";
|
|
3
3
|
/** Saved Endor Finding objects, an array, or an unmasked ListFindingsResponse. */
|
|
4
4
|
export declare function normalizeEndorFindings(input: unknown, target?: ExternalImportTarget): ExternalFindings;
|
|
5
|
+
/** A native upload would ask the worker to reconstruct fields that Cloud could not accept. */
|
|
6
|
+
export declare function requiresStructuredEndorReport(findings: ExternalFindings): boolean;
|
|
5
7
|
/** Endor's documented SARIF producer uses properties.finding-uuid, not its rule name. */
|
|
6
8
|
export declare function normalizeEndorSarif(input: unknown, target?: ExternalImportTarget): ExternalFindings;
|
|
7
9
|
export declare function readEndorFindings(path: string, target?: ExternalImportTarget): Promise<ExternalFindings>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endor-findings.d.ts","sourceRoot":"","sources":["../src/endor-findings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"endor-findings.d.ts","sourceRoot":"","sources":["../src/endor-findings.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,oBAAoB,EAG1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAiG/D,kFAAkF;AAClF,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,EACd,MAAM,GAAE,oBAA8B,GACrC,gBAAgB,CAElB;AAID,8FAA8F;AAC9F,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,gBAAgB,WAEvE;AA6KD,yFAAyF;AACzF,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,EACd,MAAM,GAAE,oBAA8B,GACrC,gBAAgB,CA4GlB;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,oBAA8B,GACrC,OAAO,CAAC,gBAAgB,CAAC,CAE3B"}
|