@openai/codex-security 0.9.1 → 0.10.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 +37 -788
- package/_bundled_plugin/.codex-plugin/plugin.json +2 -0
- package/_bundled_plugin/.mcp.json +3 -0
- package/_bundled_plugin/mcp/helpers.mjs.br +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/server.mjs.br +0 -0
- package/_bundled_plugin/references/access-advisory.md +1 -1
- package/_bundled_plugin/references/artifact-storage.md +1 -1
- package/_bundled_plugin/references/baseline-auditor.md +18 -0
- package/_bundled_plugin/references/core-scan.md +5 -42
- package/_bundled_plugin/references/final-report.md +1 -1
- package/_bundled_plugin/references/focused-investigator.md +13 -0
- package/_bundled_plugin/references/scan-prologue.md +2 -2
- package/_bundled_plugin/references/scan-runtime.md +4 -2
- package/_bundled_plugin/references/security-guidance.md +14 -1
- package/_bundled_plugin/references/threat-model.md +1 -0
- package/_bundled_plugin/references/validate-scan-findings.md +3 -0
- package/_bundled_plugin/scripts/deep_scan_workbench.py +30 -12
- package/_bundled_plugin/scripts/dispatch_inventory_tool +7 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +47 -9
- package/_bundled_plugin/scripts/launch_codex_security_mcp +54 -16
- package/_bundled_plugin/scripts/launch_codex_security_mcp.cmd +2 -0
- package/_bundled_plugin/scripts/posix_scan_local_files.py +26 -1
- package/_bundled_plugin/scripts/snapshot_sqlite.py +8 -2
- package/_bundled_plugin/scripts/windows_scan_local_files.py +216 -25
- package/_bundled_plugin/scripts/workbench/handoff.py +55 -25
- package/_bundled_plugin/scripts/workbench/storage.py +25 -5
- package/_bundled_plugin/scripts/workbench_cli.py +24 -2
- package/_bundled_plugin/scripts/workbench_constants.py +2 -0
- package/_bundled_plugin/scripts/workbench_db.py +257 -268
- package/_bundled_plugin/scripts/workbench_feedback.py +49 -4
- package/_bundled_plugin/scripts/workbench_native_indexes.py +226 -29
- package/_bundled_plugin/scripts/workbench_progress.py +159 -3
- package/_bundled_plugin/scripts/workbench_publication.py +2 -3
- package/_bundled_plugin/scripts/workbench_remediation.py +142 -2
- package/_bundled_plugin/scripts/workbench_saved_results.py +48 -8
- package/_bundled_plugin/scripts/workbench_scan_history.py +291 -134
- package/_bundled_plugin/scripts/workbench_scan_start.py +208 -11
- package/_bundled_plugin/scripts/workbench_scan_usage.py +36 -10
- package/_bundled_plugin/scripts/workbench_schema.py +220 -14
- package/_bundled_plugin/scripts/workbench_setup.py +1 -1
- package/_bundled_plugin/scripts/workbench_source_scopes.py +8 -0
- package/_bundled_plugin/scripts/workbench_target.py +486 -85
- package/_bundled_plugin/scripts/workbench_target_state.py +1108 -22
- package/_bundled_plugin/shared/workbench-history-repairs.json +64 -14
- package/_bundled_plugin/shared/workbench-migrations.json +66 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +4 -2
- package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +2 -2
- package/_bundled_plugin/skills/fix-finding/SKILL.md +1 -0
- package/_bundled_plugin/skills/publish-findings/SKILL.md +26 -160
- package/_bundled_plugin/skills/publish-findings/agents/openai.yaml +2 -2
- package/_bundled_plugin/skills/publish-findings/references/checkmarx-import.md +2 -2
- package/_bundled_plugin/skills/publish-findings/scripts/collect_checkmarx.py +3 -58
- package/_bundled_plugin/skills/publish-findings/scripts/collector_paths.py +63 -0
- package/_bundled_plugin/skills/security-scan/SKILL.md +9 -46
- package/_bundled_plugin/skills/security-scan/agents/openai.yaml +2 -2
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +3 -21
- package/_bundled_plugin/skills/security-scan/references/managed-scan.md +11 -0
- package/_bundled_plugin/skills/security-scan/references/scan-results.md +15 -0
- package/_bundled_plugin/skills/security-scan/references/scoped-paths.md +23 -0
- package/_bundled_plugin/skills/security-scan/references/sdk-files.md +24 -0
- package/bin/codex-security.mjs +2 -2
- package/dist/api.d.ts +7 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +459 -157
- package/dist/api.js.map +1 -1
- package/dist/armorcode-findings.d.ts +9 -0
- package/dist/armorcode-findings.d.ts.map +1 -0
- package/dist/armorcode-findings.js +145 -0
- package/dist/armorcode-findings.js.map +1 -0
- package/dist/artifact-export.d.ts +2 -0
- package/dist/artifact-export.d.ts.map +1 -1
- package/dist/artifact-export.js +29 -13
- package/dist/artifact-export.js.map +1 -1
- package/dist/auth.d.ts +6 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +33 -12
- package/dist/auth.js.map +1 -1
- package/dist/batch-cost.d.ts +18 -0
- package/dist/batch-cost.d.ts.map +1 -0
- package/dist/batch-cost.js +41 -0
- package/dist/batch-cost.js.map +1 -0
- package/dist/blackduck-findings.d.ts +1 -1
- package/dist/blackduck-findings.d.ts.map +1 -1
- package/dist/blackduck-findings.js +5 -18
- package/dist/blackduck-findings.js.map +1 -1
- package/dist/bundled-plugin.d.ts +4 -0
- package/dist/bundled-plugin.d.ts.map +1 -0
- package/dist/bundled-plugin.js +23 -0
- package/dist/bundled-plugin.js.map +1 -0
- package/dist/classify-scan-severity.d.ts +1 -1
- package/dist/classify-scan-severity.d.ts.map +1 -1
- package/dist/classify-scan-severity.js +11 -3
- package/dist/classify-scan-severity.js.map +1 -1
- package/dist/classify-severity-diagnostics.d.ts +10 -0
- package/dist/classify-severity-diagnostics.d.ts.map +1 -0
- package/dist/classify-severity-diagnostics.js +57 -0
- package/dist/classify-severity-diagnostics.js.map +1 -0
- package/dist/classify-severity-records.d.ts +4 -0
- package/dist/classify-severity-records.d.ts.map +1 -1
- package/dist/classify-severity-records.js +35 -8
- package/dist/classify-severity-records.js.map +1 -1
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +9 -6
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-argument.d.ts +4 -0
- package/dist/cli-argument.d.ts.map +1 -0
- package/dist/cli-argument.js +17 -0
- package/dist/cli-argument.js.map +1 -0
- package/dist/cli-help.d.ts +1 -1
- package/dist/cli-help.d.ts.map +1 -1
- package/dist/cli-help.js +71 -29
- package/dist/cli-help.js.map +1 -1
- package/dist/cli-hook.d.ts +3 -0
- package/dist/cli-hook.d.ts.map +1 -0
- package/dist/cli-hook.js +87 -0
- package/dist/cli-hook.js.map +1 -0
- package/dist/cli-integrations.d.ts +13 -0
- package/dist/cli-integrations.d.ts.map +1 -0
- package/dist/cli-integrations.js +333 -0
- package/dist/cli-integrations.js.map +1 -0
- package/dist/cli-mcp.d.ts +15 -0
- package/dist/cli-mcp.d.ts.map +1 -0
- package/dist/cli-mcp.js +178 -0
- package/dist/cli-mcp.js.map +1 -0
- package/dist/cli-token-view.d.ts +10 -0
- package/dist/cli-token-view.d.ts.map +1 -0
- package/dist/cli-token-view.js +41 -0
- package/dist/cli-token-view.js.map +1 -0
- package/dist/cli.d.ts +8 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1860 -903
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +33 -31
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codex-sdk-environment.d.ts +6 -0
- package/dist/codex-sdk-environment.d.ts.map +1 -1
- package/dist/codex-sdk-environment.js +19 -0
- package/dist/codex-sdk-environment.js.map +1 -1
- package/dist/command-words.d.ts +3 -0
- package/dist/command-words.d.ts.map +1 -0
- package/dist/command-words.js +46 -0
- package/dist/command-words.js.map +1 -0
- package/dist/component-plan.d.ts.map +1 -1
- package/dist/component-plan.js +3 -3
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.d.ts +3 -1
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +40 -7
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +30 -1
- package/dist/config.js.map +1 -1
- package/dist/continuum-aws.d.ts +6 -0
- package/dist/continuum-aws.d.ts.map +1 -0
- package/dist/continuum-aws.js +202 -0
- package/dist/continuum-aws.js.map +1 -0
- package/dist/continuum-collector.d.ts +44 -0
- package/dist/continuum-collector.d.ts.map +1 -0
- package/dist/continuum-collector.js +266 -0
- package/dist/continuum-collector.js.map +1 -0
- package/dist/continuum-findings.d.ts +31 -2
- package/dist/continuum-findings.d.ts.map +1 -1
- package/dist/continuum-findings.js +497 -59
- package/dist/continuum-findings.js.map +1 -1
- package/dist/contract.d.ts +1 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +3 -0
- package/dist/contract.js.map +1 -1
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +1 -45
- package/dist/cost.js.map +1 -1
- package/dist/crowdstrike-findings.d.ts +7 -0
- package/dist/crowdstrike-findings.d.ts.map +1 -0
- package/dist/crowdstrike-findings.js +210 -0
- package/dist/crowdstrike-findings.js.map +1 -0
- package/dist/custom-validation-prompt.d.ts +1 -1
- package/dist/custom-validation-prompt.d.ts.map +1 -1
- package/dist/custom-validation-prompt.js +29 -19
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/deduplication/local.d.ts +3 -1
- package/dist/deduplication/local.d.ts.map +1 -1
- package/dist/deduplication/local.js +8 -1
- package/dist/deduplication/local.js.map +1 -1
- package/dist/deduplication/refusal.d.ts.map +1 -1
- package/dist/deduplication/refusal.js +2 -1
- package/dist/deduplication/refusal.js.map +1 -1
- package/dist/deduplication/scan.d.ts +2 -0
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +24 -7
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-scan.d.ts.map +1 -1
- package/dist/deep-scan.js +16 -15
- package/dist/deep-scan.js.map +1 -1
- package/dist/endor-findings.d.ts +2 -2
- package/dist/endor-findings.d.ts.map +1 -1
- package/dist/endor-findings.js +6 -23
- package/dist/endor-findings.js.map +1 -1
- package/dist/errors.d.ts +3 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +7 -3
- package/dist/errors.js.map +1 -1
- package/dist/executable-path.d.ts +3 -0
- package/dist/executable-path.d.ts.map +1 -1
- package/dist/executable-path.js +26 -0
- package/dist/executable-path.js.map +1 -1
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +12 -1
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts +66 -4
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +258 -59
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +6 -1
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +330 -1633
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +11 -2
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +56 -53
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-findings.d.ts +1 -1
- package/dist/external-findings.d.ts.map +1 -1
- package/dist/external-findings.js +12 -1
- package/dist/external-findings.js.map +1 -1
- package/dist/external-import-contract.d.ts +6 -11
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +35 -177
- 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-prompt.d.ts.map +1 -1
- package/dist/finding-prompt.js +2 -2
- package/dist/finding-prompt.js.map +1 -1
- package/dist/github-dependabot-findings.d.ts.map +1 -1
- package/dist/github-dependabot-findings.js +3 -4
- package/dist/github-dependabot-findings.js.map +1 -1
- package/dist/github-findings.d.ts.map +1 -1
- package/dist/github-findings.js +19 -287
- package/dist/github-findings.js.map +1 -1
- package/dist/host-protocol.d.ts +6 -0
- package/dist/host-protocol.d.ts.map +1 -1
- package/dist/host-protocol.js +11 -1
- package/dist/host-protocol.js.map +1 -1
- package/dist/host-records-protocol.d.ts +2 -0
- package/dist/host-records-protocol.d.ts.map +1 -1
- package/dist/host-records-protocol.js +4 -0
- package/dist/host-records-protocol.js.map +1 -1
- package/dist/hosted-remediation.d.ts +1 -0
- package/dist/hosted-remediation.d.ts.map +1 -1
- package/dist/hosted-remediation.js +23 -3
- package/dist/hosted-remediation.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/inspector-findings.d.ts.map +1 -1
- package/dist/inspector-findings.js +19 -35
- package/dist/inspector-findings.js.map +1 -1
- package/dist/knowledge-base.d.ts +1 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +34 -27
- package/dist/knowledge-base.js.map +1 -1
- package/dist/linear.d.ts +11 -0
- package/dist/linear.d.ts.map +1 -1
- package/dist/linear.js.map +1 -1
- package/dist/local-git-metadata.d.ts +5 -2
- package/dist/local-git-metadata.d.ts.map +1 -1
- package/dist/local-git-metadata.js +8 -4
- package/dist/local-git-metadata.js.map +1 -1
- package/dist/multiscan.d.ts +4 -0
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +83 -39
- package/dist/multiscan.js.map +1 -1
- package/dist/opengrep-findings.d.ts +4 -2
- package/dist/opengrep-findings.d.ts.map +1 -1
- package/dist/opengrep-findings.js +39 -22
- package/dist/opengrep-findings.js.map +1 -1
- package/dist/private-finding-import.d.ts +8 -13
- package/dist/private-finding-import.d.ts.map +1 -1
- package/dist/private-finding-import.js +69 -129
- package/dist/private-finding-import.js.map +1 -1
- package/dist/project-config-schema.d.ts +2 -0
- package/dist/project-config-schema.d.ts.map +1 -1
- package/dist/project-config-schema.js +1 -0
- package/dist/project-config-schema.js.map +1 -1
- package/dist/project-config.d.ts +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +56 -13
- package/dist/project-config.js.map +1 -1
- package/dist/prompt-files.d.ts +7 -2
- package/dist/prompt-files.d.ts.map +1 -1
- package/dist/prompt-files.js +42 -20
- package/dist/prompt-files.js.map +1 -1
- package/dist/provider-profile.d.ts.map +1 -1
- package/dist/provider-profile.js +4 -9
- package/dist/provider-profile.js.map +1 -1
- package/dist/publication.d.ts +1 -1
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js.map +1 -1
- package/dist/record.d.ts +1 -5
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +3 -51
- package/dist/record.js.map +1 -1
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +3 -1
- package/dist/remediation.js.map +1 -1
- package/dist/runtime.d.ts +35 -7
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +782 -153
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan-bootstrap.d.ts +6 -1
- package/dist/saved-scan-bootstrap.d.ts.map +1 -1
- package/dist/saved-scan-bootstrap.js +267 -115
- package/dist/saved-scan-bootstrap.js.map +1 -1
- package/dist/scan-archive-path.d.ts +2 -0
- package/dist/scan-archive-path.d.ts.map +1 -0
- package/dist/scan-archive-path.js +5 -0
- package/dist/scan-archive-path.js.map +1 -0
- package/dist/scan-comparison.d.ts +20 -2
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +26 -5
- 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 +18 -2
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-executor.d.ts.map +1 -1
- package/dist/scan-executor.js +4 -2
- package/dist/scan-executor.js.map +1 -1
- package/dist/scan-history-renderer.d.ts +1 -0
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +25 -9
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +28 -4
- package/dist/scan-logs.js.map +1 -1
- package/dist/scan-settings.d.ts +1 -0
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +1 -0
- package/dist/scan-settings.js.map +1 -1
- package/dist/scanner-import.d.ts +5 -11
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +16 -89
- package/dist/scanner-import.js.map +1 -1
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js +26 -6
- package/dist/security-policy.js.map +1 -1
- package/dist/semgrep-findings.d.ts.map +1 -1
- package/dist/semgrep-findings.js +14 -48
- package/dist/semgrep-findings.js.map +1 -1
- package/dist/semgrep-platform-findings.d.ts +20 -70
- package/dist/semgrep-platform-findings.d.ts.map +1 -1
- package/dist/semgrep-platform-findings.js +116 -333
- package/dist/semgrep-platform-findings.js.map +1 -1
- package/dist/severity-review.d.ts.map +1 -1
- package/dist/severity-review.js +1 -0
- package/dist/severity-review.js.map +1 -1
- package/dist/snyk-findings.d.ts +2 -0
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +5 -8
- package/dist/snyk-findings.js.map +1 -1
- package/dist/snyk-rest-findings.d.ts +3 -20
- package/dist/snyk-rest-findings.d.ts.map +1 -1
- package/dist/snyk-rest-findings.js +45 -217
- package/dist/snyk-rest-findings.js.map +1 -1
- package/dist/sonar-findings.d.ts +1 -1
- package/dist/sonar-findings.d.ts.map +1 -1
- package/dist/sonar-findings.js +2 -4
- package/dist/sonar-findings.js.map +1 -1
- package/dist/sonar-import.d.ts +3 -0
- package/dist/sonar-import.d.ts.map +1 -1
- package/dist/sonar-import.js +28 -30
- package/dist/sonar-import.js.map +1 -1
- package/dist/stored-finding-projection.d.ts +6 -0
- package/dist/stored-finding-projection.d.ts.map +1 -0
- package/dist/stored-finding-projection.js +129 -0
- package/dist/stored-finding-projection.js.map +1 -0
- package/dist/stored-findings-publication.d.ts +23 -0
- package/dist/stored-findings-publication.d.ts.map +1 -0
- package/dist/stored-findings-publication.js +169 -0
- package/dist/stored-findings-publication.js.map +1 -0
- package/dist/targets.d.ts +8 -1
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +103 -23
- package/dist/targets.js.map +1 -1
- package/dist/tenable-findings.d.ts +1 -4
- package/dist/tenable-findings.d.ts.map +1 -1
- package/dist/tenable-findings.js.map +1 -1
- package/dist/trivy-findings.d.ts.map +1 -1
- package/dist/trivy-findings.js +0 -11
- package/dist/trivy-findings.js.map +1 -1
- package/dist/trusted-executable.d.ts +7 -0
- package/dist/trusted-executable.d.ts.map +1 -1
- package/dist/trusted-executable.js +148 -37
- package/dist/trusted-executable.js.map +1 -1
- package/dist/value.js +3 -1
- package/dist/value.js.map +1 -1
- package/dist/veracode-findings.d.ts +1 -3
- package/dist/veracode-findings.d.ts.map +1 -1
- package/dist/veracode-findings.js +13 -38
- package/dist/veracode-findings.js.map +1 -1
- package/dist/version.d.ts +3 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +184 -32
- package/dist/version.js.map +1 -1
- package/dist/wiz-findings.d.ts +2 -2
- package/dist/wiz-findings.d.ts.map +1 -1
- package/dist/wiz-findings.js +14 -92
- package/dist/wiz-findings.js.map +1 -1
- package/docs/classify-severity-records.md +30 -0
- package/docs/cli.md +537 -124
- package/docs/findings-service.md +22 -9
- package/docs/hosted-remediation.md +13 -4
- package/docs/sdk.md +918 -0
- package/package.json +15 -6
- package/schemas/external-findings.schema.json +2 -1
- package/schemas/project-config.schema.json +5 -0
- package/dist/hosted-scanner-v1.d.ts +0 -6
- package/dist/hosted-scanner-v1.d.ts.map +0 -1
- package/dist/hosted-scanner-v1.js +0 -60
- package/dist/hosted-scanner-v1.js.map +0 -1
- package/dist/reader-selection.d.ts +0 -15
- package/dist/reader-selection.d.ts.map +0 -1
- package/dist/reader-selection.js +0 -89
- package/dist/reader-selection.js.map +0 -1
- package/dist/semgrep-platform-v1.d.ts +0 -6
- package/dist/semgrep-platform-v1.d.ts.map +0 -1
- package/dist/semgrep-platform-v1.js +0 -83
- package/dist/semgrep-platform-v1.js.map +0 -1
- package/dist/snyk-rest-v1.d.ts +0 -28
- package/dist/snyk-rest-v1.d.ts.map +0 -1
- package/dist/snyk-rest-v1.js +0 -132
- package/dist/snyk-rest-v1.js.map +0 -1
|
@@ -32,6 +32,7 @@ export const ProjectConfigInputSchema = z.strictObject({
|
|
|
32
32
|
cyber_access_program: ScanSettingsSchema.shape.cyberAccessProgram,
|
|
33
33
|
owner_suggestions: ScanSettingsSchema.shape.ownerSuggestions,
|
|
34
34
|
scope: ProjectScopeSchema.optional().describe("One scope variant. Omit for the whole repository. Mode compatibility is checked after overrides."),
|
|
35
|
+
exclude_paths: ScanSettingsSchema.shape.excludePaths.describe("Literal files or directories relative to the selected repository. Exclusions take precedence over inclusions."),
|
|
35
36
|
knowledge_base: ScanSettingsSchema.shape.knowledgeBasePaths.describe("Context files or directories, relative to this file. An empty list selects no additional context."),
|
|
36
37
|
instructions_file: ScanSettingsSchema.shape.scanPromptFile.describe("Additional scan instructions, relative to this file."),
|
|
37
38
|
validation_file: ScanSettingsSchema.shape.validationPromptFile.describe("Custom validation instructions, relative to this file; not supported in active deep scans."),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-config-schema.js","sourceRoot":"","sources":["../src/project-config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAA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,CACzD,mFAAmF,CACpF;KACF,CAAC;SACD,QAAQ,EAAE;IACb,MAAM,EAAE,CAAC;SACN,YAAY,CAAC;QACZ,SAAS,EAAE,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CACpD,yFAAyF,CAC1F;KACF,CAAC;SACD,QAAQ,EAAE;CACd,CAAC,CAAC;AAKH,MAAM,UAAU,uBAAuB;IACrC,OAAO;QACL,GAAG,CAAC,CAAC,YAAY,CAAC,wBAAwB,EAAE;YAC1C,MAAM,EAAE,UAAU;YAClB,EAAE,EAAE,OAAO;YACX,eAAe,EAAE,OAAO;SACzB,CAAC;QACF,KAAK,EAAE,sCAAsC;QAC7C,WAAW,EACT,+KAA+K;QACjL,QAAQ,EACN,oHAAoH;KACvH,CAAC;AACJ,CAAC","sourcesContent":["import { z } from \"zod\";\nimport {\n DeepScanSettingsSchema,\n FailureSeveritySchema,\n ScanSettingsSchema,\n} from \"./scan-settings.js\";\n\nconst nonempty = z.string().min(1);\n\nexport const ProjectScopeSchema = z.union([\n z.strictObject({\n paths: z\n .array(nonempty)\n .min(1)\n .describe(\"Literal paths relative to the selected repository.\"),\n }),\n z.strictObject({\n diff: z.strictObject({\n base: nonempty,\n head: nonempty.optional().meta({ default: \"HEAD\" }),\n }),\n }),\n z.strictObject({\n working_tree: z.strictObject({\n base: nonempty.optional().meta({ default: \"HEAD\" }),\n }),\n }),\n]);\n\nexport const ProjectConfigInputSchema = z.strictObject({\n $schema: nonempty\n .optional()\n .describe(\n \"Editor schema URI or relative path. The CLI does not fetch or select a validator from this value.\",\n ),\n auth: ScanSettingsSchema.shape.auth.describe(\n \"Credential-source choice only; never a credential value.\",\n ),\n scan: z\n .strictObject({\n mode: ScanSettingsSchema.shape.mode,\n max_time_minutes: ScanSettingsSchema.shape.maxTimeMinutes,\n cyber_access_program: ScanSettingsSchema.shape.cyberAccessProgram,\n owner_suggestions: ScanSettingsSchema.shape.ownerSuggestions,\n scope: ProjectScopeSchema.optional().describe(\n \"One scope variant. Omit for the whole repository. Mode compatibility is checked after overrides.\",\n ),\n knowledge_base: ScanSettingsSchema.shape.knowledgeBasePaths.describe(\n \"Context files or directories, relative to this file. An empty list selects no additional context.\",\n ),\n instructions_file: ScanSettingsSchema.shape.scanPromptFile.describe(\n \"Additional scan instructions, relative to this file.\",\n ),\n validation_file: ScanSettingsSchema.shape.validationPromptFile.describe(\n \"Custom validation instructions, relative to this file; not supported in active deep scans.\",\n ),\n deep: z\n .strictObject({\n workers: DeepScanSettingsSchema.shape.workers,\n subagents_per_worker: DeepScanSettingsSchema.shape.subagents,\n stop_after_no_new: DeepScanSettingsSchema.shape.stopAfterNoNew,\n stop_after_consecutive_errors:\n DeepScanSettingsSchema.shape.stopAfterConsecutiveErrors,\n max_discovery_runs: DeepScanSettingsSchema.shape.maxDiscoveryRuns,\n max_time_hours: DeepScanSettingsSchema.shape.maxTimeHours,\n })\n .optional()\n .describe(\n \"Deep defaults; a valid block may be retained while standard mode is selected.\",\n ),\n })\n .optional(),\n codex: z\n .object({\n model: nonempty.optional(),\n model_reasoning_effort: nonempty.optional(),\n model_provider: nonempty.optional(),\n })\n .catchall(z.json())\n .optional()\n .describe(\n \"Native Codex overrides. Common key types are checked here; existing native and wrapper restrictions still apply.\",\n ),\n limits: z\n .strictObject({\n max_cost_usd_per_scan: ScanSettingsSchema.shape.maxCostUsd.describe(\n \"Estimated USD limit per launched scan attempt, not a total batch budget. Omit for no limit.\",\n ),\n })\n .optional(),\n policy: z\n .strictObject({\n fail_on_severity: FailureSeveritySchema.optional().describe(\n \"Exit threshold; does not filter retained findings. Omit for report-only behavior.\",\n ),\n })\n .optional(),\n output: z\n .strictObject({\n directory: ScanSettingsSchema.shape.outputDir.describe(\n \"Artifact directory relative to this file; existing outside-worktree checks still apply.\",\n ),\n })\n .optional(),\n});\n\nexport type ProjectConfigInput = z.infer<typeof ProjectConfigInputSchema>;\nexport type ProjectScope = z.infer<typeof ProjectScopeSchema>;\n\nexport function projectConfigJsonSchema() {\n return {\n ...z.toJSONSchema(ProjectConfigInputSchema, {\n target: \"draft-07\",\n io: \"input\",\n unrepresentable: \"throw\",\n }),\n title: \"Codex Security project configuration\",\n description:\n \"Input schema for explicitly selected YAML or JSON project files. Filesystem, active scan combinations, native configuration, and runtime availability are checked separately.\",\n $comment:\n \"Generated from ProjectConfigInputSchema. Defaults are annotations; apply defaults only after merging input layers.\",\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"project-config-schema.js","sourceRoot":"","sources":["../src/project-config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAEnC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC;IACxC,CAAC,CAAC,YAAY,CAAC;QACb,KAAK,EAAE,CAAC;aACL,KAAK,CAAC,QAAQ,CAAC;aACf,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,CAAC,oDAAoD,CAAC;KAClE,CAAC;IACF,CAAC,CAAC,YAAY,CAAC;QACb,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC;YACnB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;SACpD,CAAC;KACH,CAAC;IACF,CAAC,CAAC,YAAY,CAAC;QACb,YAAY,EAAE,CAAC,CAAC,YAAY,CAAC;YAC3B,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;SACpD,CAAC;KACH,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,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\nconst nonempty = z.string().min(1);\n\nexport const ProjectScopeSchema = z.union([\n z.strictObject({\n paths: z\n .array(nonempty)\n .min(1)\n .describe(\"Literal paths relative to the selected repository.\"),\n }),\n z.strictObject({\n diff: z.strictObject({\n base: nonempty,\n head: nonempty.optional().meta({ default: \"HEAD\" }),\n }),\n }),\n z.strictObject({\n working_tree: z.strictObject({\n base: nonempty.optional().meta({ default: \"HEAD\" }),\n }),\n }),\n]);\n\nexport const ProjectConfigInputSchema = z.strictObject({\n $schema: nonempty\n .optional()\n .describe(\n \"Editor schema URI or relative path. The CLI does not fetch or select a validator from this value.\",\n ),\n auth: ScanSettingsSchema.shape.auth.describe(\n \"Credential-source choice only; never a credential value.\",\n ),\n scan: z\n .strictObject({\n mode: ScanSettingsSchema.shape.mode,\n max_time_minutes: ScanSettingsSchema.shape.maxTimeMinutes,\n cyber_access_program: ScanSettingsSchema.shape.cyberAccessProgram,\n owner_suggestions: ScanSettingsSchema.shape.ownerSuggestions,\n scope: ProjectScopeSchema.optional().describe(\n \"One scope variant. Omit for the whole repository. Mode compatibility is checked after overrides.\",\n ),\n exclude_paths: ScanSettingsSchema.shape.excludePaths.describe(\n \"Literal files or directories relative to the selected repository. Exclusions take precedence over inclusions.\",\n ),\n knowledge_base: ScanSettingsSchema.shape.knowledgeBasePaths.describe(\n \"Context files or directories, relative to this file. An empty list selects no additional context.\",\n ),\n instructions_file: ScanSettingsSchema.shape.scanPromptFile.describe(\n \"Additional scan instructions, relative to this file.\",\n ),\n validation_file: ScanSettingsSchema.shape.validationPromptFile.describe(\n \"Custom validation instructions, relative to this file; not supported in active deep scans.\",\n ),\n deep: z\n .strictObject({\n workers: DeepScanSettingsSchema.shape.workers,\n subagents_per_worker: DeepScanSettingsSchema.shape.subagents,\n stop_after_no_new: DeepScanSettingsSchema.shape.stopAfterNoNew,\n stop_after_consecutive_errors:\n DeepScanSettingsSchema.shape.stopAfterConsecutiveErrors,\n max_discovery_runs: DeepScanSettingsSchema.shape.maxDiscoveryRuns,\n max_time_hours: DeepScanSettingsSchema.shape.maxTimeHours,\n })\n .optional()\n .describe(\n \"Deep defaults; a valid block may be retained while standard mode is selected.\",\n ),\n })\n .optional(),\n codex: z\n .object({\n model: nonempty.optional(),\n model_reasoning_effort: nonempty.optional(),\n model_provider: nonempty.optional(),\n })\n .catchall(z.json())\n .optional()\n .describe(\n \"Native Codex overrides. Common key types are checked here; existing native and wrapper restrictions still apply.\",\n ),\n limits: z\n .strictObject({\n max_cost_usd_per_scan: ScanSettingsSchema.shape.maxCostUsd.describe(\n \"Estimated USD limit per launched scan attempt, not a total batch budget. Omit for no limit.\",\n ),\n })\n .optional(),\n policy: z\n .strictObject({\n fail_on_severity: FailureSeveritySchema.optional().describe(\n \"Exit threshold; does not filter retained findings. Omit for report-only behavior.\",\n ),\n })\n .optional(),\n output: z\n .strictObject({\n directory: ScanSettingsSchema.shape.outputDir.describe(\n \"Artifact directory relative to this file; existing outside-worktree checks still apply.\",\n ),\n })\n .optional(),\n});\n\nexport type ProjectConfigInput = z.infer<typeof ProjectConfigInputSchema>;\nexport type ProjectScope = z.infer<typeof ProjectScopeSchema>;\n\nexport function projectConfigJsonSchema() {\n return {\n ...z.toJSONSchema(ProjectConfigInputSchema, {\n target: \"draft-07\",\n io: \"input\",\n unrepresentable: \"throw\",\n }),\n title: \"Codex Security project configuration\",\n description:\n \"Input schema for explicitly selected YAML or JSON project files. Filesystem, active scan combinations, native configuration, and runtime availability are checked separately.\",\n $comment:\n \"Generated from ProjectConfigInputSchema. Defaults are annotations; apply defaults only after merging input layers.\",\n };\n}\n"]}
|
package/dist/project-config.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ declare const PROJECT_SETTING_KEYS: {
|
|
|
24
24
|
readonly cyberAccessProgram: "scan.cyber_access_program";
|
|
25
25
|
readonly ownerSuggestions: "scan.owner_suggestions";
|
|
26
26
|
readonly target: "scan.scope";
|
|
27
|
+
readonly excludePaths: "scan.exclude_paths";
|
|
27
28
|
readonly knowledgeBasePaths: "scan.knowledge_base";
|
|
28
29
|
readonly scanPromptFile: "scan.instructions_file";
|
|
29
30
|
readonly validationPromptFile: "scan.validation_file";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-config.d.ts","sourceRoot":"","sources":["../src/project-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"project-config.d.ts","sourceRoot":"","sources":["../src/project-config.ts"],"names":[],"mappings":"AAcA,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAGL,kBAAkB,EAGlB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAM3D,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,kBAAkB,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE;QAAE,cAAc,EAAE,UAAU,CAAA;KAAE,CAAC;IACvC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACzC;AAED,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,KAAK,CAAC;AAC3E,QAAA,MAAM,oBAAoB;mBAClB,MAAM;mBACN,WAAW;6BACD,uBAAuB;iCACnB,2BAA2B;+BAC7B,wBAAwB;qBAClC,YAAY;2BACN,oBAAoB;iCACd,qBAAqB;6BACzB,wBAAwB;mCAClB,sBAAsB;wBACjC,kBAAkB;8BACZ,yBAAyB;yBAC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AAE,OAAO,CAAC,YAAY,CAAC,GAAG;IAAE,cAAc,CAAC,EAAE,UAAU,CAAA;CAAE,EAClE,SAAS,EAAE,MAAM,EACjB,YAAY,GAAE,OAAO,CAAC,MAAM,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,CAAM,GAC1E,qBAAqB,CA2KvB;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,GAAG,SAAS,GAC9B,UAAU,GAAG,SAAS,CAKxB"}
|
package/dist/project-config.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { isUtf8 } from "node:buffer";
|
|
2
|
+
import { existsSync, statSync } from "node:fs";
|
|
3
|
+
import { readFile, realpath } from "node:fs/promises";
|
|
4
|
+
import { basename, dirname, extname, isAbsolute, relative, resolve, sep, } from "node:path";
|
|
3
5
|
import { pathToFileURL } from "node:url";
|
|
4
6
|
import Ajv from "ajv";
|
|
5
7
|
import { DEFAULT_CODEX_CONFIG, mergeCodexOverrides, } from "./config.js";
|
|
6
8
|
import { ConfigurationError, errorMessage } from "./errors.js";
|
|
7
9
|
import { DEFAULT_DEEP_SCAN_SETTINGS } from "./deep-scan-defaults.js";
|
|
8
|
-
import { resolveConfigPath } from "./config-path.js";
|
|
9
10
|
import { deepScanOptions } from "./deep-config.js";
|
|
10
11
|
import { projectConfigJsonSchema, } from "./project-config-schema.js";
|
|
11
|
-
import {
|
|
12
|
+
import { expandHomeForLookup, resolveInputPath } from "./runtime.js";
|
|
12
13
|
import { DEFAULT_SCAN_AUTH, DEFAULT_SCAN_MODE, DEEP_SCAN_SETTINGS, pickScanSettings, } from "./scan-settings.js";
|
|
13
14
|
import { DiffTarget } from "./targets.js";
|
|
14
15
|
const validateProjectConfig = new Ajv({
|
|
@@ -21,6 +22,7 @@ const PROJECT_SETTING_KEYS = {
|
|
|
21
22
|
cyberAccessProgram: "scan.cyber_access_program",
|
|
22
23
|
ownerSuggestions: "scan.owner_suggestions",
|
|
23
24
|
target: "scan.scope",
|
|
25
|
+
excludePaths: "scan.exclude_paths",
|
|
24
26
|
knowledgeBasePaths: "scan.knowledge_base",
|
|
25
27
|
scanPromptFile: "scan.instructions_file",
|
|
26
28
|
validationPromptFile: "scan.validation_file",
|
|
@@ -49,10 +51,22 @@ export function resolveProjectConfig(input, directory = process.cwd()) {
|
|
|
49
51
|
return resolveScanSettings({ input, directory: resolve(directory) }, {}, directory);
|
|
50
52
|
}
|
|
51
53
|
export async function readProjectConfig(file, directory = process.cwd()) {
|
|
52
|
-
const
|
|
54
|
+
const selected = expandHomeForLookup(file);
|
|
55
|
+
const requested = isAbsolute(selected)
|
|
56
|
+
? selected
|
|
57
|
+
: `${directory || "."}${sep}${selected}`;
|
|
58
|
+
const traversesParent = sep === "/" && requested.split("/").includes("..");
|
|
59
|
+
let path = traversesParent ? requested : resolve(directory, selected);
|
|
53
60
|
const extension = projectConfigExtension(path);
|
|
54
61
|
let text;
|
|
55
62
|
try {
|
|
63
|
+
// Resolve the parent through the filesystem while retaining the selected filename.
|
|
64
|
+
if (traversesParent) {
|
|
65
|
+
const parent = await realpath(dirname(path), { encoding: "buffer" });
|
|
66
|
+
if (!isUtf8(parent))
|
|
67
|
+
throw new Error("The resolved configuration directory is not a valid UTF-8 path.");
|
|
68
|
+
path = resolve(parent.toString(), basename(path));
|
|
69
|
+
}
|
|
56
70
|
text = await readFile(path, "utf8");
|
|
57
71
|
}
|
|
58
72
|
catch (error) {
|
|
@@ -91,11 +105,14 @@ export function projectConfigStarter(path, directory = process.cwd()) {
|
|
|
91
105
|
const schema = isAbsolute(relativeSchema)
|
|
92
106
|
? pathToFileURL(schemaPath).href
|
|
93
107
|
: `${relativeSchema.startsWith(".") ? "" : "./"}${encodeURI(relativeSchema.split(sep).join("/")).replace(/[#?]/gu, encodeURIComponent)}`;
|
|
108
|
+
const hasSchema = existsSync(schemaPath);
|
|
94
109
|
if (projectConfigExtension(path) === ".json")
|
|
95
|
-
return `${JSON.stringify({ $schema: schema }, null, 2)}\n`;
|
|
110
|
+
return `${JSON.stringify(hasSchema ? { $schema: schema } : {}, null, 2)}\n`;
|
|
96
111
|
return [
|
|
97
112
|
"# This file is trusted like CLI options. Keep it outside untrusted inputs.",
|
|
98
|
-
|
|
113
|
+
...(hasSchema
|
|
114
|
+
? [`$schema: ${schema}`]
|
|
115
|
+
: ["# Replace the empty mapping below when enabling settings.", "{}"]),
|
|
99
116
|
"",
|
|
100
117
|
"# Uncomment the settings you want to override. Defaults remain unpinned.",
|
|
101
118
|
`# auth: ${DEFAULT_SCAN_AUTH}`,
|
|
@@ -103,6 +120,7 @@ export function projectConfigStarter(path, directory = process.cwd()) {
|
|
|
103
120
|
`# mode: ${DEFAULT_SCAN_MODE}`,
|
|
104
121
|
"# scope:",
|
|
105
122
|
"# paths: [src] # Relative to each selected repository.",
|
|
123
|
+
"# exclude_paths: [examples] # Relative to each selected repository.",
|
|
106
124
|
"# knowledge_base: [] # Paths relative to this file.",
|
|
107
125
|
"# instructions_file: instructions.md",
|
|
108
126
|
"# validation_file: validation.md # Standard mode only.",
|
|
@@ -134,6 +152,32 @@ function requireProjectConfig(value, path) {
|
|
|
134
152
|
throw new ConfigurationError(`Invalid project configuration${path === undefined ? "" : ` at ${path}`}: ${issues}`);
|
|
135
153
|
}
|
|
136
154
|
}
|
|
155
|
+
function outputPath(value, directory) {
|
|
156
|
+
if (value === undefined)
|
|
157
|
+
return;
|
|
158
|
+
const requested = resolveInputPath(value, directory);
|
|
159
|
+
const parts = requested.split(sep);
|
|
160
|
+
const parent = parts.lastIndexOf("..");
|
|
161
|
+
if (parent < 0)
|
|
162
|
+
return requested;
|
|
163
|
+
const prefix = parts.slice(0, parent + 1).join(sep);
|
|
164
|
+
try {
|
|
165
|
+
// Keep a redirected traversal intact for output validation.
|
|
166
|
+
const selected = statSync(prefix, { bigint: true, throwIfNoEntry: false });
|
|
167
|
+
if (selected !== undefined) {
|
|
168
|
+
const lexical = statSync(resolve(prefix), {
|
|
169
|
+
bigint: true,
|
|
170
|
+
throwIfNoEntry: false,
|
|
171
|
+
});
|
|
172
|
+
if (selected.dev !== lexical?.dev || selected.ino !== lexical.ino)
|
|
173
|
+
return requested;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
return requested;
|
|
178
|
+
}
|
|
179
|
+
return resolve(requested);
|
|
180
|
+
}
|
|
137
181
|
export function resolveScanSettings(project, overrides, directory, scopeSources = {}) {
|
|
138
182
|
const file = project?.input;
|
|
139
183
|
const sources = {};
|
|
@@ -149,10 +193,8 @@ export function resolveScanSettings(project, overrides, directory, scopeSources
|
|
|
149
193
|
return undefined;
|
|
150
194
|
};
|
|
151
195
|
const projectDirectory = project?.directory ?? directory;
|
|
152
|
-
const filePath = (value) => value === undefined
|
|
153
|
-
|
|
154
|
-
: resolveConfigPath(projectDirectory, value);
|
|
155
|
-
const cliPath = (value) => value === undefined ? undefined : resolveConfigPath(directory, value);
|
|
196
|
+
const filePath = (value) => value === undefined ? undefined : resolveInputPath(value, projectDirectory);
|
|
197
|
+
const cliPath = (value) => value === undefined ? undefined : resolveInputPath(value, directory);
|
|
156
198
|
const mode = choose("scan.mode", file?.scan?.mode, overrides.mode) ?? DEFAULT_SCAN_MODE;
|
|
157
199
|
const explicitDeep = deepScanOptions({
|
|
158
200
|
...overrides,
|
|
@@ -198,7 +240,7 @@ export function resolveScanSettings(project, overrides, directory, scopeSources
|
|
|
198
240
|
for (const source of ["default", "project", "cli"]) {
|
|
199
241
|
recordNativeSources(nativeSources, source);
|
|
200
242
|
}
|
|
201
|
-
const knowledgeBasePaths = choose("scan.knowledge_base", file?.scan?.knowledge_base?.map((value) =>
|
|
243
|
+
const knowledgeBasePaths = choose("scan.knowledge_base", file?.scan?.knowledge_base?.map((value) => resolveInputPath(value, projectDirectory)), overrides.knowledgeBasePaths?.map((value) => resolveInputPath(value, directory))) ?? [];
|
|
202
244
|
const settings = {
|
|
203
245
|
...pickScanSettings(overrides),
|
|
204
246
|
auth: choose("auth", file?.auth, overrides.auth) ?? DEFAULT_SCAN_AUTH,
|
|
@@ -206,12 +248,13 @@ export function resolveScanSettings(project, overrides, directory, scopeSources
|
|
|
206
248
|
mode,
|
|
207
249
|
maxTimeMinutes,
|
|
208
250
|
target,
|
|
251
|
+
excludePaths: choose("scan.exclude_paths", file?.scan?.exclude_paths, overrides.excludePaths),
|
|
209
252
|
ownerSuggestions: choose("scan.owner_suggestions", file?.scan?.owner_suggestions, overrides.ownerSuggestions),
|
|
210
253
|
knowledgeBasePaths,
|
|
211
254
|
scanPromptFile: choose("scan.instructions_file", filePath(file?.scan?.instructions_file), cliPath(overrides.scanPromptFile)),
|
|
212
255
|
validationPromptFile: choose("scan.validation_file", filePath(file?.scan?.validation_file), cliPath(overrides.validationPromptFile)),
|
|
213
256
|
postScanPromptFile: cliPath(overrides.postScanPromptFile),
|
|
214
|
-
outputDir: choose("output.directory",
|
|
257
|
+
outputDir: choose("output.directory", outputPath(file?.output?.directory, projectDirectory), outputPath(overrides.outputDir, directory)),
|
|
215
258
|
failureSeverity: choose("policy.fail_on_severity", file?.policy?.fail_on_severity, overrides.failureSeverity),
|
|
216
259
|
maxCostUsd: choose("limits.max_cost_usd_per_scan", file?.limits?.max_cost_usd_per_scan, overrides.maxCostUsd),
|
|
217
260
|
...deep,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-config.js","sourceRoot":"","sources":["../src/project-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EACL,OAAO,EACP,OAAO,EACP,UAAU,EACV,QAAQ,EACR,OAAO,EACP,GAAG,GACJ,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GAEpB,MAAM,aAAa,CAAC;AACrB,OAAO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C9B,IAAI,EAAE,MAAM,EAAE,qBAAqB,EACnC,SAAS,CAAC,UAAU,CACrB;QACD,GAAG,IAAI;KACR,CAAC;IACF,MAAM,eAAe,GAAG,oBAAoB,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC;IAC9E,OAAO;QACL,MAAM,EAAE,EAAE,cAAc,EAAE;QAC1B,OAAO,EAAE,QAAQ;QACjB,OAAO,EAAE,eAAe;QACxB,GAAG,CAAC,OAAO,EAAE,IAAI,KAAK,SAAS;YAC7B,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,CAAC;KACzE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,KAA+B;IAE/B,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,OAAO,IAAI,KAAK;QAAE,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IAC9C,IAAI,MAAM,IAAI,KAAK;QAAE,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACxD,OAAO,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport {\n dirname,\n extname,\n isAbsolute,\n relative,\n resolve,\n sep,\n} from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport Ajv from \"ajv\";\nimport {\n DEFAULT_CODEX_CONFIG,\n mergeCodexOverrides,\n type JsonObject,\n} from \"./config.js\";\nimport { ConfigurationError, errorMessage } from \"./errors.js\";\nimport { DEFAULT_DEEP_SCAN_SETTINGS } from \"./deep-scan-defaults.js\";\nimport { resolveConfigPath, type AbsolutePath } from \"./config-path.js\";\nimport { deepScanOptions, type DeepScanSources } from \"./deep-config.js\";\nimport {\n projectConfigJsonSchema,\n type ProjectConfigInput,\n type ProjectScope,\n} from \"./project-config-schema.js\";\nimport { expandHome } from \"./runtime.js\";\nimport {\n DEFAULT_SCAN_AUTH,\n DEFAULT_SCAN_MODE,\n DEEP_SCAN_SETTINGS,\n pickScanSettings,\n type DeepScanOptions,\n type ResolvedScanSettings,\n type ScanSettings,\n} from \"./scan-settings.js\";\nimport { DiffTarget, type ScanTarget } from \"./targets.js\";\n\nconst validateProjectConfig = new Ajv({\n allErrors: true,\n}).compile<ProjectConfigInput>(projectConfigJsonSchema());\n\nexport interface ProjectConfigSource {\n path?: string;\n directory: string;\n input: ProjectConfigInput;\n}\n\nexport interface ResolvedProjectConfig {\n config: { codexOverrides: JsonObject };\n options: ResolvedScanSettings;\n sources: ConfigurationSources;\n projectConfig?: ProjectConfigProvenance;\n}\n\nexport type ConfigurationSource = \"default\" | \"legacy\" | \"project\" | \"cli\";\nconst PROJECT_SETTING_KEYS = {\n auth: \"auth\",\n mode: \"scan.mode\",\n maxTimeMinutes: \"scan.max_time_minutes\",\n cyberAccessProgram: \"scan.cyber_access_program\",\n ownerSuggestions: \"scan.owner_suggestions\",\n target: \"scan.scope\",\n knowledgeBasePaths: \"scan.knowledge_base\",\n scanPromptFile: \"scan.instructions_file\",\n validationPromptFile: \"scan.validation_file\",\n outputDir: \"output.directory\",\n failureSeverity: \"policy.fail_on_severity\",\n maxCostUsd: \"limits.max_cost_usd_per_scan\",\n} as const satisfies Partial<Record<keyof ScanSettings, string>>;\ntype SettingProvenanceKey =\n (typeof PROJECT_SETTING_KEYS)[keyof typeof PROJECT_SETTING_KEYS];\nexport type ScopeProvenanceKey =\n \"scan.scope\" | \"scan.scope.diff.head\" | \"scan.scope.working_tree.base\";\nexport type ProvenanceKey =\n | SettingProvenanceKey\n | ScopeProvenanceKey\n | `scan.deep.${(typeof DEEP_SCAN_SETTINGS)[number][2]}`\n | `codex.${string}`;\nexport type ConfigurationSources = Readonly<\n Record<SettingProvenanceKey, ConfigurationSource> &\n Partial<Record<ProvenanceKey, ConfigurationSource>>\n>;\nexport interface ProjectConfigProvenance {\n path: string;\n sources: ConfigurationSources;\n}\n\n/** Build a complete, immutable source map after layer and preflight resolution. */\nexport function configurationSources(\n values: Partial<Record<ProvenanceKey, ConfigurationSource>> = {},\n deepSources?: DeepScanSources,\n): ConfigurationSources {\n const sources = {\n ...Object.fromEntries(\n Object.values(PROJECT_SETTING_KEYS).map((key) => [key, \"default\"]),\n ),\n ...values,\n } as Record<SettingProvenanceKey, ConfigurationSource> &\n Partial<Record<ProvenanceKey, ConfigurationSource>>;\n for (const [name, , key] of DEEP_SCAN_SETTINGS) {\n const source = deepSources?.[name];\n if (source !== undefined && source !== \"override\")\n sources[`scan.deep.${key}`] = source;\n }\n return Object.freeze(sources);\n}\n\nexport async function loadProjectConfig(\n file: string,\n directory = process.cwd(),\n): Promise<ResolvedProjectConfig> {\n return resolveScanSettings(\n await readProjectConfig(file, directory),\n {},\n directory,\n );\n}\n\nexport function resolveProjectConfig(\n input: ProjectConfigInput,\n directory = process.cwd(),\n): ResolvedProjectConfig {\n requireProjectConfig(input);\n return resolveScanSettings(\n { input, directory: resolve(directory) },\n {},\n directory,\n );\n}\n\nexport async function readProjectConfig(\n file: string,\n directory = process.cwd(),\n): Promise<ProjectConfigSource> {\n const path = resolve(directory, expandHome(file));\n const extension = projectConfigExtension(path);\n let text: string;\n try {\n text = await readFile(path, \"utf8\");\n } catch (error) {\n throw new ConfigurationError(\n `Cannot read project configuration at ${path}: ${errorMessage(error)}`,\n { cause: error },\n );\n }\n let value: unknown;\n try {\n if (extension === \".json\") {\n value = JSON.parse(text.replace(/^\\uFEFF/u, \"\"));\n } else {\n const { parseDocument } = await import(\"yaml\");\n const document = parseDocument(text, { prettyErrors: false });\n if (document.errors.length > 0) throw document.errors[0];\n // Keep YAML's expansion guard while allowing repeated native profiles.\n value = document.toJS({ maxAliasCount: 10_000 });\n }\n } catch (error) {\n throw new ConfigurationError(\n `Cannot parse project configuration at ${path}: ${errorMessage(error)}`,\n { cause: error },\n );\n }\n requireProjectConfig(value, path);\n return { path, directory: dirname(path), input: value };\n}\n\nfunction projectConfigExtension(path: string): string {\n const extension = extname(path).toLowerCase();\n if (![\".yaml\", \".yml\", \".json\"].includes(extension)) {\n throw new ConfigurationError(\n \"Project configuration must be a .yaml, .yml, or .json file.\",\n );\n }\n return extension;\n}\n\nexport function projectConfigStarter(\n path: string,\n directory = process.cwd(),\n): string {\n const schemaPath = resolve(\n directory,\n \"node_modules/@openai/codex-security/schemas/project-config.schema.json\",\n );\n const relativeSchema = relative(\n dirname(resolve(directory, path)),\n schemaPath,\n );\n const schema = isAbsolute(relativeSchema)\n ? pathToFileURL(schemaPath).href\n : `${relativeSchema.startsWith(\".\") ? \"\" : \"./\"}${encodeURI(\n relativeSchema.split(sep).join(\"/\"),\n ).replace(/[#?]/gu, encodeURIComponent)}`;\n if (projectConfigExtension(path) === \".json\")\n return `${JSON.stringify({ $schema: schema }, null, 2)}\\n`;\n return [\n \"# This file is trusted like CLI options. Keep it outside untrusted inputs.\",\n `$schema: ${schema}`,\n \"\",\n \"# Uncomment the settings you want to override. Defaults remain unpinned.\",\n `# auth: ${DEFAULT_SCAN_AUTH}`,\n \"# scan:\",\n `# mode: ${DEFAULT_SCAN_MODE}`,\n \"# scope:\",\n \"# paths: [src] # Relative to each selected repository.\",\n \"# knowledge_base: [] # Paths relative to this file.\",\n \"# instructions_file: instructions.md\",\n \"# validation_file: validation.md # Standard mode only.\",\n \"# max_time_minutes: 15 # Advisory in Standard; enforced discovery limit in Deep.\",\n \"# deep: # Used when mode is deep.\",\n ...DEEP_SCAN_SETTINGS.filter(([name]) => name !== \"maxTimeHours\").map(\n ([name, , key]) => `# ${key}: ${DEFAULT_DEEP_SCAN_SETTINGS[name]}`,\n ),\n \"# codex:\",\n `# model: ${DEFAULT_CODEX_CONFIG[\"model\"]}`,\n `# model_reasoning_effort: ${DEFAULT_CODEX_CONFIG[\"model_reasoning_effort\"]}`,\n \"# limits:\",\n \"# max_cost_usd_per_scan: 10 # Optional limit per scan attempt.\",\n \"# policy:\",\n \"# fail_on_severity: high # Omitted by default (report only).\",\n \"# output:\",\n \"# directory: ../scan-results # Outside the selected repositories.\",\n \"\",\n ].join(\"\\n\");\n}\n\nfunction requireProjectConfig(\n value: unknown,\n path?: string,\n): asserts value is ProjectConfigInput {\n if (!validateProjectConfig(value)) {\n const issues = validateProjectConfig\n .errors!.map((issue) => {\n const message =\n issue.keyword === \"additionalProperties\"\n ? `Unknown key ${issue.params[\"additionalProperty\"]}.`\n : issue.message;\n return `${issue.instancePath || \"configuration\"}: ${message}`;\n })\n .join(\"; \");\n throw new ConfigurationError(\n `Invalid project configuration${path === undefined ? \"\" : ` at ${path}`}: ${issues}`,\n );\n }\n}\n\nexport function resolveScanSettings(\n project: ProjectConfigSource | undefined,\n overrides: Partial<ScanSettings> & { codexOverrides?: JsonObject },\n directory: string,\n scopeSources: Partial<Record<ScopeProvenanceKey, ConfigurationSource>> = {},\n): ResolvedProjectConfig {\n const file = project?.input;\n const sources: Partial<Record<ProvenanceKey, ConfigurationSource>> = {};\n const choose = <T>(\n key: ProvenanceKey,\n configured: T | undefined,\n explicit: T | undefined,\n ): T | undefined => {\n if (explicit !== undefined) {\n sources[key] = \"cli\";\n return explicit;\n }\n if (configured !== undefined) {\n sources[key] = \"project\";\n return configured;\n }\n return undefined;\n };\n const projectDirectory = project?.directory ?? directory;\n const filePath = (value: string | undefined): AbsolutePath | undefined =>\n value === undefined\n ? undefined\n : resolveConfigPath(projectDirectory, value);\n const cliPath = (value: string | undefined): AbsolutePath | undefined =>\n value === undefined ? undefined : resolveConfigPath(directory, value);\n\n const mode =\n choose(\"scan.mode\", file?.scan?.mode, overrides.mode) ?? DEFAULT_SCAN_MODE;\n const explicitDeep = deepScanOptions({\n ...overrides,\n maxTimeMinutes: undefined,\n mode,\n });\n const target =\n choose(\n \"scan.scope\",\n projectScopeTarget(file?.scan?.scope),\n overrides.target,\n ) ?? \"repository\";\n const configuredDeep = file?.scan?.deep;\n const explicitTime =\n overrides.maxTimeMinutes !== undefined ||\n overrides.maxTimeHours !== undefined;\n const maxTimeMinutes = choose(\n \"scan.max_time_minutes\",\n explicitTime ? undefined : file?.scan?.max_time_minutes,\n overrides.maxTimeMinutes,\n );\n const deep: DeepScanOptions = {};\n if (mode === \"deep\") {\n for (const [name, , field] of DEEP_SCAN_SETTINGS) {\n const value = choose(\n `scan.deep.${field}`,\n name === \"maxTimeHours\" && explicitTime\n ? undefined\n : configuredDeep?.[field],\n explicitDeep[name],\n );\n if (value !== undefined) deep[name] = value;\n }\n }\n\n const codexOverrides = mergeCodexOverrides(\n file?.codex ?? {},\n overrides.codexOverrides ?? {},\n );\n const nativeSourceTree = (\n value: JsonObject,\n source: ConfigurationSource,\n ): JsonObject =>\n Object.fromEntries(\n Object.entries(value).map(([key, item]) => [\n key,\n item !== null && typeof item === \"object\" && !Array.isArray(item)\n ? nativeSourceTree(item, source)\n : source,\n ]),\n );\n const recordNativeSources = (\n value: JsonObject,\n source: ConfigurationSource,\n prefix: \"codex\" | `codex.${string}` = \"codex\",\n ) => {\n for (const [key, item] of Object.entries(value)) {\n const path: `codex.${string}` = `${prefix}.${key}`;\n if (item !== null && typeof item === \"object\" && !Array.isArray(item)) {\n recordNativeSources(item, source, path);\n } else if (item === source) {\n sources[path] = source;\n }\n }\n };\n // Match the value merge: defaults beneath the combined project/CLI overrides.\n const nativeSources = mergeCodexOverrides(\n nativeSourceTree(DEFAULT_CODEX_CONFIG, \"default\"),\n mergeCodexOverrides(\n nativeSourceTree(file?.codex ?? {}, \"project\"),\n nativeSourceTree(overrides.codexOverrides ?? {}, \"cli\"),\n ),\n );\n // Literal dotted keys can share a flattened name; retain layer precedence.\n for (const source of [\"default\", \"project\", \"cli\"] as const) {\n recordNativeSources(nativeSources, source);\n }\n const knowledgeBasePaths =\n choose(\n \"scan.knowledge_base\",\n file?.scan?.knowledge_base?.map((value) =>\n resolveConfigPath(projectDirectory, value),\n ),\n overrides.knowledgeBasePaths?.map((value) =>\n resolveConfigPath(directory, value),\n ),\n ) ?? [];\n const settings: ResolvedScanSettings = {\n ...pickScanSettings(overrides),\n auth: choose(\"auth\", file?.auth, overrides.auth) ?? DEFAULT_SCAN_AUTH,\n cyberAccessProgram: choose(\n \"scan.cyber_access_program\",\n file?.scan?.cyber_access_program,\n overrides.cyberAccessProgram,\n ),\n mode,\n maxTimeMinutes,\n target,\n ownerSuggestions: choose(\n \"scan.owner_suggestions\",\n file?.scan?.owner_suggestions,\n overrides.ownerSuggestions,\n ),\n knowledgeBasePaths,\n scanPromptFile: choose(\n \"scan.instructions_file\",\n filePath(file?.scan?.instructions_file),\n cliPath(overrides.scanPromptFile),\n ),\n validationPromptFile: choose(\n \"scan.validation_file\",\n filePath(file?.scan?.validation_file),\n cliPath(overrides.validationPromptFile),\n ),\n postScanPromptFile: cliPath(overrides.postScanPromptFile),\n outputDir: choose(\n \"output.directory\",\n filePath(file?.output?.directory),\n cliPath(overrides.outputDir),\n ),\n failureSeverity: choose(\n \"policy.fail_on_severity\",\n file?.policy?.fail_on_severity,\n overrides.failureSeverity,\n ),\n maxCostUsd: choose(\n \"limits.max_cost_usd_per_scan\",\n file?.limits?.max_cost_usd_per_scan,\n overrides.maxCostUsd,\n ),\n ...deep,\n };\n const resolvedSources = configurationSources({ ...sources, ...scopeSources });\n return {\n config: { codexOverrides },\n options: settings,\n sources: resolvedSources,\n ...(project?.path === undefined\n ? {}\n : { projectConfig: { path: project.path, sources: resolvedSources } }),\n };\n}\n\nexport function projectScopeTarget(\n scope: ProjectScope | undefined,\n): ScanTarget | undefined {\n if (scope === undefined) return undefined;\n if (\"paths\" in scope) return [...scope.paths];\n if (\"diff\" in scope) return DiffTarget.refs(scope.diff);\n return DiffTarget.workingTree(scope.working_tree);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"project-config.js","sourceRoot":"","sources":["../src/project-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,M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MAAM,EAAE,gBAAgB,EAC9B,SAAS,CAAC,eAAe,CAC1B;QACD,UAAU,EAAE,MAAM,CAChB,8BAA8B,EAC9B,IAAI,EAAE,MAAM,EAAE,qBAAqB,EACnC,SAAS,CAAC,UAAU,CACrB;QACD,GAAG,IAAI;KACR,CAAC;IACF,MAAM,eAAe,GAAG,oBAAoB,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC;IAC9E,OAAO;QACL,MAAM,EAAE,EAAE,cAAc,EAAE;QAC1B,OAAO,EAAE,QAAQ;QACjB,OAAO,EAAE,eAAe;QACxB,GAAG,CAAC,OAAO,EAAE,IAAI,KAAK,SAAS;YAC7B,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,CAAC;KACzE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,KAA+B;IAE/B,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,OAAO,IAAI,KAAK;QAAE,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IAC9C,IAAI,MAAM,IAAI,KAAK;QAAE,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACxD,OAAO,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import { isUtf8 } from \"node:buffer\";\nimport { existsSync, statSync } from \"node:fs\";\nimport { readFile, realpath } from \"node:fs/promises\";\nimport {\n basename,\n dirname,\n extname,\n isAbsolute,\n relative,\n resolve,\n sep,\n} from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport Ajv from \"ajv\";\nimport {\n DEFAULT_CODEX_CONFIG,\n mergeCodexOverrides,\n type JsonObject,\n} from \"./config.js\";\nimport { ConfigurationError, errorMessage } from \"./errors.js\";\nimport { DEFAULT_DEEP_SCAN_SETTINGS } from \"./deep-scan-defaults.js\";\nimport type { AbsolutePath } from \"./config-path.js\";\nimport { deepScanOptions, type DeepScanSources } from \"./deep-config.js\";\nimport {\n projectConfigJsonSchema,\n type ProjectConfigInput,\n type ProjectScope,\n} from \"./project-config-schema.js\";\nimport { expandHomeForLookup, resolveInputPath } from \"./runtime.js\";\nimport {\n DEFAULT_SCAN_AUTH,\n DEFAULT_SCAN_MODE,\n DEEP_SCAN_SETTINGS,\n pickScanSettings,\n type DeepScanOptions,\n type ResolvedScanSettings,\n type ScanSettings,\n} from \"./scan-settings.js\";\nimport { DiffTarget, type ScanTarget } from \"./targets.js\";\n\nconst validateProjectConfig = new Ajv({\n allErrors: true,\n}).compile<ProjectConfigInput>(projectConfigJsonSchema());\n\nexport interface ProjectConfigSource {\n path?: string;\n directory: string;\n input: ProjectConfigInput;\n}\n\nexport interface ResolvedProjectConfig {\n config: { codexOverrides: JsonObject };\n options: ResolvedScanSettings;\n sources: ConfigurationSources;\n projectConfig?: ProjectConfigProvenance;\n}\n\nexport type ConfigurationSource = \"default\" | \"legacy\" | \"project\" | \"cli\";\nconst PROJECT_SETTING_KEYS = {\n auth: \"auth\",\n mode: \"scan.mode\",\n maxTimeMinutes: \"scan.max_time_minutes\",\n cyberAccessProgram: \"scan.cyber_access_program\",\n ownerSuggestions: \"scan.owner_suggestions\",\n target: \"scan.scope\",\n excludePaths: \"scan.exclude_paths\",\n knowledgeBasePaths: \"scan.knowledge_base\",\n scanPromptFile: \"scan.instructions_file\",\n validationPromptFile: \"scan.validation_file\",\n outputDir: \"output.directory\",\n failureSeverity: \"policy.fail_on_severity\",\n maxCostUsd: \"limits.max_cost_usd_per_scan\",\n} as const satisfies Partial<Record<keyof ScanSettings, string>>;\ntype SettingProvenanceKey =\n (typeof PROJECT_SETTING_KEYS)[keyof typeof PROJECT_SETTING_KEYS];\nexport type ScopeProvenanceKey =\n \"scan.scope\" | \"scan.scope.diff.head\" | \"scan.scope.working_tree.base\";\nexport type ProvenanceKey =\n | SettingProvenanceKey\n | ScopeProvenanceKey\n | `scan.deep.${(typeof DEEP_SCAN_SETTINGS)[number][2]}`\n | `codex.${string}`;\nexport type ConfigurationSources = Readonly<\n Record<SettingProvenanceKey, ConfigurationSource> &\n Partial<Record<ProvenanceKey, ConfigurationSource>>\n>;\nexport interface ProjectConfigProvenance {\n path: string;\n sources: ConfigurationSources;\n}\n\n/** Build a complete, immutable source map after layer and preflight resolution. */\nexport function configurationSources(\n values: Partial<Record<ProvenanceKey, ConfigurationSource>> = {},\n deepSources?: DeepScanSources,\n): ConfigurationSources {\n const sources = {\n ...Object.fromEntries(\n Object.values(PROJECT_SETTING_KEYS).map((key) => [key, \"default\"]),\n ),\n ...values,\n } as Record<SettingProvenanceKey, ConfigurationSource> &\n Partial<Record<ProvenanceKey, ConfigurationSource>>;\n for (const [name, , key] of DEEP_SCAN_SETTINGS) {\n const source = deepSources?.[name];\n if (source !== undefined && source !== \"override\")\n sources[`scan.deep.${key}`] = source;\n }\n return Object.freeze(sources);\n}\n\nexport async function loadProjectConfig(\n file: string,\n directory = process.cwd(),\n): Promise<ResolvedProjectConfig> {\n return resolveScanSettings(\n await readProjectConfig(file, directory),\n {},\n directory,\n );\n}\n\nexport function resolveProjectConfig(\n input: ProjectConfigInput,\n directory = process.cwd(),\n): ResolvedProjectConfig {\n requireProjectConfig(input);\n return resolveScanSettings(\n { input, directory: resolve(directory) },\n {},\n directory,\n );\n}\n\nexport async function readProjectConfig(\n file: string,\n directory = process.cwd(),\n): Promise<ProjectConfigSource> {\n const selected = expandHomeForLookup(file);\n const requested = isAbsolute(selected)\n ? selected\n : `${directory || \".\"}${sep}${selected}`;\n const traversesParent = sep === \"/\" && requested.split(\"/\").includes(\"..\");\n let path = traversesParent ? requested : resolve(directory, selected);\n const extension = projectConfigExtension(path);\n let text: string;\n try {\n // Resolve the parent through the filesystem while retaining the selected filename.\n if (traversesParent) {\n const parent = await realpath(dirname(path), { encoding: \"buffer\" });\n if (!isUtf8(parent))\n throw new Error(\n \"The resolved configuration directory is not a valid UTF-8 path.\",\n );\n path = resolve(parent.toString(), basename(path));\n }\n text = await readFile(path, \"utf8\");\n } catch (error) {\n throw new ConfigurationError(\n `Cannot read project configuration at ${path}: ${errorMessage(error)}`,\n { cause: error },\n );\n }\n let value: unknown;\n try {\n if (extension === \".json\") {\n value = JSON.parse(text.replace(/^\\uFEFF/u, \"\"));\n } else {\n const { parseDocument } = await import(\"yaml\");\n const document = parseDocument(text, { prettyErrors: false });\n if (document.errors.length > 0) throw document.errors[0];\n // Keep YAML's expansion guard while allowing repeated native profiles.\n value = document.toJS({ maxAliasCount: 10_000 });\n }\n } catch (error) {\n throw new ConfigurationError(\n `Cannot parse project configuration at ${path}: ${errorMessage(error)}`,\n { cause: error },\n );\n }\n requireProjectConfig(value, path);\n return { path, directory: dirname(path), input: value };\n}\n\nfunction projectConfigExtension(path: string): string {\n const extension = extname(path).toLowerCase();\n if (![\".yaml\", \".yml\", \".json\"].includes(extension)) {\n throw new ConfigurationError(\n \"Project configuration must be a .yaml, .yml, or .json file.\",\n );\n }\n return extension;\n}\n\nexport function projectConfigStarter(\n path: string,\n directory = process.cwd(),\n): string {\n const schemaPath = resolve(\n directory,\n \"node_modules/@openai/codex-security/schemas/project-config.schema.json\",\n );\n const relativeSchema = relative(\n dirname(resolve(directory, path)),\n schemaPath,\n );\n const schema = isAbsolute(relativeSchema)\n ? pathToFileURL(schemaPath).href\n : `${relativeSchema.startsWith(\".\") ? \"\" : \"./\"}${encodeURI(\n relativeSchema.split(sep).join(\"/\"),\n ).replace(/[#?]/gu, encodeURIComponent)}`;\n const hasSchema = existsSync(schemaPath);\n if (projectConfigExtension(path) === \".json\")\n return `${JSON.stringify(hasSchema ? { $schema: schema } : {}, null, 2)}\\n`;\n return [\n \"# This file is trusted like CLI options. Keep it outside untrusted inputs.\",\n ...(hasSchema\n ? [`$schema: ${schema}`]\n : [\"# Replace the empty mapping below when enabling settings.\", \"{}\"]),\n \"\",\n \"# Uncomment the settings you want to override. Defaults remain unpinned.\",\n `# auth: ${DEFAULT_SCAN_AUTH}`,\n \"# scan:\",\n `# mode: ${DEFAULT_SCAN_MODE}`,\n \"# scope:\",\n \"# paths: [src] # Relative to each selected repository.\",\n \"# exclude_paths: [examples] # Relative to each selected repository.\",\n \"# knowledge_base: [] # Paths relative to this file.\",\n \"# instructions_file: instructions.md\",\n \"# validation_file: validation.md # Standard mode only.\",\n \"# max_time_minutes: 15 # Advisory in Standard; enforced discovery limit in Deep.\",\n \"# deep: # Used when mode is deep.\",\n ...DEEP_SCAN_SETTINGS.filter(([name]) => name !== \"maxTimeHours\").map(\n ([name, , key]) => `# ${key}: ${DEFAULT_DEEP_SCAN_SETTINGS[name]}`,\n ),\n \"# codex:\",\n `# model: ${DEFAULT_CODEX_CONFIG[\"model\"]}`,\n `# model_reasoning_effort: ${DEFAULT_CODEX_CONFIG[\"model_reasoning_effort\"]}`,\n \"# limits:\",\n \"# max_cost_usd_per_scan: 10 # Optional limit per scan attempt.\",\n \"# policy:\",\n \"# fail_on_severity: high # Omitted by default (report only).\",\n \"# output:\",\n \"# directory: ../scan-results # Outside the selected repositories.\",\n \"\",\n ].join(\"\\n\");\n}\n\nfunction requireProjectConfig(\n value: unknown,\n path?: string,\n): asserts value is ProjectConfigInput {\n if (!validateProjectConfig(value)) {\n const issues = validateProjectConfig\n .errors!.map((issue) => {\n const message =\n issue.keyword === \"additionalProperties\"\n ? `Unknown key ${issue.params[\"additionalProperty\"]}.`\n : issue.message;\n return `${issue.instancePath || \"configuration\"}: ${message}`;\n })\n .join(\"; \");\n throw new ConfigurationError(\n `Invalid project configuration${path === undefined ? \"\" : ` at ${path}`}: ${issues}`,\n );\n }\n}\n\nfunction outputPath(\n value: string | undefined,\n directory: string,\n): AbsolutePath | undefined {\n if (value === undefined) return;\n const requested = resolveInputPath(value, directory);\n const parts = requested.split(sep);\n const parent = parts.lastIndexOf(\"..\");\n if (parent < 0) return requested;\n const prefix = parts.slice(0, parent + 1).join(sep);\n try {\n // Keep a redirected traversal intact for output validation.\n const selected = statSync(prefix, { bigint: true, throwIfNoEntry: false });\n if (selected !== undefined) {\n const lexical = statSync(resolve(prefix), {\n bigint: true,\n throwIfNoEntry: false,\n });\n if (selected.dev !== lexical?.dev || selected.ino !== lexical.ino)\n return requested;\n }\n } catch {\n return requested;\n }\n return resolve(requested) as AbsolutePath;\n}\n\nexport function resolveScanSettings(\n project: ProjectConfigSource | undefined,\n overrides: Partial<ScanSettings> & { codexOverrides?: JsonObject },\n directory: string,\n scopeSources: Partial<Record<ScopeProvenanceKey, ConfigurationSource>> = {},\n): ResolvedProjectConfig {\n const file = project?.input;\n const sources: Partial<Record<ProvenanceKey, ConfigurationSource>> = {};\n const choose = <T>(\n key: ProvenanceKey,\n configured: T | undefined,\n explicit: T | undefined,\n ): T | undefined => {\n if (explicit !== undefined) {\n sources[key] = \"cli\";\n return explicit;\n }\n if (configured !== undefined) {\n sources[key] = \"project\";\n return configured;\n }\n return undefined;\n };\n const projectDirectory = project?.directory ?? directory;\n const filePath = (value: string | undefined): AbsolutePath | undefined =>\n value === undefined ? undefined : resolveInputPath(value, projectDirectory);\n const cliPath = (value: string | undefined): AbsolutePath | undefined =>\n value === undefined ? undefined : resolveInputPath(value, directory);\n\n const mode =\n choose(\"scan.mode\", file?.scan?.mode, overrides.mode) ?? DEFAULT_SCAN_MODE;\n const explicitDeep = deepScanOptions({\n ...overrides,\n maxTimeMinutes: undefined,\n mode,\n });\n const target =\n choose(\n \"scan.scope\",\n projectScopeTarget(file?.scan?.scope),\n overrides.target,\n ) ?? \"repository\";\n const configuredDeep = file?.scan?.deep;\n const explicitTime =\n overrides.maxTimeMinutes !== undefined ||\n overrides.maxTimeHours !== undefined;\n const maxTimeMinutes = choose(\n \"scan.max_time_minutes\",\n explicitTime ? undefined : file?.scan?.max_time_minutes,\n overrides.maxTimeMinutes,\n );\n const deep: DeepScanOptions = {};\n if (mode === \"deep\") {\n for (const [name, , field] of DEEP_SCAN_SETTINGS) {\n const value = choose(\n `scan.deep.${field}`,\n name === \"maxTimeHours\" && explicitTime\n ? undefined\n : configuredDeep?.[field],\n explicitDeep[name],\n );\n if (value !== undefined) deep[name] = value;\n }\n }\n\n const codexOverrides = mergeCodexOverrides(\n file?.codex ?? {},\n overrides.codexOverrides ?? {},\n );\n const nativeSourceTree = (\n value: JsonObject,\n source: ConfigurationSource,\n ): JsonObject =>\n Object.fromEntries(\n Object.entries(value).map(([key, item]) => [\n key,\n item !== null && typeof item === \"object\" && !Array.isArray(item)\n ? nativeSourceTree(item, source)\n : source,\n ]),\n );\n const recordNativeSources = (\n value: JsonObject,\n source: ConfigurationSource,\n prefix: \"codex\" | `codex.${string}` = \"codex\",\n ) => {\n for (const [key, item] of Object.entries(value)) {\n const path: `codex.${string}` = `${prefix}.${key}`;\n if (item !== null && typeof item === \"object\" && !Array.isArray(item)) {\n recordNativeSources(item, source, path);\n } else if (item === source) {\n sources[path] = source;\n }\n }\n };\n // Match the value merge: defaults beneath the combined project/CLI overrides.\n const nativeSources = mergeCodexOverrides(\n nativeSourceTree(DEFAULT_CODEX_CONFIG, \"default\"),\n mergeCodexOverrides(\n nativeSourceTree(file?.codex ?? {}, \"project\"),\n nativeSourceTree(overrides.codexOverrides ?? {}, \"cli\"),\n ),\n );\n // Literal dotted keys can share a flattened name; retain layer precedence.\n for (const source of [\"default\", \"project\", \"cli\"] as const) {\n recordNativeSources(nativeSources, source);\n }\n const knowledgeBasePaths =\n choose(\n \"scan.knowledge_base\",\n file?.scan?.knowledge_base?.map((value) =>\n resolveInputPath(value, projectDirectory),\n ),\n overrides.knowledgeBasePaths?.map((value) =>\n resolveInputPath(value, directory),\n ),\n ) ?? [];\n const settings: ResolvedScanSettings = {\n ...pickScanSettings(overrides),\n auth: choose(\"auth\", file?.auth, overrides.auth) ?? DEFAULT_SCAN_AUTH,\n cyberAccessProgram: choose(\n \"scan.cyber_access_program\",\n file?.scan?.cyber_access_program,\n overrides.cyberAccessProgram,\n ),\n mode,\n maxTimeMinutes,\n target,\n excludePaths: choose(\n \"scan.exclude_paths\",\n file?.scan?.exclude_paths,\n overrides.excludePaths,\n ),\n ownerSuggestions: choose(\n \"scan.owner_suggestions\",\n file?.scan?.owner_suggestions,\n overrides.ownerSuggestions,\n ),\n knowledgeBasePaths,\n scanPromptFile: choose(\n \"scan.instructions_file\",\n filePath(file?.scan?.instructions_file),\n cliPath(overrides.scanPromptFile),\n ),\n validationPromptFile: choose(\n \"scan.validation_file\",\n filePath(file?.scan?.validation_file),\n cliPath(overrides.validationPromptFile),\n ),\n postScanPromptFile: cliPath(overrides.postScanPromptFile),\n outputDir: choose(\n \"output.directory\",\n outputPath(file?.output?.directory, projectDirectory),\n outputPath(overrides.outputDir, directory),\n ),\n failureSeverity: choose(\n \"policy.fail_on_severity\",\n file?.policy?.fail_on_severity,\n overrides.failureSeverity,\n ),\n maxCostUsd: choose(\n \"limits.max_cost_usd_per_scan\",\n file?.limits?.max_cost_usd_per_scan,\n overrides.maxCostUsd,\n ),\n ...deep,\n };\n const resolvedSources = configurationSources({ ...sources, ...scopeSources });\n return {\n config: { codexOverrides },\n options: settings,\n sources: resolvedSources,\n ...(project?.path === undefined\n ? {}\n : { projectConfig: { path: project.path, sources: resolvedSources } }),\n };\n}\n\nexport function projectScopeTarget(\n scope: ProjectScope | undefined,\n): ScanTarget | undefined {\n if (scope === undefined) return undefined;\n if (\"paths\" in scope) return [...scope.paths];\n if (\"diff\" in scope) return DiffTarget.refs(scope.diff);\n return DiffTarget.workingTree(scope.working_tree);\n}\n"]}
|
package/dist/prompt-files.d.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { type BigIntStats } from "node:fs";
|
|
2
2
|
import type { ScanPromptSettings } from "./scan-settings.js";
|
|
3
|
+
/** Canonical source directories, or null when a checkout cannot be verified. */
|
|
4
|
+
export type DocumentRoots = readonly string[] | null;
|
|
5
|
+
export type DocumentRootSource = DocumentRoots | (() => Promise<DocumentRoots>);
|
|
3
6
|
type ResolvedScanPrompts = Pick<ScanPromptSettings, "scanPrompt" | "validationPrompt" | "postScanPrompt"> & {
|
|
4
7
|
scanPromptFile: undefined;
|
|
5
8
|
validationPromptFile: undefined;
|
|
6
9
|
postScanPromptFile: undefined;
|
|
7
10
|
};
|
|
8
11
|
/** Resolve selected files once; an inline SDK prompt overrides its file. */
|
|
9
|
-
export declare function resolveScanPrompts(options: ScanPromptSettings, repository: string |
|
|
10
|
-
|
|
12
|
+
export declare function resolveScanPrompts(options: ScanPromptSettings, repository: string | DocumentRootSource, directory?: string): Promise<ResolvedScanPrompts>;
|
|
13
|
+
/** A selected source cannot use a directory link to supply a document outside it. */
|
|
14
|
+
export declare function checkDocumentPath(path: string, canonical: string, source: DocumentRootSource, signal?: AbortSignal): Promise<void>;
|
|
15
|
+
export declare function readRegularInputFile(path: string, repository: string | DocumentRootSource, metadata?: Pick<BigIntStats, "isFile" | "dev" | "ino">): Promise<string>;
|
|
11
16
|
export {};
|
|
12
17
|
//# sourceMappingURL=prompt-files.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-files.d.ts","sourceRoot":"","sources":["../src/prompt-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt-files.d.ts","sourceRoot":"","sources":["../src/prompt-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AActD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,gFAAgF;AAChF,MAAM,MAAM,aAAa,GAAG,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;AACrD,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG,CAAC,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;AAEhF,KAAK,mBAAmB,GAAG,IAAI,CAC7B,kBAAkB,EAClB,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,CACrD,GAAG;IACF,cAAc,EAAE,SAAS,CAAC;IAC1B,oBAAoB,EAAE,SAAS,CAAC;IAChC,kBAAkB,EAAE,SAAS,CAAC;CAC/B,CAAC;AAEF,4EAA4E;AAC5E,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,kBAAkB,EAC3B,UAAU,EAAE,MAAM,GAAG,kBAAkB,EACvC,SAAS,SAAgB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAoC9B;AAED,qFAAqF;AACrF,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,kBAAkB,EAC1B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CA8Bf;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GAAG,kBAAkB,EACvC,QAAQ,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC,GACrD,OAAO,CAAC,MAAM,CAAC,CAwCjB"}
|
package/dist/prompt-files.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { constants } from "node:fs";
|
|
2
|
-
import { lstat, open, realpath } from "node:fs/promises";
|
|
3
|
-
import { basename, dirname, join,
|
|
2
|
+
import { lstat, open, readlink, realpath } from "node:fs/promises";
|
|
3
|
+
import { basename, dirname, format, isAbsolute, join, parse, sep, } from "node:path";
|
|
4
4
|
import { CodexSecurityError } from "./errors.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { resolveInputPath, resolveParentTraversal } from "./runtime.js";
|
|
6
|
+
import { isWithin } from "./trusted-executable.js";
|
|
7
7
|
/** Resolve selected files once; an inline SDK prompt overrides its file. */
|
|
8
8
|
export async function resolveScanPrompts(options, repository, directory = process.cwd()) {
|
|
9
9
|
const read = async (inline, file) => inline !== undefined || file === undefined
|
|
10
10
|
? inline
|
|
11
|
-
: await readRegularInputFile(
|
|
11
|
+
: await readRegularInputFile(resolveInputPath(file, directory), repository);
|
|
12
12
|
const [scanPrompt, validationPrompt, postScanPrompt] = await Promise.all([
|
|
13
13
|
read(options.scanPrompt, options.scanPromptFile),
|
|
14
14
|
read(options.validationPrompt, options.validationPromptFile),
|
|
@@ -34,26 +34,48 @@ export async function resolveScanPrompts(options, repository, directory = proces
|
|
|
34
34
|
postScanPromptFile: undefined,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
+
/** A selected source cannot use a directory link to supply a document outside it. */
|
|
38
|
+
export async function checkDocumentPath(path, canonical, source, signal) {
|
|
39
|
+
if (path === canonical)
|
|
40
|
+
return;
|
|
41
|
+
const roots = typeof source === "function" ? await source() : source;
|
|
42
|
+
const outside = roots?.filter((root) => !isWithin(root, canonical));
|
|
43
|
+
if (outside?.length === 0)
|
|
44
|
+
return;
|
|
45
|
+
const directories = new Set([dirname(path)]);
|
|
46
|
+
for (const directory of directories) {
|
|
47
|
+
const parsed = parse(directory);
|
|
48
|
+
if (!parsed.base)
|
|
49
|
+
continue;
|
|
50
|
+
directories.add(parsed.dir);
|
|
51
|
+
signal?.throwIfAborted();
|
|
52
|
+
// A trailing slash would make lstat follow the link. Keep any raw "..".
|
|
53
|
+
const entry = format(parsed);
|
|
54
|
+
if (!(await lstat(entry)).isSymbolicLink())
|
|
55
|
+
continue;
|
|
56
|
+
if (!outside) {
|
|
57
|
+
throw new CodexSecurityError("Select the document by its canonical path when the source checkout is unknown.");
|
|
58
|
+
}
|
|
59
|
+
const owner = await realpath(await resolveParentTraversal(parsed.dir));
|
|
60
|
+
if (outside.some((root) => isWithin(root, owner))) {
|
|
61
|
+
throw new CodexSecurityError(`Input files must not follow repository directory links outside the selected repository: ${entry}`);
|
|
62
|
+
}
|
|
63
|
+
// An external alias can point through a directory link inside a checkout.
|
|
64
|
+
const target = await readlink(entry);
|
|
65
|
+
directories.add(isAbsolute(target) ? target : `${owner}${sep}${target}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
37
68
|
export async function readRegularInputFile(path, repository, metadata) {
|
|
38
69
|
const selected = metadata ?? (await lstat(path, { bigint: true }));
|
|
39
70
|
if (!selected.isFile()) {
|
|
40
71
|
throw new CodexSecurityError("Input files must be regular files.");
|
|
41
72
|
}
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (!isOutsidePath(relative(canonicalRepository, await realpath(ancestor)))) {
|
|
49
|
-
throw new CodexSecurityError("Input files must not follow repository directory links outside the selected repository.");
|
|
50
|
-
}
|
|
51
|
-
if (dirname(ancestor) === ancestor)
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const file = await open(join(canonicalParent, basename(path)), constants.O_RDONLY |
|
|
73
|
+
const canonical = join(await realpath(await resolveParentTraversal(dirname(path))), basename(path));
|
|
74
|
+
const roots = typeof repository === "string" ? [repository] : repository;
|
|
75
|
+
await checkDocumentPath(path, canonical, Array.isArray(roots)
|
|
76
|
+
? await Promise.all(roots.map(async (root) => realpath(await resolveParentTraversal(root))))
|
|
77
|
+
: roots);
|
|
78
|
+
const file = await open(canonical, constants.O_RDONLY |
|
|
57
79
|
(constants.O_NOFOLLOW ?? 0) |
|
|
58
80
|
(constants.O_NONBLOCK ?? 0));
|
|
59
81
|
try {
|
package/dist/prompt-files.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-files.js","sourceRoot":"","sources":["../src/prompt-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt-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type BigIntStats } from \"node:fs\";\nimport { lstat, open, readlink, realpath } from \"node:fs/promises\";\nimport {\n basename,\n dirname,\n format,\n isAbsolute,\n join,\n parse,\n sep,\n} from \"node:path\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport { resolveInputPath, resolveParentTraversal } from \"./runtime.js\";\nimport { isWithin } from \"./trusted-executable.js\";\nimport type { ScanPromptSettings } from \"./scan-settings.js\";\n\n/** Canonical source directories, or null when a checkout cannot be verified. */\nexport type DocumentRoots = readonly string[] | null;\nexport type DocumentRootSource = DocumentRoots | (() => Promise<DocumentRoots>);\n\ntype ResolvedScanPrompts = Pick<\n ScanPromptSettings,\n \"scanPrompt\" | \"validationPrompt\" | \"postScanPrompt\"\n> & {\n scanPromptFile: undefined;\n validationPromptFile: undefined;\n postScanPromptFile: undefined;\n};\n\n/** Resolve selected files once; an inline SDK prompt overrides its file. */\nexport async function resolveScanPrompts(\n options: ScanPromptSettings,\n repository: string | DocumentRootSource,\n directory = process.cwd(),\n): Promise<ResolvedScanPrompts> {\n const read = async (inline: string | undefined, file: string | undefined) =>\n inline !== undefined || file === undefined\n ? inline\n : await readRegularInputFile(\n resolveInputPath(file, directory),\n repository,\n );\n const [scanPrompt, validationPrompt, postScanPrompt] = await Promise.all([\n read(options.scanPrompt, options.scanPromptFile),\n read(options.validationPrompt, options.validationPromptFile),\n read(options.postScanPrompt, options.postScanPromptFile),\n ]);\n if (\n options.validationPrompt === undefined &&\n validationPrompt !== undefined &&\n !validationPrompt.trim()\n ) {\n throw new CodexSecurityError(\"The validation prompt must not be empty.\");\n }\n return {\n scanPrompt:\n options.scanPrompt !== undefined || scanPrompt?.trim()\n ? scanPrompt\n : undefined,\n validationPrompt,\n postScanPrompt:\n options.postScanPrompt !== undefined || postScanPrompt?.trim()\n ? postScanPrompt\n : undefined,\n // Spreading the resolved prompts back into options must clear file inputs,\n // including blank files, so later preparation does not read them again.\n scanPromptFile: undefined,\n validationPromptFile: undefined,\n postScanPromptFile: undefined,\n };\n}\n\n/** A selected source cannot use a directory link to supply a document outside it. */\nexport async function checkDocumentPath(\n path: string,\n canonical: string,\n source: DocumentRootSource,\n signal?: AbortSignal,\n): Promise<void> {\n if (path === canonical) return;\n const roots = typeof source === \"function\" ? await source() : source;\n const outside = roots?.filter((root) => !isWithin(root, canonical));\n if (outside?.length === 0) return;\n\n const directories = new Set([dirname(path)]);\n for (const directory of directories) {\n const parsed = parse(directory);\n if (!parsed.base) continue;\n directories.add(parsed.dir);\n signal?.throwIfAborted();\n // A trailing slash would make lstat follow the link. Keep any raw \"..\".\n const entry = format(parsed);\n if (!(await lstat(entry)).isSymbolicLink()) continue;\n if (!outside) {\n throw new CodexSecurityError(\n \"Select the document by its canonical path when the source checkout is unknown.\",\n );\n }\n const owner = await realpath(await resolveParentTraversal(parsed.dir));\n if (outside.some((root) => isWithin(root, owner))) {\n throw new CodexSecurityError(\n `Input files must not follow repository directory links outside the selected repository: ${entry}`,\n );\n }\n // An external alias can point through a directory link inside a checkout.\n const target = await readlink(entry);\n directories.add(isAbsolute(target) ? target : `${owner}${sep}${target}`);\n }\n}\n\nexport async function readRegularInputFile(\n path: string,\n repository: string | DocumentRootSource,\n metadata?: Pick<BigIntStats, \"isFile\" | \"dev\" | \"ino\">,\n): Promise<string> {\n const selected = metadata ?? (await lstat(path, { bigint: true }));\n if (!selected.isFile()) {\n throw new CodexSecurityError(\"Input files must be regular files.\");\n }\n const canonical = join(\n await realpath(await resolveParentTraversal(dirname(path))),\n basename(path),\n );\n const roots = typeof repository === \"string\" ? [repository] : repository;\n await checkDocumentPath(\n path,\n canonical,\n Array.isArray(roots)\n ? await Promise.all(\n roots.map(async (root: string) =>\n realpath(await resolveParentTraversal(root)),\n ),\n )\n : roots,\n );\n const file = await open(\n canonical,\n constants.O_RDONLY |\n (constants.O_NOFOLLOW ?? 0) |\n (constants.O_NONBLOCK ?? 0),\n );\n try {\n const opened = await file.stat({ bigint: true });\n if (\n !opened.isFile() ||\n opened.dev !== selected.dev ||\n opened.ino !== selected.ino\n ) {\n throw new CodexSecurityError(\"Input files must remain regular files.\");\n }\n return await file.readFile({ encoding: \"utf8\" });\n } finally {\n await file.close();\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-profile.d.ts","sourceRoot":"","sources":["../src/provider-profile.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAI7D,OAAO,EAOL,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAKL,4BAA4B,EAG5B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,sFAAsF;AACtF,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,YAAY,CAAC,CA6BvB;AAED,uFAAuF;AACvF,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,UAAU,GACjB,UAAU,CAeZ;AAED,6EAA6E;AAC7E,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,UAAU,EAClB,OAAO,GAAE,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAC,CAAC,CAAC,GAAG;IAC5D,MAAM,CAAC,EAAE,OAAO,CAAC;CACb,GACL,OAAO,CAAC,eAAe,CAAC,CAuB1B;AAED,sFAAsF;AACtF,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,kBAAkB,GAC9B,OAAO,CAAC,UAAU,CAAC,CAiDrB;AAED,yEAAyE;AACzE,wBAAsB,kBAAkB,CACtC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AAC;CACb,GACL,OAAO,CAAC,eAAe,CAAC,CAuB1B;AAED,sFAAsF;AACtF,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,kBAAkB,GAC9B,OAAO,CAAC,UAAU,CAAC,CAiDrB;AAED,yEAAyE;AACzE,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,MAAM,EACnB,0BAA0B,CAAC,EAAE,MAAM,GAClC,OAAO,CAAC,KAAK,CAAC,CAahB;AAED,sFAAsF;AACtF,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,YAAY,EACrB,eAAe,EAAE,UAAU,EAC3B,cAAc,EAAE,UAAU,EAC1B,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC;IAAE,mBAAmB,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA6CrE;AAED,wBAAsB,sBAAsB,CAAC,CAAC,EAC5C,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EACvC,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAC1B,OAAO,CAAC,CAAC,CAAC,CAiBZ;AAED,wBAAsB,yBAAyB,iBAU9C;AAED,wBAAsB,mBAAmB,iBAMxC"}
|
package/dist/provider-profile.js
CHANGED
|
@@ -15,7 +15,7 @@ import { configuredCodexHome } from "./auth.js";
|
|
|
15
15
|
import { CodexSecurityError } from "./errors.js";
|
|
16
16
|
import { resolveCodexProfile, deepMerge, modelProviderConfigOverride, inlineToml, writeCodexConfig, writePrivateConfig, } from "./config.js";
|
|
17
17
|
import { isRecord } from "./record.js";
|
|
18
|
-
import {
|
|
18
|
+
import { nativeCodexLaunch } from "./codex-sdk-environment.js";
|
|
19
19
|
import { bundledPluginRoot, acquireCodexSecurityCredentialHomeLock, codexSecurityCredentialHome, executablePathForSpawn, requirePrivateCredentialHome, requireSecureCredentialHome, resolveCodexCommand, } from "./runtime.js";
|
|
20
20
|
/** Keep provider metadata, analytics consent, and attribution on no-turn commands. */
|
|
21
21
|
export async function providerPreflightCommand(command, config) {
|
|
@@ -122,16 +122,14 @@ export async function restoreProviderProfile(config, profile, environment) {
|
|
|
122
122
|
}
|
|
123
123
|
/** The pinned SDK lacks the native CLI's private profile-file option. */
|
|
124
124
|
export async function createProfileCodex(options, profileName, requestedPermissionProfile) {
|
|
125
|
-
const command = options.codexPathOverride ?? resolveCodexCommand(options.env).command;
|
|
125
|
+
const { command, environment } = await nativeCodexLaunch(options.codexPathOverride ?? resolveCodexCommand(options.env).command, options.env);
|
|
126
126
|
const client = await nativeProfileClient();
|
|
127
127
|
return client.createCodexProfileClient({
|
|
128
128
|
...options,
|
|
129
129
|
codexPathOverride: executablePathForSpawn(command),
|
|
130
130
|
profileName,
|
|
131
131
|
requestedPermissionProfile,
|
|
132
|
-
|
|
133
|
-
? {}
|
|
134
|
-
: { env: bundledCodexSdkEnvironment(command, options.env) }),
|
|
132
|
+
env: environment,
|
|
135
133
|
});
|
|
136
134
|
}
|
|
137
135
|
/** Verify the effective helper policy before starting exec with a private profile. */
|
|
@@ -143,15 +141,12 @@ export async function preflightReadOnlyProfileCodex(options, expectedProfile, pr
|
|
|
143
141
|
`default_permissions=${JSON.stringify(permissionProfileId)}`,
|
|
144
142
|
`permissions.${permissionProfileId}=${inlineToml(expectedProfile)}`,
|
|
145
143
|
];
|
|
146
|
-
const command = options.codexPathOverride ?? resolveCodexCommand(options.env).command;
|
|
144
|
+
const { command, environment: env } = await nativeCodexLaunch(options.codexPathOverride ?? resolveCodexCommand(options.env).command, options.env);
|
|
147
145
|
const client = await nativeProfileClient();
|
|
148
146
|
const providers = resolveCodexProfile(providerConfig)["model_providers"];
|
|
149
147
|
const definitions = isRecord(providers)
|
|
150
148
|
? client.preflightProviderDefinitions(providers)
|
|
151
149
|
: {};
|
|
152
|
-
const env = options.env === undefined
|
|
153
|
-
? undefined
|
|
154
|
-
: bundledCodexSdkEnvironment(command, options.env);
|
|
155
150
|
await withCodexPreflightLock(env, signal, async () => {
|
|
156
151
|
await preflight.preflightDeepScanWorkerPermissionProfile({
|
|
157
152
|
codexPath: executablePathForSpawn(command),
|