@openai/codex-security 0.8.2 → 0.8.3
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 +43 -61
- package/_bundled_plugin/.app.json +4 -0
- package/_bundled_plugin/.mcp.json +1 -0
- 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/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/permission-profile-preflight.mjs +46 -12
- 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/references/artifact-storage.md +1 -1
- package/_bundled_plugin/references/core-scan.md +14 -5
- package/_bundled_plugin/references/default-severity-rubric.md +28 -0
- package/_bundled_plugin/references/finding-detail-fields.md +1 -0
- package/_bundled_plugin/references/threat-model.md +1 -0
- package/_bundled_plugin/scripts/deep_scan_workbench.py +23 -112
- package/_bundled_plugin/scripts/finalize_scan_contract.py +167 -153
- package/_bundled_plugin/scripts/finding_preview.py +5 -29
- package/_bundled_plugin/scripts/posix_scan_local_files.py +187 -0
- package/_bundled_plugin/scripts/report_projection.py +87 -136
- package/_bundled_plugin/scripts/validate_scan_contract.py +2 -6
- package/_bundled_plugin/scripts/windows_scan_local_files.py +212 -55
- package/_bundled_plugin/scripts/workbench/retained_coverage.py +8 -24
- package/_bundled_plugin/scripts/workbench/saved_coverage.py +143 -231
- package/_bundled_plugin/scripts/workbench_cli.py +102 -13
- package/_bundled_plugin/scripts/workbench_constants.py +9 -0
- package/_bundled_plugin/scripts/workbench_db.py +186 -360
- package/_bundled_plugin/scripts/workbench_finding_workflows.py +86 -4
- package/_bundled_plugin/scripts/workbench_native_indexes.py +17 -21
- package/_bundled_plugin/scripts/workbench_remediation.py +495 -11
- package/_bundled_plugin/scripts/workbench_scan_history.py +22 -25
- package/_bundled_plugin/scripts/workbench_scan_start.py +1 -1
- package/_bundled_plugin/scripts/workbench_scan_usage.py +25 -52
- package/_bundled_plugin/scripts/workbench_schema.py +1 -1
- package/_bundled_plugin/scripts/workbench_setup.py +239 -0
- package/_bundled_plugin/scripts/workbench_source_scopes.py +15 -23
- package/_bundled_plugin/scripts/workbench_target.py +213 -20
- package/_bundled_plugin/scripts/workbench_validation.py +1 -9
- package/_bundled_plugin/shared/workbench-history-repairs.json +7 -0
- package/_bundled_plugin/shared/workbench-migrations.json +19 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +1 -1
- package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +4 -68
- package/_bundled_plugin/skills/check-skills/SKILL.md +43 -0
- package/_bundled_plugin/skills/check-skills/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/cloud-findings/SKILL.md +2 -0
- package/_bundled_plugin/skills/fix-finding/SKILL.md +18 -1
- package/_bundled_plugin/skills/publish-findings/SKILL.md +64 -35
- package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +2 -21
- package/_bundled_plugin/skills/threat-model-visualize/scripts/build_explorer.py +14 -8
- package/_bundled_plugin/skills/track-findings/SKILL.md +5 -3
- package/_bundled_plugin/skills/triage-finding/references/github-rest-intake.md +22 -68
- package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +6 -4
- package/dist/api.d.ts +6 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +411 -160
- package/dist/api.js.map +1 -1
- package/dist/auth.js +6 -1
- package/dist/auth.js.map +1 -1
- package/dist/blackduck-findings.d.ts +8 -0
- package/dist/blackduck-findings.d.ts.map +1 -0
- package/dist/blackduck-findings.js +305 -0
- package/dist/blackduck-findings.js.map +1 -0
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +51 -36
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/classify-severity-records.d.ts +5 -0
- package/dist/classify-severity-records.d.ts.map +1 -1
- package/dist/classify-severity-records.js +6 -8
- package/dist/classify-severity-records.js.map +1 -1
- package/dist/classify-severity.d.ts +4 -1
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +28 -9
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +608 -258
- package/dist/cli.js.map +1 -1
- package/dist/codex-prompt.d.ts +2 -0
- package/dist/codex-prompt.d.ts.map +1 -1
- package/dist/codex-prompt.js +6 -0
- package/dist/codex-prompt.js.map +1 -1
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +6 -5
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +162 -40
- package/dist/config.js.map +1 -1
- package/dist/continuum-findings.d.ts +7 -0
- package/dist/continuum-findings.d.ts.map +1 -0
- package/dist/continuum-findings.js +157 -0
- package/dist/continuum-findings.js.map +1 -0
- package/dist/contract-values.d.ts +28 -0
- package/dist/contract-values.d.ts.map +1 -0
- package/dist/contract-values.js +75 -0
- package/dist/contract-values.js.map +1 -0
- package/dist/contract.d.ts +2 -20
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +58 -669
- package/dist/contract.js.map +1 -1
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +1 -4
- package/dist/cost-model.js.map +1 -1
- package/dist/cost.d.ts +19 -1
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +2120 -39
- package/dist/cost.js.map +1 -1
- package/dist/custom-validation-prompt.d.ts +1 -1
- package/dist/custom-validation-prompt.d.ts.map +1 -1
- package/dist/custom-validation-prompt.js +5 -0
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/custom-validation.d.ts +2 -0
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +4 -0
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts +4 -4
- package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
- package/dist/deduplication/deduplication-prompts.js +2 -2
- package/dist/deduplication/deduplication-prompts.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts +14 -11
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
- package/dist/deduplication/deduplication-reviewer.js +11 -4
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/deduplication.js.map +1 -1
- package/dist/deduplication/finding-schema.d.ts +19 -1
- package/dist/deduplication/finding-schema.d.ts.map +1 -1
- package/dist/deduplication/finding-schema.js +25 -0
- package/dist/deduplication/finding-schema.js.map +1 -1
- package/dist/deduplication/local.d.ts.map +1 -1
- package/dist/deduplication/local.js +3 -8
- package/dist/deduplication/local.js.map +1 -1
- package/dist/deduplication/records.d.ts +8 -2
- package/dist/deduplication/records.d.ts.map +1 -1
- package/dist/deduplication/records.js +36 -8
- package/dist/deduplication/records.js.map +1 -1
- package/dist/deep-scan.d.ts +11 -0
- package/dist/deep-scan.d.ts.map +1 -1
- package/dist/deep-scan.js +235 -4
- package/dist/deep-scan.js.map +1 -1
- package/dist/default-severity-rubric.d.ts +1 -2
- package/dist/default-severity-rubric.d.ts.map +1 -1
- package/dist/default-severity-rubric.js +2 -66
- package/dist/default-severity-rubric.js.map +1 -1
- package/dist/endor-findings.d.ts.map +1 -1
- package/dist/endor-findings.js +7 -37
- package/dist/endor-findings.js.map +1 -1
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +5 -11
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts +9 -0
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +325 -179
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +12 -0
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +1202 -214
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +8 -0
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +65 -54
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-findings.d.ts +2 -0
- package/dist/external-findings.d.ts.map +1 -1
- package/dist/external-findings.js +111 -0
- package/dist/external-findings.js.map +1 -1
- package/dist/external-import-contract.d.ts +29 -1
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +314 -44
- 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/finding-normalization.d.ts +1 -1
- package/dist/finding-normalization.d.ts.map +1 -1
- package/dist/finding-normalization.js +46 -11
- package/dist/finding-normalization.js.map +1 -1
- package/dist/finding-retrieval.d.ts +3 -3
- package/dist/finding-retrieval.d.ts.map +1 -1
- package/dist/finding-retrieval.js.map +1 -1
- package/dist/finding-workflow.d.ts +6 -1
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js +2 -2
- package/dist/finding-workflow.js.map +1 -1
- package/dist/git-remote.d.ts +4 -0
- package/dist/git-remote.d.ts.map +1 -1
- package/dist/git-remote.js +20 -0
- package/dist/git-remote.js.map +1 -1
- package/dist/github-advisories.d.ts +3 -12
- package/dist/github-advisories.d.ts.map +1 -1
- package/dist/github-advisories.js +9 -29
- package/dist/github-advisories.js.map +1 -1
- package/dist/github-dependabot-findings.d.ts.map +1 -1
- package/dist/github-dependabot-findings.js +7 -16
- package/dist/github-dependabot-findings.js.map +1 -1
- package/dist/github-findings.d.ts.map +1 -1
- package/dist/github-findings.js +344 -56
- package/dist/github-findings.js.map +1 -1
- package/dist/github.d.ts +17 -7
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +43 -30
- package/dist/github.js.map +1 -1
- package/dist/host-protocol.d.ts +2 -2
- package/dist/host-protocol.d.ts.map +1 -1
- package/dist/host-protocol.js.map +1 -1
- package/dist/host-records-protocol.d.ts +10 -11
- package/dist/host-records-protocol.d.ts.map +1 -1
- package/dist/host-records-protocol.js +69 -9
- package/dist/host-records-protocol.js.map +1 -1
- package/dist/hosted-scan.d.ts +15 -0
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +55 -33
- package/dist/hosted-scan.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/inspector-findings.d.ts.map +1 -1
- package/dist/inspector-findings.js +13 -18
- package/dist/inspector-findings.js.map +1 -1
- package/dist/knowledge-base.js +18 -5
- package/dist/knowledge-base.js.map +1 -1
- package/dist/local-git-metadata.d.ts +5 -0
- package/dist/local-git-metadata.d.ts.map +1 -0
- package/dist/local-git-metadata.js +131 -0
- package/dist/local-git-metadata.js.map +1 -0
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +22 -12
- package/dist/multiscan.js.map +1 -1
- package/dist/opengrep-findings.d.ts.map +1 -1
- package/dist/opengrep-findings.js +34 -20
- package/dist/opengrep-findings.js.map +1 -1
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +90 -35
- package/dist/patch-tui.js.map +1 -1
- package/dist/private-finding-import.d.ts +246 -0
- package/dist/private-finding-import.d.ts.map +1 -0
- package/dist/private-finding-import.js +387 -0
- package/dist/private-finding-import.js.map +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +2 -2
- package/dist/project-config.js.map +1 -1
- package/dist/provider-profile.d.ts +10 -2
- package/dist/provider-profile.d.ts.map +1 -1
- package/dist/provider-profile.js +72 -10
- package/dist/provider-profile.js.map +1 -1
- package/dist/publication.js +7 -1
- package/dist/publication.js.map +1 -1
- package/dist/reader-selection.d.ts +13 -0
- package/dist/reader-selection.d.ts.map +1 -0
- package/dist/reader-selection.js +81 -0
- package/dist/reader-selection.js.map +1 -0
- package/dist/record.d.ts +6 -1
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +53 -2
- package/dist/record.js.map +1 -1
- package/dist/remediation.d.ts +5 -0
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +30 -0
- package/dist/remediation.js.map +1 -1
- package/dist/result.d.ts +2 -0
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +3 -1
- package/dist/result.js.map +1 -1
- package/dist/runtime.d.ts +2 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +95 -52
- package/dist/runtime.js.map +1 -1
- package/dist/scan-activity.js +40 -17
- package/dist/scan-activity.js.map +1 -1
- package/dist/scan-comparison.d.ts +1 -1
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +11 -13
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +1 -0
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +16 -37
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-executor.d.ts +2 -0
- package/dist/scan-executor.d.ts.map +1 -1
- package/dist/scan-executor.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +22 -9
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +5 -5
- package/dist/scan-logs.js.map +1 -1
- package/dist/scanner-import.d.ts +46 -6
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +208 -42
- package/dist/scanner-import.js.map +1 -1
- package/dist/scanner-repository-url.d.ts +14 -0
- package/dist/scanner-repository-url.d.ts.map +1 -0
- package/dist/scanner-repository-url.js +67 -0
- package/dist/scanner-repository-url.js.map +1 -0
- package/dist/semgrep-findings.d.ts.map +1 -1
- package/dist/semgrep-findings.js +20 -48
- package/dist/semgrep-findings.js.map +1 -1
- package/dist/semgrep-platform-findings.d.ts +12 -0
- package/dist/semgrep-platform-findings.d.ts.map +1 -0
- package/dist/semgrep-platform-findings.js +198 -0
- package/dist/semgrep-platform-findings.js.map +1 -0
- package/dist/severity-rubric.d.ts +20 -0
- package/dist/severity-rubric.d.ts.map +1 -0
- package/dist/severity-rubric.js +73 -0
- package/dist/severity-rubric.js.map +1 -0
- package/dist/severity-store.js +15 -5
- package/dist/severity-store.js.map +1 -1
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +21 -20
- package/dist/snyk-findings.js.map +1 -1
- package/dist/sonar-collector.d.ts +16 -0
- package/dist/sonar-collector.d.ts.map +1 -0
- package/dist/sonar-collector.js +383 -0
- package/dist/sonar-collector.js.map +1 -0
- package/dist/sonar-findings.d.ts +49 -0
- package/dist/sonar-findings.d.ts.map +1 -0
- package/dist/sonar-findings.js +288 -0
- package/dist/sonar-findings.js.map +1 -0
- package/dist/sonar-import.d.ts +111 -0
- package/dist/sonar-import.d.ts.map +1 -0
- package/dist/sonar-import.js +279 -0
- package/dist/sonar-import.js.map +1 -0
- package/dist/suggest-owners.d.ts.map +1 -1
- package/dist/suggest-owners.js +2 -1
- package/dist/suggest-owners.js.map +1 -1
- package/dist/targets.d.ts +3 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +18 -12
- package/dist/targets.js.map +1 -1
- package/dist/terminal-columns.d.ts +4 -0
- package/dist/terminal-columns.d.ts.map +1 -0
- package/dist/terminal-columns.js +19 -0
- package/dist/terminal-columns.js.map +1 -0
- package/dist/validation-records.d.ts +0 -3
- package/dist/validation-records.d.ts.map +1 -1
- package/dist/validation-records.js +0 -16
- package/dist/validation-records.js.map +1 -1
- package/dist/veracode-findings.d.ts +7 -0
- package/dist/veracode-findings.d.ts.map +1 -0
- package/dist/veracode-findings.js +371 -0
- package/dist/veracode-findings.js.map +1 -0
- package/dist/windows-path.d.ts.map +1 -1
- package/dist/windows-path.js +1 -0
- package/dist/windows-path.js.map +1 -1
- package/dist/wiz-csv.d.ts +2 -2
- package/dist/wiz-csv.d.ts.map +1 -1
- package/dist/wiz-csv.js +1 -3
- package/dist/wiz-csv.js.map +1 -1
- package/dist/wiz-findings.d.ts +10 -2
- package/dist/wiz-findings.d.ts.map +1 -1
- package/dist/wiz-findings.js +88 -49
- package/dist/wiz-findings.js.map +1 -1
- package/docs/classify-severity-records.md +1 -1
- package/docs/cli.md +310 -477
- package/docs/dedupe-records.md +10 -0
- package/docs/findings-service.md +21 -8
- package/docs/hosted-scans.md +16 -1
- package/package.json +8 -9
- package/schemas/external-findings.schema.json +12 -1
- package/schemas/hosted-scan-v2.fixture.json +16 -1
- package/_bundled_plugin/scripts/validate_tracking_source.py +0 -82
- package/_bundled_plugin/scripts/workbench_local_dedupe.py +0 -136
- package/dist/deduplication/records-protocol.d.ts +0 -4
- package/dist/deduplication/records-protocol.d.ts.map +0 -1
- package/dist/deduplication/records-protocol.js +0 -49
- package/dist/deduplication/records-protocol.js.map +0 -1
package/dist/deep-scan.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-scan.d.ts","sourceRoot":"","sources":["../src/deep-scan.ts"],"names":[],"mappings":"
|
|
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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 var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
7
7
|
return path;
|
|
8
8
|
};
|
|
9
9
|
import { spawn } from "node:child_process";
|
|
10
|
-
import {
|
|
10
|
+
import { realpathSync } from "node:fs";
|
|
11
|
+
import { join, resolve } from "node:path";
|
|
11
12
|
import { pathToFileURL } from "node:url";
|
|
12
|
-
import {
|
|
13
|
+
import { parse } from "smol-toml";
|
|
14
|
+
import { bundledCodexSdkEnvironment, resolveBundledCodexExecutable, } from "./codex-sdk-environment.js";
|
|
13
15
|
import { CodexSecurityError } from "./errors.js";
|
|
14
|
-
import {
|
|
16
|
+
import { deepMerge, inlineToml, } from "./config.js";
|
|
17
|
+
import { isRecord } from "./record.js";
|
|
18
|
+
import { executablePathForSpawn, PLUGIN_NAME, runCodexCommand, } from "./runtime.js";
|
|
15
19
|
import { resolveTrustedExecutable } from "./trusted-executable.js";
|
|
16
|
-
import { withCodexPreflightLock } from "./provider-profile.js";
|
|
20
|
+
import { nativePermissionPreflight, nativeProfileClient, withCodexPreflightLock, } from "./provider-profile.js";
|
|
21
|
+
// The stock SDK emits one flag per leaf, including literal dotted keys in order.
|
|
22
|
+
function sdkConfigFlags(config, prefix = "") {
|
|
23
|
+
return Object.entries(config).flatMap(([key, value]) => {
|
|
24
|
+
const path = prefix ? `${prefix}.${key}` : key;
|
|
25
|
+
return isRecord(value) && Object.keys(value).length
|
|
26
|
+
? sdkConfigFlags(value, path)
|
|
27
|
+
: [`${path}=${inlineToml(value)}`];
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// An older custom launcher must start in the caller's directory. Only use
|
|
31
|
+
// supplied routing when its app-server cannot read the scan at startup.
|
|
32
|
+
function suppliedParentRouting(overrides) {
|
|
33
|
+
try {
|
|
34
|
+
const config = Object.create(null);
|
|
35
|
+
for (const override of overrides) {
|
|
36
|
+
const equals = override.indexOf("=");
|
|
37
|
+
const key = override.slice(0, equals).trim();
|
|
38
|
+
if (!/^(?:features|mcp_servers)(?:\.|$)/u.test(key))
|
|
39
|
+
continue;
|
|
40
|
+
const path = key.split(".");
|
|
41
|
+
const leaf = path.pop();
|
|
42
|
+
let table = config;
|
|
43
|
+
for (const part of path) {
|
|
44
|
+
const next = Object.hasOwn(table, part) ? table[part] : undefined;
|
|
45
|
+
const child = table === config["features"] && part === "code_mode"
|
|
46
|
+
? codeModeTable(next)
|
|
47
|
+
: next;
|
|
48
|
+
table = table[part] = Object.assign(Object.create(null), isRecord(child) ? child : {});
|
|
49
|
+
}
|
|
50
|
+
const value = parse(`value=${override.slice(equals + 1)}`)["value"];
|
|
51
|
+
const priorMode = key === "features.code_mode" ? codeModeTable(table[leaf]) : undefined;
|
|
52
|
+
const newMode = priorMode && codeModeTable(value);
|
|
53
|
+
table[leaf] =
|
|
54
|
+
priorMode && newMode ? deepMerge({ ...priorMode }, newMode) : value;
|
|
55
|
+
}
|
|
56
|
+
const servers = config["mcp_servers"];
|
|
57
|
+
const owner = isRecord(servers) ? servers[PLUGIN_NAME] : undefined;
|
|
58
|
+
// Even a supplied transport can inherit a machine-level direct opt-out.
|
|
59
|
+
if (isRecord(owner) && !Array.isArray(owner["omit_tools_from"]))
|
|
60
|
+
return;
|
|
61
|
+
return config;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Leave malformed settings for exec's own parser.
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Codex merges a structured Code Mode setting with its boolean shorthand.
|
|
69
|
+
function codeModeTable(value) {
|
|
70
|
+
if (typeof value === "boolean")
|
|
71
|
+
return { enabled: value };
|
|
72
|
+
return isRecord(value) ? value : undefined;
|
|
73
|
+
}
|
|
74
|
+
/** Read the same native layers and CLI overrides as the parent before adding its tool. */
|
|
75
|
+
export async function readDeepScanParentConfig(options) {
|
|
76
|
+
const { codexOptions, preflightCommand: command } = options;
|
|
77
|
+
const config = codexOptions.config ?? {};
|
|
78
|
+
// The provider-profile launcher emits whole top-level tables instead.
|
|
79
|
+
const overrides = codexOptions.nativeProfile === undefined
|
|
80
|
+
? sdkConfigFlags(config)
|
|
81
|
+
: (await nativeProfileClient()).profileConfigOverrides(config);
|
|
82
|
+
const environment = bundledCodexSdkEnvironment(command.command, {
|
|
83
|
+
...codexOptions.env,
|
|
84
|
+
...(codexOptions.apiKey === undefined
|
|
85
|
+
? {}
|
|
86
|
+
: { CODEX_API_KEY: codexOptions.apiKey }),
|
|
87
|
+
});
|
|
88
|
+
const configOverrides = [
|
|
89
|
+
...overrides,
|
|
90
|
+
...(codexOptions.configOverrides ?? []),
|
|
91
|
+
];
|
|
92
|
+
// Subcommand help does not load a project. A global --cd is ignored by
|
|
93
|
+
// older app-servers, so require support on the subcommand itself.
|
|
94
|
+
const help = await runCodexCommand(command, ["app-server", "--cd", options.scanDir, "--help"], environment, undefined, options.signal);
|
|
95
|
+
const supportsCd = help.success && /^\s*(?:-C,\s*)?--cd\s+<[^>\n]+>/mu.test(help.stdout);
|
|
96
|
+
if (!supportsCd) {
|
|
97
|
+
// The bundled command is the native executable itself. A custom launcher
|
|
98
|
+
// can use its own working directory to resolve scripts and other inputs.
|
|
99
|
+
if (resolve(options.scanDir) !== process.cwd() &&
|
|
100
|
+
!isBundledExecutable(command.command))
|
|
101
|
+
return options.plugin
|
|
102
|
+
? undefined
|
|
103
|
+
: suppliedParentRouting(configOverrides);
|
|
104
|
+
if (environment["CODEX_HOME"])
|
|
105
|
+
environment["CODEX_HOME"] = resolve(environment["CODEX_HOME"]);
|
|
106
|
+
}
|
|
107
|
+
const native = await nativePermissionPreflight();
|
|
108
|
+
return withCodexPreflightLock(environment, options.signal, () => native.readDeepScanRuntimeConfig({
|
|
109
|
+
codexPath: command.command,
|
|
110
|
+
commandArgs: command.args,
|
|
111
|
+
cwd: supportsCd ? process.cwd() : options.scanDir,
|
|
112
|
+
...(supportsCd && { configCwd: options.scanDir }),
|
|
113
|
+
configOverrides,
|
|
114
|
+
env: environment,
|
|
115
|
+
signal: options.signal,
|
|
116
|
+
context: "parent-config",
|
|
117
|
+
plugin: options.plugin,
|
|
118
|
+
}, (config, hasEmptyCatalog) => inspectFilteredPeers(config, options.pluginServers, hasEmptyCatalog)));
|
|
119
|
+
}
|
|
120
|
+
function isBundledExecutable(command) {
|
|
121
|
+
try {
|
|
122
|
+
return (realpathSync.native(command) ===
|
|
123
|
+
realpathSync.native(resolveBundledCodexExecutable()));
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return false; // An installation may supply only an external launcher.
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async function inspectFilteredPeers(config, pluginServers, hasEmptyCatalog) {
|
|
130
|
+
const configured = isRecord(config["mcp_servers"])
|
|
131
|
+
? config["mcp_servers"]
|
|
132
|
+
: {};
|
|
133
|
+
const owner = configured[PLUGIN_NAME];
|
|
134
|
+
if (isRecord(owner) &&
|
|
135
|
+
(owner["command"] ||
|
|
136
|
+
owner["url"] ||
|
|
137
|
+
Array.isArray(owner["omit_tools_from"])))
|
|
138
|
+
return config;
|
|
139
|
+
const servers = { ...pluginServers, ...configured };
|
|
140
|
+
const registration = servers[PLUGIN_NAME];
|
|
141
|
+
if (!isRecord(registration) || registration["enabled"] === false)
|
|
142
|
+
return config;
|
|
143
|
+
const routing = { ...configured };
|
|
144
|
+
for (const [name, settings] of Object.entries(servers)) {
|
|
145
|
+
if (name === PLUGIN_NAME ||
|
|
146
|
+
!isRecord(settings) ||
|
|
147
|
+
settings["enabled"] === false ||
|
|
148
|
+
!["codex_security", "mcp__codex_security"].includes(normalizedServerName(name)))
|
|
149
|
+
continue;
|
|
150
|
+
if (![settings["enabled_tools"], settings["disabled_tools"]].some((tools) => Array.isArray(tools) && tools.length > 0))
|
|
151
|
+
continue;
|
|
152
|
+
if (await hasEmptyCatalog(name)) {
|
|
153
|
+
// This view is used only to select a namespace. Never change the peer's config.
|
|
154
|
+
routing[name] = { enabled_tools: [] };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return { ...config, mcp_servers: routing };
|
|
158
|
+
}
|
|
159
|
+
function normalizedServerName(server) {
|
|
160
|
+
return server.replace(/[-.:@/]/gu, "_");
|
|
161
|
+
}
|
|
162
|
+
/** Keep direct dispatch scoped to the original SDK coordinator turn and MCP server. */
|
|
163
|
+
export function deepScanParentToolOverrides(config, pluginServers) {
|
|
164
|
+
const features = config["features"] ?? {};
|
|
165
|
+
if (!isRecord(features))
|
|
166
|
+
return [];
|
|
167
|
+
const mode = features["code_mode"];
|
|
168
|
+
if (mode !== undefined && typeof mode !== "boolean" && !isRecord(mode))
|
|
169
|
+
return [];
|
|
170
|
+
const direct = (isRecord(mode) ? mode["direct_only_tool_namespaces"] : undefined) ?? [];
|
|
171
|
+
if (!Array.isArray(direct))
|
|
172
|
+
return [];
|
|
173
|
+
const owner = PLUGIN_NAME;
|
|
174
|
+
const bare = "codex_security";
|
|
175
|
+
const prefixed = "mcp__codex_security";
|
|
176
|
+
let required = [prefixed, bare];
|
|
177
|
+
const overrides = [];
|
|
178
|
+
const configured = config["mcp_servers"];
|
|
179
|
+
// Native registrations take precedence over the selected plugin's entries.
|
|
180
|
+
const servers = {
|
|
181
|
+
...pluginServers,
|
|
182
|
+
...(isRecord(configured) ? configured : {}),
|
|
183
|
+
};
|
|
184
|
+
const ownerConfig = servers[owner];
|
|
185
|
+
if (!isRecord(ownerConfig) || ownerConfig["enabled"] === false)
|
|
186
|
+
return [];
|
|
187
|
+
const omitted = ownerConfig["omit_tools_from"];
|
|
188
|
+
if (Array.isArray(omitted) && omitted.includes("direct"))
|
|
189
|
+
return [];
|
|
190
|
+
// A raw transport or an existing omission leaf can be updated in place.
|
|
191
|
+
// Adding a new registration would shadow a plugin's transport and policy.
|
|
192
|
+
if (isRecord(configured) &&
|
|
193
|
+
Object.hasOwn(configured, owner) &&
|
|
194
|
+
(Array.isArray(omitted) ||
|
|
195
|
+
typeof ownerConfig["command"] === "string" ||
|
|
196
|
+
typeof ownerConfig["url"] === "string")) {
|
|
197
|
+
if (omitted != null && !Array.isArray(omitted))
|
|
198
|
+
return [];
|
|
199
|
+
const surfaces = omitted ?? [];
|
|
200
|
+
if (surfaces.includes("code_mode") && surfaces.includes("deferred"))
|
|
201
|
+
return [];
|
|
202
|
+
return [
|
|
203
|
+
`mcp_servers.${owner}.omit_tools_from=${inlineToml([...new Set([...surfaces, "code_mode", "deferred"])])}`,
|
|
204
|
+
];
|
|
205
|
+
}
|
|
206
|
+
const option = features["non_prefixed_mcp_tool_names"];
|
|
207
|
+
const enabled = option === true || (isRecord(option) && option["enabled"] === true);
|
|
208
|
+
const selected = isRecord(option) ? option["server_names"] : undefined;
|
|
209
|
+
function namespace(server) {
|
|
210
|
+
const name = normalizedServerName(server);
|
|
211
|
+
const omitPrefix = enabled && (!Array.isArray(selected) || selected.includes(server));
|
|
212
|
+
return omitPrefix || name.startsWith("mcp__") ? name : `mcp__${name}`;
|
|
213
|
+
}
|
|
214
|
+
const occupied = new Set(Object.entries(servers)
|
|
215
|
+
.filter(([server, settings]) => server !== owner &&
|
|
216
|
+
isRecord(settings) &&
|
|
217
|
+
settings["enabled"] !== false &&
|
|
218
|
+
(!Array.isArray(settings["enabled_tools"]) ||
|
|
219
|
+
settings["enabled_tools"].length > 0))
|
|
220
|
+
.map(([server]) => namespace(server)));
|
|
221
|
+
const current = namespace(owner);
|
|
222
|
+
if (occupied.has(current)) {
|
|
223
|
+
const excluded = isRecord(mode) ? mode["excluded_tool_namespaces"] : null;
|
|
224
|
+
const routed = Array.isArray(excluded) ? [...direct, ...excluded] : direct;
|
|
225
|
+
// Moving the owner also renames its peers. Keep names that the caller
|
|
226
|
+
// explicitly routed or excluded from Code Mode.
|
|
227
|
+
if (current === bare ||
|
|
228
|
+
occupied.has(bare) ||
|
|
229
|
+
routed.some((name) => name === current ||
|
|
230
|
+
(typeof name === "string" &&
|
|
231
|
+
/^mcp__codex_security_[0-9a-f]{12}$/u.test(name))) ||
|
|
232
|
+
(option != null && !enabled))
|
|
233
|
+
return [];
|
|
234
|
+
overrides.push(`features.non_prefixed_mcp_tool_names=${inlineToml({
|
|
235
|
+
enabled: true,
|
|
236
|
+
server_names: [...(Array.isArray(selected) ? selected : []), owner],
|
|
237
|
+
})}`);
|
|
238
|
+
required = [bare];
|
|
239
|
+
}
|
|
240
|
+
else if (occupied.has(prefixed) || occupied.has(bare)) {
|
|
241
|
+
required = [current];
|
|
242
|
+
}
|
|
243
|
+
if (!required.every((name) => direct.includes(name))) {
|
|
244
|
+
overrides.push(`features.code_mode.direct_only_tool_namespaces=${inlineToml([...new Set([...direct, ...required])])}`);
|
|
245
|
+
}
|
|
246
|
+
return overrides;
|
|
247
|
+
}
|
|
17
248
|
// The direct coordinator records context but never calls a model itself.
|
|
18
249
|
export const DIRECT_DEEP_SCAN_CONTROL_USAGE = {
|
|
19
250
|
input_tokens: 0,
|
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,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAqB,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAa/D,yEAAyE;AACzE,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,YAAY,EAAE,CAAC;IACf,mBAAmB,EAAE,CAAC;IACtB,wBAAwB,EAAE,CAAC;IAC3B,aAAa,EAAE,CAAC;CACR,CAAC;AAEX,2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AC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,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 { join } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { CodexOptions } from \"@openai/codex-sdk\";\nimport { bundledCodexSdkEnvironment } from \"./codex-sdk-environment.js\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport { executablePathForSpawn, type CodexCommand } from \"./runtime.js\";\nimport { resolveTrustedExecutable } from \"./trusted-executable.js\";\nimport { withCodexPreflightLock } 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 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,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE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QACvD,IACE,CAAC,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,QAAQ,CAC9D,KAAK,CAAC,IAAI,IAAI,EAAE,CACjB;YAED,YAAY,GAAG,KAAK,CAAC;IACzB,CAAC,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrD,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,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,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const defaultSeverityRubric = "# Severity guidance\n\nJudge the attacker's actual starting access, the security boundary crossed, and\nthe additional unauthorized harm. Use the supplied report and evidence; do not\nperform new validation. Keep confidence separate from severity and identify the\nmissing fact that could change the assessment. Missing proof alone does not\nestablish that a broader attack is impossible; do not invent an attack path or\ndowngrade merely because exploitation was not demonstrated.\n\n## Critical\n\nReserve Critical for consequential, strongly supported compromise meeting all\nthree conditions:\n- Access: an unauthenticated internet attacker, ordinary external user, or\n publicly admitted untrusted workload can exploit the interface without\n employee-only access, an invitation, an approved business relationship, or\n compromise of a trusted supplier.\n- Impact: crossing an important security boundary enables consequential access\n to protected data, privileged actions, meaningful code execution, workload\n escape, or comparable compromise of the affected system.\n- Evidence: demonstrated exploitation or strong source-backed validation\n establishes the complete attack path.\n\nSecond-order attacks can qualify: an external attacker plants data that a trusted\nuser or system later processes, causing consequential unauthorized access or\nprivileged actions.\n\n## High\n\nAssign High when a realistic, evidenced path gives a lower-trust attacker a\nsubstantial unauthorized capability they did not already possess. Internal\nusers, partners, invited collaborators, and admitted untrusted workloads can\nqualify; unauthenticated internet access is not required. Consequences include\nsensitive customer or business data or reusable credentials, account takeover,\nmeaningful cross-tenant access or actions as another user, control of production\nworkloads or deployments, privileged identities, encryption keys or important\nisolation boundaries, or significant repeatable disruption of a critical or\nshared service. A dangerous function, production label, internal access, or the\nexistence of a privileged credential alone is insufficient: identify the\nlower-trust actor, boundary crossing, and consequential new capability.\n\n## Medium\n\nAssign Medium to a credible vulnerability with concretely bounded impact, such\nas nonsecret operational information, narrow unauthorized changes, contained\ndisruption of a noncritical service, or isolated development or staging systems\nwithout a consequential pivot. A fully demonstrated vulnerability can still be\nMedium. Base a downgrade on verified constraints, not on an assumption that\nmissing evidence rules out broader harm.\n\n## Low\n\nAssign Low to a supported security weakness with minor additional unauthorized\nharm and verified limits on its scope, sensitivity, or duration, such as a small\ninformation exposure with little security value or a narrowly contained nuisance.\nDo 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\nsupplied evidence establishes no additional unauthorized capability or security\nimpact. Explain why it is informational rather than treating missing proof of\nexploitation as proof of safety. Administrative records that do not describe a\nsecurity finding may be excluded; exclusion is distinct from severity.\n";
|
|
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: 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 a realistic, evidenced path gives a lower-trust attacker a substantial unauthorized capability they did not already possess. Internal users, partners, invited collaborators, and admitted untrusted workloads can qualify; unauthenticated internet access is not required. Consequences include 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, or significant repeatable disruption of a critical or shared service. A dangerous function, production label, internal access, or the existence of a privileged credential alone is insufficient: identify the lower-trust actor, boundary crossing, and consequential new capability.\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
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":"
|
|
1
|
+
{"version":3,"file":"default-severity-rubric.d.ts","sourceRoot":"","sources":["../src/default-severity-rubric.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,qBAAqB,8wGAC2uG,CAAC"}
|
|
@@ -1,67 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export const defaultSeverityRubric =
|
|
3
|
-
|
|
4
|
-
Judge the attacker's actual starting access, the security boundary crossed, and
|
|
5
|
-
the additional unauthorized harm. Use the supplied report and evidence; do not
|
|
6
|
-
perform new validation. Keep confidence separate from severity and identify the
|
|
7
|
-
missing fact that could change the assessment. Missing proof alone does not
|
|
8
|
-
establish that a broader attack is impossible; do not invent an attack path or
|
|
9
|
-
downgrade merely because exploitation was not demonstrated.
|
|
10
|
-
|
|
11
|
-
## Critical
|
|
12
|
-
|
|
13
|
-
Reserve Critical for consequential, strongly supported compromise meeting all
|
|
14
|
-
three conditions:
|
|
15
|
-
- Access: an unauthenticated internet attacker, ordinary external user, or
|
|
16
|
-
publicly admitted untrusted workload can exploit the interface without
|
|
17
|
-
employee-only access, an invitation, an approved business relationship, or
|
|
18
|
-
compromise of a trusted supplier.
|
|
19
|
-
- Impact: crossing an important security boundary enables consequential access
|
|
20
|
-
to protected data, privileged actions, meaningful code execution, workload
|
|
21
|
-
escape, or comparable compromise of the affected system.
|
|
22
|
-
- Evidence: demonstrated exploitation or strong source-backed validation
|
|
23
|
-
establishes the complete attack path.
|
|
24
|
-
|
|
25
|
-
Second-order attacks can qualify: an external attacker plants data that a trusted
|
|
26
|
-
user or system later processes, causing consequential unauthorized access or
|
|
27
|
-
privileged actions.
|
|
28
|
-
|
|
29
|
-
## High
|
|
30
|
-
|
|
31
|
-
Assign High when a realistic, evidenced path gives a lower-trust attacker a
|
|
32
|
-
substantial unauthorized capability they did not already possess. Internal
|
|
33
|
-
users, partners, invited collaborators, and admitted untrusted workloads can
|
|
34
|
-
qualify; unauthenticated internet access is not required. Consequences include
|
|
35
|
-
sensitive customer or business data or reusable credentials, account takeover,
|
|
36
|
-
meaningful cross-tenant access or actions as another user, control of production
|
|
37
|
-
workloads or deployments, privileged identities, encryption keys or important
|
|
38
|
-
isolation boundaries, or significant repeatable disruption of a critical or
|
|
39
|
-
shared service. A dangerous function, production label, internal access, or the
|
|
40
|
-
existence of a privileged credential alone is insufficient: identify the
|
|
41
|
-
lower-trust actor, boundary crossing, and consequential new capability.
|
|
42
|
-
|
|
43
|
-
## Medium
|
|
44
|
-
|
|
45
|
-
Assign Medium to a credible vulnerability with concretely bounded impact, such
|
|
46
|
-
as nonsecret operational information, narrow unauthorized changes, contained
|
|
47
|
-
disruption of a noncritical service, or isolated development or staging systems
|
|
48
|
-
without a consequential pivot. A fully demonstrated vulnerability can still be
|
|
49
|
-
Medium. Base a downgrade on verified constraints, not on an assumption that
|
|
50
|
-
missing evidence rules out broader harm.
|
|
51
|
-
|
|
52
|
-
## Low
|
|
53
|
-
|
|
54
|
-
Assign Low to a supported security weakness with minor additional unauthorized
|
|
55
|
-
harm and verified limits on its scope, sensitivity, or duration, such as a small
|
|
56
|
-
information exposure with little security value or a narrowly contained nuisance.
|
|
57
|
-
Do not use Low as a substitute for uncertainty about a potentially serious path.
|
|
58
|
-
|
|
59
|
-
## Informational
|
|
60
|
-
|
|
61
|
-
Assign Informational to a hardening opportunity or observation for which the
|
|
62
|
-
supplied evidence establishes no additional unauthorized capability or security
|
|
63
|
-
impact. Explain why it is informational rather than treating missing proof of
|
|
64
|
-
exploitation as proof of safety. Administrative records that do not describe a
|
|
65
|
-
security finding may be excluded; exclusion is distinct from severity.
|
|
66
|
-
`;
|
|
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: 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 a realistic, evidenced path gives a lower-trust attacker a substantial unauthorized capability they did not already possess. Internal users, partners, invited collaborators, and admitted untrusted workloads can qualify; unauthenticated internet access is not required. Consequences include 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, or significant repeatable disruption of a critical or shared service. A dangerous function, production label, internal access, or the existence of a privileged credential alone is insufficient: identify the lower-trust actor, boundary crossing, and consequential new capability.\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";
|
|
67
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,
|
|
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,2wGAA2wG,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- 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 a realistic, evidenced path gives a lower-trust attacker a substantial unauthorized capability they did not already possess. Internal users, partners, invited collaborators, and admitted untrusted workloads can qualify; unauthenticated internet access is not required. Consequences include 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, or significant repeatable disruption of a critical or shared service. A dangerous function, production label, internal access, or the existence of a privileged credential alone is insufficient: identify the lower-trust actor, boundary crossing, and consequential new capability.\\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endor-findings.d.ts","sourceRoot":"","sources":["../src/endor-findings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAgC/D,kFAAkF;AAClF,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,EACd,MAAM,GAAE,oBAA8B,GACrC,gBAAgB,CA8IlB;AAED,yFAAyF;AACzF,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,EACd,MAAM,GAAE,oBAA8B,GACrC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"endor-findings.d.ts","sourceRoot":"","sources":["../src/endor-findings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAgC/D,kFAAkF;AAClF,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,EACd,MAAM,GAAE,oBAA8B,GACrC,gBAAgB,CA8IlB;AAED,yFAAyF;AACzF,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,EACd,MAAM,GAAE,oBAA8B,GACrC,gBAAgB,CAsHlB;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,oBAA8B,GACrC,OAAO,CAAC,gBAAgB,CAAC,CAE3B"}
|
package/dist/endor-findings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { validateExternalEvidence } from "./external-import-contract.js";
|
|
2
2
|
import { isRecord } from "./record.js";
|
|
3
|
-
import { array, hasSarifExternalPropertyReferences,
|
|
3
|
+
import { array, hasSarifExternalPropertyReferences, normalizeRecords, readScannerJson, record, relativePath, requiredText, sarifRunResults, strings, text, validateSarifRuleReference, } from "./scanner-import.js";
|
|
4
4
|
/** @internal Repository claims retained in the adapter's original SARIF context. */
|
|
5
5
|
export function endorRepositoryUrls(sourceData) {
|
|
6
6
|
if (!isRecord(sourceData))
|
|
@@ -121,43 +121,18 @@ export function normalizeEndorSarif(input, target = "cloud") {
|
|
|
121
121
|
throw new Error("Expected the endorctl SARIF producer.");
|
|
122
122
|
if (hasSarifExternalPropertyReferences(run["externalPropertyFileReferences"]))
|
|
123
123
|
throw new Error("Use a self-contained Endor SARIF report.");
|
|
124
|
-
|
|
125
|
-
const rulesById = indexSarifRules(rules);
|
|
126
|
-
const { runs: _runs, ...documentContext } = document;
|
|
127
|
-
const { results: _results, tool: _tool, ...runContext } = run;
|
|
128
|
-
const { rules: _rules, ...driverContext } = driver;
|
|
129
|
-
const { driver: _driver, ...toolContext } = tool;
|
|
130
|
-
return array(run["results"] ?? [], "Endor results").map((result) => ({
|
|
131
|
-
result,
|
|
132
|
-
rulesById,
|
|
133
|
-
documentContext,
|
|
134
|
-
runContext,
|
|
135
|
-
driverContext,
|
|
136
|
-
toolContext,
|
|
137
|
-
}));
|
|
124
|
+
return sarifRunResults(document, run, tool, driver, "Endor");
|
|
138
125
|
});
|
|
139
|
-
return normalizeRecords(entries, ({ result: value,
|
|
126
|
+
return normalizeRecords(entries, ({ result: value, context }) => {
|
|
140
127
|
const result = record(value, "Endor result");
|
|
141
128
|
const properties = record(result["properties"], "Endor result properties");
|
|
142
129
|
requiredText(properties["project-uuid"], "Endor project-uuid");
|
|
143
130
|
const ruleId = requiredText(result["ruleId"], "Endor ruleId");
|
|
144
|
-
const selectedRule = rulesById.get(ruleId);
|
|
131
|
+
const selectedRule = context.rulesById.get(ruleId);
|
|
145
132
|
if (!selectedRule)
|
|
146
133
|
throw new Error("Endor result must reference exactly one rule in its run.");
|
|
147
|
-
const { rule
|
|
148
|
-
|
|
149
|
-
result["ruleIndex"] !== ruleIndex)
|
|
150
|
-
throw new Error("Endor ruleIndex and ruleId disagree.");
|
|
151
|
-
if (result["rule"] !== undefined) {
|
|
152
|
-
const reference = record(result["rule"], "Endor rule reference");
|
|
153
|
-
if (reference["toolComponent"] !== undefined ||
|
|
154
|
-
(reference["id"] !== undefined && reference["id"] !== ruleId) ||
|
|
155
|
-
(reference["index"] !== undefined &&
|
|
156
|
-
reference["index"] !== ruleIndex) ||
|
|
157
|
-
(reference["guid"] !== undefined &&
|
|
158
|
-
reference["guid"] !== rule["guid"]))
|
|
159
|
-
throw new Error("Inconsistent or external Endor rule reference.");
|
|
160
|
-
}
|
|
134
|
+
const { rule } = selectedRule;
|
|
135
|
+
validateSarifRuleReference(result, ruleId, selectedRule, "Endor");
|
|
161
136
|
const message = record(result["message"], "Endor message");
|
|
162
137
|
const short = record(rule["shortDescription"] ?? {}, "Endor shortDescription");
|
|
163
138
|
const full = record(rule["fullDescription"] ?? {}, "Endor fullDescription");
|
|
@@ -208,12 +183,7 @@ export function normalizeEndorSarif(input, target = "cloud") {
|
|
|
208
183
|
locations: [
|
|
209
184
|
...new Map(locations.map((location) => [JSON.stringify(location), location])).values(),
|
|
210
185
|
],
|
|
211
|
-
source_data:
|
|
212
|
-
...context,
|
|
213
|
-
runContext: sarifRunContextForResult(context.runContext, result, rule, context.documentContext, context.driverContext, context.toolContext),
|
|
214
|
-
rule,
|
|
215
|
-
result,
|
|
216
|
-
}),
|
|
186
|
+
source_data: context.sourceData(result, rule),
|
|
217
187
|
}, target);
|
|
218
188
|
}, ({ result }) => requiredText(record(record(result, "Endor result")["properties"], "Endor result properties")["finding-uuid"], "Endor finding-uuid"), target);
|
|
219
189
|
}
|