@openai/codex-security 0.1.31 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +442 -2434
- package/_bundled_plugin/.app.json +5 -1
- package/_bundled_plugin/.codex-plugin/plugin.json +9 -5
- package/_bundled_plugin/.mcp.json +3 -0
- package/_bundled_plugin/examples/completed-scan/coverage.json +0 -1
- package/_bundled_plugin/examples/completed-scan/report.md +28 -26
- package/_bundled_plugin/examples/completed-scan/scan-manifest.json +1 -1
- package/_bundled_plugin/mcp/helpers.mjs +1 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +7 -214
- 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 +563 -0
- package/_bundled_plugin/mcp/server.mjs +1 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/preflight/capability-profiles.toml +0 -13
- package/_bundled_plugin/references/artifact-storage.md +5 -5
- package/_bundled_plugin/references/config-preflight.md +1 -5
- package/_bundled_plugin/references/core-scan.md +34 -10
- package/_bundled_plugin/references/final-report.md +13 -13
- package/_bundled_plugin/references/finding-detail-fields.md +90 -80
- package/_bundled_plugin/references/sarif-adapter.md +1 -1
- package/_bundled_plugin/references/scan-artifacts.md +3 -4
- package/_bundled_plugin/references/scan-contract.md +11 -6
- package/_bundled_plugin/references/scan-prologue.md +12 -0
- package/_bundled_plugin/references/security-guidance.md +2 -2
- package/_bundled_plugin/references/standalone-validation.md +11 -0
- package/_bundled_plugin/references/threat-model.md +2 -2
- package/_bundled_plugin/schemas/coverage.schema.json +23 -47
- package/_bundled_plugin/schemas/definitions/artifact-common.schema.json +2 -24
- package/_bundled_plugin/schemas/definitions/discovery-candidate.schema.json +49 -25
- package/_bundled_plugin/schemas/findings.schema.json +71 -192
- package/_bundled_plugin/schemas/scan-manifest.schema.json +83 -95
- package/_bundled_plugin/schemas/tools/candidate-attack-paths.schema.json +91 -83
- package/_bundled_plugin/schemas/tools/candidate-validations.schema.json +35 -64
- package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +5 -2
- package/_bundled_plugin/schemas/tools/discovery-candidates.schema.json +6 -55
- package/_bundled_plugin/schemas/tools/review-items.schema.json +2 -38
- package/_bundled_plugin/schemas/tools/scan-draft.schema.json +245 -356
- package/_bundled_plugin/scripts/codex_profile.mjs +239 -0
- package/_bundled_plugin/scripts/codex_session.mjs +53 -0
- package/_bundled_plugin/scripts/config_preflight.py +29 -69
- package/_bundled_plugin/scripts/deep_scan_config.py +9 -11
- package/_bundled_plugin/scripts/deep_scan_workbench.py +208 -363
- package/_bundled_plugin/scripts/filesystem_identity.py +1 -5
- package/_bundled_plugin/scripts/finalize_scan_contract.py +733 -375
- package/_bundled_plugin/scripts/finding_preview.py +81 -91
- package/_bundled_plugin/scripts/generate_in_scope_files.py +48 -102
- package/_bundled_plugin/scripts/generate_rank_input.py +117 -888
- package/_bundled_plugin/scripts/launch_codex_security_mcp +35 -6
- package/_bundled_plugin/scripts/launch_codex_security_mcp.cmd +5 -5
- package/_bundled_plugin/scripts/rank_preview.py +43 -902
- package/_bundled_plugin/scripts/report_projection.py +143 -219
- package/_bundled_plugin/scripts/snapshot_sqlite.py +6 -1
- package/_bundled_plugin/scripts/threat_model_projection.py +161 -0
- package/_bundled_plugin/scripts/validate_scan_contract.py +4 -34
- package/_bundled_plugin/scripts/validate_tracking_source.py +3 -13
- package/_bundled_plugin/scripts/windows_scan_local_files.py +59 -9
- package/_bundled_plugin/scripts/workbench/handoff.py +25 -50
- package/_bundled_plugin/scripts/workbench/runtime_toml.py +22 -0
- package/_bundled_plugin/scripts/workbench/storage.py +21 -6
- package/_bundled_plugin/scripts/workbench_cli.py +99 -190
- package/_bundled_plugin/scripts/workbench_constants.py +6 -14
- package/_bundled_plugin/scripts/workbench_db.py +524 -672
- package/_bundled_plugin/scripts/workbench_feedback.py +6 -3
- package/_bundled_plugin/scripts/workbench_finding_index.py +20 -7
- package/_bundled_plugin/scripts/workbench_finding_workflows.py +18 -4
- package/_bundled_plugin/scripts/workbench_local_dedupe.py +136 -0
- package/_bundled_plugin/scripts/workbench_native_indexes.py +28 -18
- package/_bundled_plugin/scripts/workbench_progress.py +26 -92
- package/_bundled_plugin/scripts/workbench_publication.py +77 -116
- package/_bundled_plugin/scripts/workbench_remediation.py +14 -20
- package/_bundled_plugin/scripts/workbench_saved_results.py +1402 -263
- package/_bundled_plugin/scripts/workbench_scan_history.py +57 -57
- package/_bundled_plugin/scripts/workbench_scan_start.py +109 -52
- package/_bundled_plugin/scripts/workbench_scan_usage.py +30 -49
- package/_bundled_plugin/scripts/workbench_schema.py +71 -1370
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +16 -7
- package/_bundled_plugin/scripts/workbench_target.py +526 -150
- package/_bundled_plugin/scripts/workbench_target_state.py +1 -5
- package/_bundled_plugin/scripts/workbench_validation.py +19 -44
- package/_bundled_plugin/shared/workbench-history-repairs.json +218 -0
- package/_bundled_plugin/shared/workbench-migrations.json +397 -0
- package/_bundled_plugin/skills/assess-patch-risk/SKILL.md +15 -4
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +1 -0
- package/_bundled_plugin/skills/cloud-findings/SKILL.md +54 -0
- package/_bundled_plugin/skills/cloud-findings/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +6 -6
- package/_bundled_plugin/skills/deep-security-scan/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/finding-discovery/SKILL.md +3 -3
- package/_bundled_plugin/skills/propose-security-hardening/references/proposal-format.md +50 -20
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +8 -14
- package/_bundled_plugin/skills/security-diff-scan/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/security-scan/SKILL.md +22 -7
- package/_bundled_plugin/skills/security-scan/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +2 -2
- package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +13 -1
- package/_bundled_plugin/skills/threat-model/SKILL.md +2 -2
- package/_bundled_plugin/skills/track-findings/SKILL.md +46 -178
- package/_bundled_plugin/skills/track-findings/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/track-findings/references/github-security-advisories.md +16 -24
- package/_bundled_plugin/skills/track-findings/references/jira.md +15 -61
- package/_bundled_plugin/skills/triage-finding/SKILL.md +50 -289
- package/_bundled_plugin/skills/triage-finding/agents/openai.yaml +2 -2
- package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +23 -43
- package/_bundled_plugin/skills/triage-finding/references/triage-result-contract.md +7 -1
- package/bin/codex-security.mjs +9 -2
- package/dist/api.d.ts +63 -15
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +970 -553
- package/dist/api.js.map +1 -1
- package/dist/artifact-export.d.ts +70 -0
- package/dist/artifact-export.d.ts.map +1 -0
- package/dist/artifact-export.js +292 -0
- package/dist/artifact-export.js.map +1 -0
- package/dist/auth.d.ts +2 -6
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +27 -12
- package/dist/auth.js.map +1 -1
- package/dist/bulk-scan-discovery.d.ts +1 -0
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +9 -9
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/classify-scan-severity.d.ts.map +1 -1
- package/dist/classify-scan-severity.js +2 -5
- package/dist/classify-scan-severity.js.map +1 -1
- package/dist/classify-severity.d.ts +28 -17
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +16 -35
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-help.d.ts +3 -0
- package/dist/cli-help.d.ts.map +1 -0
- package/dist/cli-help.js +285 -0
- package/dist/cli-help.js.map +1 -0
- package/dist/cli-signals.d.ts +8 -0
- package/dist/cli-signals.d.ts.map +1 -0
- package/dist/cli-signals.js +28 -0
- package/dist/cli-signals.js.map +1 -0
- package/dist/cli.d.ts +22 -24
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1660 -1556
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +11 -17
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codeowners.d.ts +19 -0
- package/dist/codeowners.d.ts.map +1 -0
- package/dist/codeowners.js +138 -0
- package/dist/codeowners.js.map +1 -0
- package/dist/codex-prompt.d.ts.map +1 -1
- package/dist/codex-prompt.js +1 -2
- package/dist/codex-prompt.js.map +1 -1
- package/dist/codex-sdk-environment.d.ts +3 -0
- package/dist/codex-sdk-environment.d.ts.map +1 -0
- package/dist/codex-sdk-environment.js +68 -0
- package/dist/codex-sdk-environment.js.map +1 -0
- package/dist/component-plan.d.ts +2 -5
- package/dist/component-plan.d.ts.map +1 -1
- package/dist/component-plan.js +38 -34
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.d.ts +7 -5
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +54 -44
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +93 -104
- package/dist/config.js.map +1 -1
- package/dist/contract.d.ts +15 -2
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +124 -348
- package/dist/contract.js.map +1 -1
- package/dist/cost-model.d.ts +13 -6
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +75 -34
- package/dist/cost-model.js.map +1 -1
- package/dist/cost.d.ts +10 -2
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +116 -134
- package/dist/cost.js.map +1 -1
- package/dist/custom-validation-prompt.d.ts.map +1 -1
- package/dist/custom-validation-prompt.js +7 -6
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/custom-validation.d.ts +1 -2
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +23 -16
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/checkpointed-review.d.ts +4 -2
- package/dist/deduplication/checkpointed-review.d.ts.map +1 -1
- package/dist/deduplication/checkpointed-review.js +33 -20
- package/dist/deduplication/checkpointed-review.js.map +1 -1
- package/dist/deduplication/codex-review.d.ts +9 -1
- package/dist/deduplication/codex-review.d.ts.map +1 -1
- package/dist/deduplication/codex-review.js +129 -20
- package/dist/deduplication/codex-review.js.map +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts +5 -2
- package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
- package/dist/deduplication/deduplication-prompts.js +18 -4
- package/dist/deduplication/deduplication-prompts.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts +26 -4
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
- package/dist/deduplication/deduplication-reviewer.js +59 -47
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/deduplication.d.ts.map +1 -1
- package/dist/deduplication/deduplication.js +59 -113
- package/dist/deduplication/deduplication.js.map +1 -1
- package/dist/deduplication/diagnostics.d.ts +17 -0
- package/dist/deduplication/diagnostics.d.ts.map +1 -0
- package/dist/deduplication/diagnostics.js +5 -0
- package/dist/deduplication/diagnostics.js.map +1 -0
- package/dist/deduplication/finding-schema.d.ts.map +1 -1
- package/dist/deduplication/finding-schema.js +7 -1
- package/dist/deduplication/finding-schema.js.map +1 -1
- package/dist/deduplication/local.d.ts +31 -0
- package/dist/deduplication/local.d.ts.map +1 -0
- package/dist/deduplication/local.js +166 -0
- package/dist/deduplication/local.js.map +1 -0
- package/dist/deduplication/records-protocol.d.ts.map +1 -1
- package/dist/deduplication/records-protocol.js +12 -28
- package/dist/deduplication/records-protocol.js.map +1 -1
- package/dist/deduplication/records.d.ts +188 -12
- package/dist/deduplication/records.d.ts.map +1 -1
- package/dist/deduplication/records.js +34 -24
- package/dist/deduplication/records.js.map +1 -1
- package/dist/deduplication/review.d.ts +7 -0
- package/dist/deduplication/review.d.ts.map +1 -1
- package/dist/deduplication/review.js.map +1 -1
- package/dist/deduplication/scan.d.ts +9 -3
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +159 -44
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-config.d.ts +2 -1
- package/dist/deep-config.d.ts.map +1 -1
- package/dist/deep-config.js +7 -23
- package/dist/deep-config.js.map +1 -1
- package/dist/deep-progress.d.ts +2 -1
- package/dist/deep-progress.d.ts.map +1 -1
- package/dist/deep-progress.js +32 -47
- package/dist/deep-progress.js.map +1 -1
- package/dist/deep-scan.d.ts +20 -0
- package/dist/deep-scan.d.ts.map +1 -0
- package/dist/deep-scan.js +113 -0
- package/dist/deep-scan.js.map +1 -0
- package/dist/errors.d.ts +5 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +7 -7
- package/dist/errors.js.map +1 -1
- package/dist/feedback.d.ts.map +1 -1
- package/dist/feedback.js +53 -21
- package/dist/feedback.js.map +1 -1
- package/dist/finding-catalogue.d.ts.map +1 -1
- package/dist/finding-catalogue.js +26 -30
- package/dist/finding-catalogue.js.map +1 -1
- package/dist/finding-normalization.d.ts +5 -0
- package/dist/finding-normalization.d.ts.map +1 -0
- package/dist/finding-normalization.js +120 -0
- package/dist/finding-normalization.js.map +1 -0
- package/dist/finding-retrieval.d.ts +9 -0
- package/dist/finding-retrieval.d.ts.map +1 -1
- package/dist/finding-retrieval.js.map +1 -1
- package/dist/finding-workflow.d.ts +13 -8
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js +18 -13
- package/dist/finding-workflow.js.map +1 -1
- package/dist/findings-client.d.ts +2 -1
- package/dist/findings-client.d.ts.map +1 -1
- package/dist/findings-client.js +36 -9
- package/dist/findings-client.js.map +1 -1
- package/dist/findings-errors.d.ts +16 -0
- package/dist/findings-errors.d.ts.map +1 -0
- package/dist/findings-errors.js +24 -0
- package/dist/findings-errors.js.map +1 -0
- package/dist/findings-import.d.ts +1 -1
- package/dist/findings-import.d.ts.map +1 -1
- package/dist/findings-import.js +16 -44
- package/dist/findings-import.js.map +1 -1
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +9 -4
- package/dist/github.js.map +1 -1
- package/dist/import-scan.d.ts.map +1 -1
- package/dist/import-scan.js +49 -39
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +11 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.d.ts +7 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +115 -47
- package/dist/knowledge-base.js.map +1 -1
- package/dist/linear.d.ts.map +1 -1
- package/dist/linear.js +4 -10
- package/dist/linear.js.map +1 -1
- package/dist/mock-scan.d.ts.map +1 -1
- package/dist/mock-scan.js +0 -1
- package/dist/mock-scan.js.map +1 -1
- package/dist/models.d.ts +24 -2
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/multiscan.d.ts +9 -3
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +225 -153
- package/dist/multiscan.js.map +1 -1
- package/dist/owner-evidence.d.ts +10 -2
- package/dist/owner-evidence.d.ts.map +1 -1
- package/dist/owner-evidence.js +69 -14
- package/dist/owner-evidence.js.map +1 -1
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +5 -6
- package/dist/patch-tui.js.map +1 -1
- package/dist/project-config-schema.d.ts +10 -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 +5 -3
- package/dist/project-config.js.map +1 -1
- package/dist/prompt-files.d.ts +0 -1
- package/dist/prompt-files.d.ts.map +1 -1
- package/dist/prompt-files.js +2 -4
- package/dist/prompt-files.js.map +1 -1
- package/dist/provider-profile.d.ts +21 -0
- package/dist/provider-profile.d.ts.map +1 -0
- package/dist/provider-profile.js +133 -0
- package/dist/provider-profile.js.map +1 -0
- package/dist/publication-events.d.ts +6 -8
- package/dist/publication-events.d.ts.map +1 -1
- package/dist/publication-events.js +40 -79
- package/dist/publication-events.js.map +1 -1
- package/dist/publication-store.d.ts.map +1 -1
- package/dist/publication-store.js +48 -76
- package/dist/publication-store.js.map +1 -1
- package/dist/publication.d.ts +1 -2
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js +7 -16
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts +1 -5
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +138 -199
- package/dist/publish.js.map +1 -1
- package/dist/record.d.ts +2 -0
- package/dist/record.d.ts.map +1 -0
- package/dist/record.js +4 -0
- package/dist/record.js.map +1 -0
- package/dist/request-metadata.d.ts +9 -0
- package/dist/request-metadata.d.ts.map +1 -0
- package/dist/request-metadata.js +13 -0
- package/dist/request-metadata.js.map +1 -0
- package/dist/result.d.ts +4 -1
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +7 -0
- package/dist/result.js.map +1 -1
- package/dist/runtime.d.ts +25 -17
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +619 -255
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan-bootstrap.d.ts +14 -0
- package/dist/saved-scan-bootstrap.d.ts.map +1 -0
- package/dist/saved-scan-bootstrap.js +261 -0
- package/dist/saved-scan-bootstrap.js.map +1 -0
- package/dist/saved-scan.d.ts +1 -1
- package/dist/saved-scan.d.ts.map +1 -1
- package/dist/saved-scan.js +16 -32
- package/dist/saved-scan.js.map +1 -1
- package/dist/scan-activity.d.ts.map +1 -1
- package/dist/scan-activity.js +19 -30
- package/dist/scan-activity.js.map +1 -1
- package/dist/scan-comparison.d.ts +31 -18
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +307 -347
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +3 -1
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +351 -92
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +55 -15
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-inputs.d.ts +6 -0
- package/dist/scan-inputs.d.ts.map +1 -0
- package/dist/scan-inputs.js +71 -0
- package/dist/scan-inputs.js.map +1 -0
- package/dist/scan-logs.d.ts +2 -3
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +14 -12
- package/dist/scan-logs.js.map +1 -1
- package/dist/scan-sessions.d.ts +4 -0
- package/dist/scan-sessions.d.ts.map +1 -1
- package/dist/scan-sessions.js +18 -3
- package/dist/scan-sessions.js.map +1 -1
- package/dist/scan-settings.d.ts +5 -0
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +4 -0
- package/dist/scan-settings.js.map +1 -1
- package/dist/scan-skill-paths.d.ts +8 -0
- package/dist/scan-skill-paths.d.ts.map +1 -0
- package/dist/scan-skill-paths.js +47 -0
- package/dist/scan-skill-paths.js.map +1 -0
- package/dist/security-policy-cli.d.ts.map +1 -1
- package/dist/security-policy-cli.js +15 -33
- package/dist/security-policy-cli.js.map +1 -1
- package/dist/security-policy.d.ts +17 -9
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js +131 -98
- package/dist/security-policy.js.map +1 -1
- package/dist/server/api.d.ts +0 -1
- package/dist/server/api.d.ts.map +1 -1
- package/dist/server/api.js +0 -1
- package/dist/server/api.js.map +1 -1
- package/dist/server/embeddings.d.ts +3 -1
- package/dist/server/embeddings.d.ts.map +1 -1
- package/dist/server/embeddings.js +11 -3
- package/dist/server/embeddings.js.map +1 -1
- package/dist/server/errors.d.ts +5 -2
- package/dist/server/errors.d.ts.map +1 -1
- package/dist/server/errors.js +7 -0
- package/dist/server/errors.js.map +1 -1
- package/dist/server/sqlite-store.d.ts +0 -2
- package/dist/server/sqlite-store.d.ts.map +1 -1
- package/dist/server/sqlite-store.js +55 -55
- package/dist/server/sqlite-store.js.map +1 -1
- package/dist/server/storage.d.ts +0 -2
- package/dist/server/storage.d.ts.map +1 -1
- package/dist/server/storage.js.map +1 -1
- package/dist/severity-store.js +20 -32
- package/dist/severity-store.js.map +1 -1
- package/dist/standalone-validation-prompt.d.ts +2 -0
- package/dist/standalone-validation-prompt.d.ts.map +1 -0
- package/dist/standalone-validation-prompt.js +10 -0
- package/dist/standalone-validation-prompt.js.map +1 -0
- package/dist/suggest-owners.d.ts +6 -5
- package/dist/suggest-owners.d.ts.map +1 -1
- package/dist/suggest-owners.js +15 -10
- package/dist/suggest-owners.js.map +1 -1
- package/dist/targets.d.ts +12 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +124 -62
- package/dist/targets.js.map +1 -1
- package/dist/trusted-executable.d.ts +6 -1
- package/dist/trusted-executable.d.ts.map +1 -1
- package/dist/trusted-executable.js +28 -9
- package/dist/trusted-executable.js.map +1 -1
- package/dist/value.d.ts +2 -0
- package/dist/value.d.ts.map +1 -0
- package/dist/value.js +27 -0
- package/dist/value.js.map +1 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +3 -6
- package/dist/version.js.map +1 -1
- package/dist/windows-path.d.ts.map +1 -1
- package/dist/windows-path.js +1 -2
- package/dist/windows-path.js.map +1 -1
- package/dist/workbench-arguments.d.ts +3 -0
- package/dist/workbench-arguments.d.ts.map +1 -0
- package/dist/workbench-arguments.js +15 -0
- package/dist/workbench-arguments.js.map +1 -0
- package/dist/worker-progress.d.ts +2 -0
- package/dist/worker-progress.d.ts.map +1 -1
- package/dist/worker-progress.js +40 -46
- package/dist/worker-progress.js.map +1 -1
- package/docs/cli.md +1778 -0
- package/docs/dedupe-records.md +24 -0
- package/docs/findings-service.md +402 -0
- package/package.json +23 -23
- package/schemas/project-config.schema.json +5 -0
- package/_bundled_plugin/schemas/tools/worker-threat-model.schema.json +0 -18
- package/_bundled_plugin/scripts/normalize_candidates.py +0 -338
- package/_bundled_plugin/scripts/workbench_dashboard.py +0 -159
- package/_bundled_plugin/scripts/workbench_findings.py +0 -221
- package/_bundled_plugin/scripts/workbench_severity.py +0 -119
- package/_bundled_plugin/skills/assess-patch-risk/scripts/validate_patch_risk_assessment.py +0 -163
- package/dist/server/dashboard/THIRD_PARTY_NOTICES.txt +0 -276
- package/dist/server/dashboard/app.css +0 -2
- package/dist/server/dashboard/app.js +0 -66
- package/dist/server/dashboard/index.html +0 -18
- package/dist/server/dashboard-types.d.ts +0 -48
- package/dist/server/dashboard-types.d.ts.map +0 -1
- package/dist/server/dashboard-types.js +0 -2
- package/dist/server/dashboard-types.js.map +0 -1
- package/dist/server/dashboard.d.ts +0 -6
- package/dist/server/dashboard.d.ts.map +0 -1
- package/dist/server/dashboard.js +0 -59
- package/dist/server/dashboard.js.map +0 -1
- package/dist/server/findings-service.d.ts +0 -20
- package/dist/server/findings-service.d.ts.map +0 -1
- package/dist/server/findings-service.js +0 -31
- package/dist/server/findings-service.js.map +0 -1
- package/dist/server/index.d.ts +0 -2
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/index.js +0 -6
- package/dist/server/index.js.map +0 -1
- package/dist/server/routes.d.ts +0 -6
- package/dist/server/routes.d.ts.map +0 -1
- package/dist/server/routes.js +0 -86
- package/dist/server/routes.js.map +0 -1
- package/dist/server/serve.d.ts +0 -2
- package/dist/server/serve.d.ts.map +0 -1
- package/dist/server/serve.js +0 -28
- package/dist/server/serve.js.map +0 -1
- package/dist/server/server.d.ts +0 -10
- package/dist/server/server.d.ts.map +0 -1
- package/dist/server/server.js +0 -17
- package/dist/server/server.js.map +0 -1
- package/dist/server/validation.d.ts +0 -17
- package/dist/server/validation.d.ts.map +0 -1
- package/dist/server/validation.js +0 -53
- package/dist/server/validation.js.map +0 -1
|
@@ -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,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GAEpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAqB,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAwB,MAAM,kBAAkB,CAAC;AACzE,OAAO,EACL,uBAAuB,GAGxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GAIjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AAE3D,MAAM,qBAAqB,GAAG,IAAI,GAAG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AO,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 { parseDocument } from \"yaml\";\nimport {\n DEFAULT_CODEX_CONFIG,\n mergeCodexOverrides,\n type JsonObject,\n} from \"./config.js\";\nimport { ConfigurationError } 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 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}.`,\n { cause: error },\n );\n }\n let value: unknown;\n try {\n if (extension === \".json\") {\n value = JSON.parse(text);\n } else {\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}.`,\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(\".\") ? \"\" : \"./\"}${relativeSchema\n .split(sep)\n .join(\"/\")}`;\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 \"# deep: # Used when mode is deep.\",\n ...DEEP_SCAN_SETTINGS.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({ ...overrides, mode });\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 deep: DeepScanOptions = {};\n if (mode === \"deep\") {\n for (const [name, , field] of DEEP_SCAN_SETTINGS) {\n const value = choose(\n `scan.deep.${field}`,\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 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 delete sources[path];\n recordNativeSources(item, source, path);\n } else {\n for (const existing of Object.keys(sources) as ProvenanceKey[]) {\n if (existing.startsWith(`${path}.`)) delete sources[existing];\n }\n sources[path] = source;\n }\n }\n };\n recordNativeSources(DEFAULT_CODEX_CONFIG, \"default\");\n recordNativeSources(file?.codex ?? {}, \"project\");\n recordNativeSources(overrides.codexOverrides ?? {}, \"cli\");\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 mode,\n target,\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,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,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GAEpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAA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;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 { parseDocument } from \"yaml\";\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 cyberAccessProgram: \"scan.cyber_access_program\",\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);\n } else {\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(\".\") ? \"\" : \"./\"}${relativeSchema\n .split(sep)\n .join(\"/\")}`;\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 \"# deep: # Used when mode is deep.\",\n ...DEEP_SCAN_SETTINGS.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({ ...overrides, mode });\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 deep: DeepScanOptions = {};\n if (mode === \"deep\") {\n for (const [name, , field] of DEEP_SCAN_SETTINGS) {\n const value = choose(\n `scan.deep.${field}`,\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 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 delete sources[path];\n recordNativeSources(item, source, path);\n } else {\n for (const existing of Object.keys(sources) as ProvenanceKey[]) {\n if (existing.startsWith(`${path}.`)) delete sources[existing];\n }\n sources[path] = source;\n }\n }\n };\n recordNativeSources(DEFAULT_CODEX_CONFIG, \"default\");\n recordNativeSources(file?.codex ?? {}, \"project\");\n recordNativeSources(overrides.codexOverrides ?? {}, \"cli\");\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 target,\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"]}
|
package/dist/prompt-files.d.ts
CHANGED
|
@@ -8,6 +8,5 @@ type ResolvedScanPrompts = Pick<ScanPromptSettings, "scanPrompt" | "validationPr
|
|
|
8
8
|
/** Resolve selected files once; an inline SDK prompt overrides its file. */
|
|
9
9
|
export declare function resolveScanPrompts(options: ScanPromptSettings, repository: string | readonly string[], directory?: string): Promise<ResolvedScanPrompts>;
|
|
10
10
|
export declare function readRegularInputFile(path: string, repository: string | readonly string[], metadata?: Pick<BigIntStats, "isFile" | "dev" | "ino">): Promise<string>;
|
|
11
|
-
export declare function isOutsidePath(path: string): boolean;
|
|
12
11
|
export {};
|
|
13
12
|
//# 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;AAMtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,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,SAAS,MAAM,EAAE,EACtC,SAAS,SAAgB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAoC9B;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EACtC,QAAQ,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC,GACrD,OAAO,CAAC,MAAM,CAAC,CA4CjB"}
|
package/dist/prompt-files.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { constants } from "node:fs";
|
|
2
2
|
import { lstat, open, realpath } from "node:fs/promises";
|
|
3
|
-
import { basename, dirname,
|
|
3
|
+
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
4
4
|
import { CodexSecurityError } from "./errors.js";
|
|
5
5
|
import { expandHome } from "./runtime.js";
|
|
6
|
+
import { relativePathIsOutside as isOutsidePath } from "./targets.js";
|
|
6
7
|
/** Resolve selected files once; an inline SDK prompt overrides its file. */
|
|
7
8
|
export async function resolveScanPrompts(options, repository, directory = process.cwd()) {
|
|
8
9
|
const read = async (inline, file) => inline !== undefined || file === undefined
|
|
@@ -68,7 +69,4 @@ export async function readRegularInputFile(path, repository, metadata) {
|
|
|
68
69
|
await file.close();
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
|
-
export function isOutsidePath(path) {
|
|
72
|
-
return path === ".." || path.startsWith(`..${sep}`) || isAbsolute(path);
|
|
73
|
-
}
|
|
74
72
|
//# sourceMappingURL=prompt-files.js.map
|
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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;IACrB,CAAC;AACH,CAAC","sourcesContent":["import { constants, type BigIntStats } from \"node:fs\";\nimport { lstat, open, realpath } from \"node:fs/promises\";\nimport { basename, dirname, join, relative, resolve } from \"node:path\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport { expandHome } from \"./runtime.js\";\nimport { relativePathIsOutside as isOutsidePath } from \"./targets.js\";\nimport type { ScanPromptSettings } from \"./scan-settings.js\";\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 | readonly string[],\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 resolve(directory, expandHome(file)),\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\nexport async function readRegularInputFile(\n path: string,\n repository: string | readonly string[],\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 canonicalParent = await realpath(dirname(path));\n const repositories =\n typeof repository === \"string\" ? [repository] : repository;\n for (const repository of repositories) {\n const canonicalRepository = await realpath(repository);\n if (isOutsidePath(relative(canonicalRepository, canonicalParent))) {\n for (let ancestor = dirname(path); ; ancestor = dirname(ancestor)) {\n if (\n !isOutsidePath(\n relative(canonicalRepository, await realpath(ancestor)),\n )\n ) {\n throw new CodexSecurityError(\n \"Input files must not follow repository directory links outside the selected repository.\",\n );\n }\n if (dirname(ancestor) === ancestor) break;\n }\n }\n }\n const file = await open(\n join(canonicalParent, basename(path)),\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"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Codex, CodexOptions } from "@openai/codex-sdk";
|
|
2
|
+
import { type JsonObject } from "./config.js";
|
|
3
|
+
import { requirePrivateCredentialHome, type CodexCommand } from "./runtime.js";
|
|
4
|
+
export interface ProviderProfile {
|
|
5
|
+
name: string;
|
|
6
|
+
path: string;
|
|
7
|
+
cleanup(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
/** Native no-turn commands need provider metadata when managed policy selects it. */
|
|
10
|
+
export declare function providerPreflightCommand(command: CodexCommand, config: JsonObject): Promise<CodexCommand>;
|
|
11
|
+
/** Provider definitions use a native file layer, never process arguments. */
|
|
12
|
+
export declare function createProviderProfile(codexHome: string, config: JsonObject, options?: Parameters<typeof requirePrivateCredentialHome>[2]): Promise<ProviderProfile>;
|
|
13
|
+
/** The pinned SDK lacks the native CLI's private profile-file option. */
|
|
14
|
+
export declare function createProfileCodex(options: CodexOptions, profileName: string, requestedPermissionProfile?: string): Promise<Codex>;
|
|
15
|
+
/** Verify the effective helper policy before starting exec with a private profile. */
|
|
16
|
+
export declare function preflightReadOnlyProfileCodex(options: CodexOptions, expectedProfile: JsonObject, providerConfig: JsonObject, cwd: string, signal?: AbortSignal): Promise<{
|
|
17
|
+
permissionProfileId: string;
|
|
18
|
+
configOverrides: string[];
|
|
19
|
+
}>;
|
|
20
|
+
export declare function withCodexPreflightLock<T>(env: Record<string, string> | undefined, signal: AbortSignal | undefined, operation: () => Promise<T>): Promise<T>;
|
|
21
|
+
//# sourceMappingURL=provider-profile.d.ts.map
|
|
@@ -0,0 +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;AAE7D,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAIL,4BAA4B,EAE5B,KAAK,YAAY,EAClB,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,qFAAqF;AACrF,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,YAAY,CAAC,CAuBvB;AAED,6EAA6E;AAC7E,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,UAAU,EAClB,OAAO,GAAE,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAC,CAAC,CAAM,GAC/D,OAAO,CAAC,eAAe,CAAC,CAgB1B;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,CA+CrE;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"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import { randomUUID } from "node:crypto";
|
|
10
|
+
import { lstat, mkdir, rm } from "node:fs/promises";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { pathToFileURL } from "node:url";
|
|
13
|
+
import { configuredCodexHome } from "./auth.js";
|
|
14
|
+
import { resolveCodexProfile, modelProviderConfigOverride, inlineToml, writeCodexConfig, } from "./config.js";
|
|
15
|
+
import { isRecord } from "./record.js";
|
|
16
|
+
import { bundledCodexSdkEnvironment } from "./codex-sdk-environment.js";
|
|
17
|
+
import { bundledPluginRoot, acquireCodexSecurityCredentialHomeLock, executablePathForSpawn, requirePrivateCredentialHome, resolveCodexCommand, } from "./runtime.js";
|
|
18
|
+
/** Native no-turn commands need provider metadata when managed policy selects it. */
|
|
19
|
+
export async function providerPreflightCommand(command, config) {
|
|
20
|
+
const resolved = resolveCodexProfile(config);
|
|
21
|
+
const overrides = [];
|
|
22
|
+
const providers = resolved["model_providers"];
|
|
23
|
+
if (isRecord(providers) && Object.keys(providers).length > 0) {
|
|
24
|
+
const client = await nativeProfileClient();
|
|
25
|
+
const definitions = client.preflightProviderDefinitions(providers);
|
|
26
|
+
overrides.push(...modelProviderConfigOverride({ model_providers: definitions }));
|
|
27
|
+
}
|
|
28
|
+
if (resolved["model_provider"] !== undefined)
|
|
29
|
+
overrides.push(`model_provider=${inlineToml(resolved["model_provider"])}`);
|
|
30
|
+
if (overrides.length === 0)
|
|
31
|
+
return command;
|
|
32
|
+
return {
|
|
33
|
+
...command,
|
|
34
|
+
args: [
|
|
35
|
+
...(command.args ?? []),
|
|
36
|
+
...overrides.flatMap((value) => ["-c", value]),
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Provider definitions use a native file layer, never process arguments. */
|
|
41
|
+
export async function createProviderProfile(codexHome, config, options = {}) {
|
|
42
|
+
const providers = resolveCodexProfile(config)["model_providers"];
|
|
43
|
+
const name = `codex_security_${randomUUID()}`;
|
|
44
|
+
const path = join(codexHome, `${name}.config.toml`);
|
|
45
|
+
if ((options.platform ?? process.platform) === "win32") {
|
|
46
|
+
await mkdir(codexHome, { recursive: true, mode: 0o700 });
|
|
47
|
+
await requirePrivateCredentialHome(await lstat(codexHome), codexHome, options);
|
|
48
|
+
}
|
|
49
|
+
await writeCodexConfig(path, {
|
|
50
|
+
model_providers: isRecord(providers) ? providers : {},
|
|
51
|
+
});
|
|
52
|
+
return { name, path, cleanup: () => rm(path, { force: true }) };
|
|
53
|
+
}
|
|
54
|
+
/** The pinned SDK lacks the native CLI's private profile-file option. */
|
|
55
|
+
export async function createProfileCodex(options, profileName, requestedPermissionProfile) {
|
|
56
|
+
const command = options.codexPathOverride ?? resolveCodexCommand(options.env).command;
|
|
57
|
+
const client = await nativeProfileClient();
|
|
58
|
+
return client.createCodexProfileClient({
|
|
59
|
+
...options,
|
|
60
|
+
codexPathOverride: executablePathForSpawn(command),
|
|
61
|
+
profileName,
|
|
62
|
+
requestedPermissionProfile,
|
|
63
|
+
...(options.env === undefined
|
|
64
|
+
? {}
|
|
65
|
+
: { env: bundledCodexSdkEnvironment(command, options.env) }),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/** Verify the effective helper policy before starting exec with a private profile. */
|
|
69
|
+
export async function preflightReadOnlyProfileCodex(options, expectedProfile, providerConfig, cwd, signal) {
|
|
70
|
+
const preflight = await nativePermissionPreflight();
|
|
71
|
+
const permissionProfileId = preflight.DEEP_SCAN_WORKER_PERMISSION_PROFILE_ID;
|
|
72
|
+
const configOverrides = [
|
|
73
|
+
...(options.configOverrides ?? []),
|
|
74
|
+
`default_permissions=${JSON.stringify(permissionProfileId)}`,
|
|
75
|
+
`permissions.${permissionProfileId}=${inlineToml(expectedProfile)}`,
|
|
76
|
+
];
|
|
77
|
+
const command = options.codexPathOverride ?? resolveCodexCommand(options.env).command;
|
|
78
|
+
const client = await nativeProfileClient();
|
|
79
|
+
const providers = resolveCodexProfile(providerConfig)["model_providers"];
|
|
80
|
+
const definitions = isRecord(providers)
|
|
81
|
+
? client.preflightProviderDefinitions(providers)
|
|
82
|
+
: {};
|
|
83
|
+
const env = options.env === undefined
|
|
84
|
+
? undefined
|
|
85
|
+
: bundledCodexSdkEnvironment(command, options.env);
|
|
86
|
+
await withCodexPreflightLock(env, signal, async () => {
|
|
87
|
+
await preflight.preflightDeepScanWorkerPermissionProfile({
|
|
88
|
+
codexPath: executablePathForSpawn(command),
|
|
89
|
+
cwd,
|
|
90
|
+
configOverrides: [
|
|
91
|
+
...client.profileConfigOverrides(options.config ?? {}),
|
|
92
|
+
...configOverrides,
|
|
93
|
+
],
|
|
94
|
+
providerConfigOverrides: modelProviderConfigOverride({
|
|
95
|
+
model_providers: definitions,
|
|
96
|
+
}),
|
|
97
|
+
...(env === undefined
|
|
98
|
+
? {}
|
|
99
|
+
: {
|
|
100
|
+
env: {
|
|
101
|
+
...env,
|
|
102
|
+
...(options.apiKey === undefined
|
|
103
|
+
? {}
|
|
104
|
+
: { CODEX_API_KEY: options.apiKey }),
|
|
105
|
+
},
|
|
106
|
+
}),
|
|
107
|
+
expectedProfile,
|
|
108
|
+
signal: signal ?? new AbortController().signal,
|
|
109
|
+
context: "helper",
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
return { permissionProfileId, configOverrides };
|
|
113
|
+
}
|
|
114
|
+
export async function withCodexPreflightLock(env, signal, operation) {
|
|
115
|
+
// App-server treats concurrent cold-home SQLite initialization as fatal.
|
|
116
|
+
// Keep the lock in a private child so a readable native home stays readable.
|
|
117
|
+
const lockDirectory = join(configuredCodexHome(env ?? process.env), ".codex-security-preflight");
|
|
118
|
+
await mkdir(lockDirectory, { recursive: true, mode: 0o700 });
|
|
119
|
+
const release = await acquireCodexSecurityCredentialHomeLock(lockDirectory, signal);
|
|
120
|
+
try {
|
|
121
|
+
return await operation();
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
await release();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async function nativePermissionPreflight() {
|
|
128
|
+
return await import(__rewriteRelativeImportExtension(pathToFileURL(join(await bundledPluginRoot(), "mcp", "permission-profile-preflight.mjs")).href));
|
|
129
|
+
}
|
|
130
|
+
async function nativeProfileClient() {
|
|
131
|
+
return await import(__rewriteRelativeImportExtension(pathToFileURL(join(await bundledPluginRoot(), "scripts", "codex_profile.mjs")).href));
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=provider-profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-profile.js","sourceRoot":"","sources":["../src/provider-profile.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,UAAU,EACV,gBAAgB,GAEjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,sCAAsC,EACtC,sBAAsB,EACtB,4BAA4B,EAC5B,mBAAmB,GAEpB,MAAM,cAAc,CAAC;AAQtB,qFAAqF;AACrF,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,OAAqB,EACrB,MAAkB;IAElB,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,MAAM,SAAS,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC9C,IAAI,QAAQ,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7D,MAAM,MAAM,GAAG,MAAM,mBAAmB,EAAE,CAAC;QAC3C,MAAM,WAAW,GAAG,MAAM,CAAC,4BAA4B,CACrD,SAAS,CACI,CAAC;QAChB,SAAS,CAAC,IAAI,C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9C,OAAO,EAAE,QAAQ;SAClB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,GAAuC,EACvC,MAA+B,EAC/B,SAA2B;IAE3B,yEAAyE;IACzE,6EAA6E;IAC7E,MAAM,aAAa,GAAG,IAAI,CACxB,mBAAmB,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,EACvC,2BAA2B,CAC5B,CAAC;IACF,MAAM,KAAK,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7D,MAAM,OAAO,GAAG,MAAM,sCAAsC,CAC1D,aAAa,EACb,MAAM,CACP,CAAC;IACF,IAAI,CAAC;QACH,OAAO,MAAM,SAAS,EAAE,CAAC;IAC3B,CAAC;YAAS,CAAC;QACT,MAAM,OAAO,EAAE,CAAC;IAClB,CAAC;AACH,CAAC;AAED,KAAK,UAAU,yBAAyB;IACtC,OAAO,MAAM,MAAM,kCACjB,aAAa,CACX,IAAI,CACF,MAAM,iBAAiB,EAAE,EACzB,KAAK,EACL,kCAAkC,CACnC,CACF,CAAC,IAAI,EACP,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,mBAAmB;IAChC,OAAO,MAAM,MAAM,kCACjB,aAAa,CACX,IAAI,CAAC,MAAM,iBAAiB,EAAE,EAAE,SAAS,EAAE,mBAAmB,CAAC,CAChE,CAAC,IAAI,EACP,CAAC;AACJ,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { lstat, mkdir, rm } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { Codex, CodexOptions } from \"@openai/codex-sdk\";\nimport { configuredCodexHome } from \"./auth.js\";\nimport {\n resolveCodexProfile,\n modelProviderConfigOverride,\n inlineToml,\n writeCodexConfig,\n type JsonObject,\n} from \"./config.js\";\nimport { isRecord } from \"./record.js\";\nimport { bundledCodexSdkEnvironment } from \"./codex-sdk-environment.js\";\nimport {\n bundledPluginRoot,\n acquireCodexSecurityCredentialHomeLock,\n executablePathForSpawn,\n requirePrivateCredentialHome,\n resolveCodexCommand,\n type CodexCommand,\n} from \"./runtime.js\";\n\nexport interface ProviderProfile {\n name: string;\n path: string;\n cleanup(): Promise<void>;\n}\n\n/** Native no-turn commands need provider metadata when managed policy selects it. */\nexport async function providerPreflightCommand(\n command: CodexCommand,\n config: JsonObject,\n): Promise<CodexCommand> {\n const resolved = resolveCodexProfile(config);\n const overrides: string[] = [];\n const providers = resolved[\"model_providers\"];\n if (isRecord(providers) && Object.keys(providers).length > 0) {\n const client = await nativeProfileClient();\n const definitions = client.preflightProviderDefinitions(\n providers,\n ) as JsonObject;\n overrides.push(\n ...modelProviderConfigOverride({ model_providers: definitions }),\n );\n }\n if (resolved[\"model_provider\"] !== undefined)\n overrides.push(`model_provider=${inlineToml(resolved[\"model_provider\"])}`);\n if (overrides.length === 0) return command;\n return {\n ...command,\n args: [\n ...(command.args ?? []),\n ...overrides.flatMap((value) => [\"-c\", value]),\n ],\n };\n}\n\n/** Provider definitions use a native file layer, never process arguments. */\nexport async function createProviderProfile(\n codexHome: string,\n config: JsonObject,\n options: Parameters<typeof requirePrivateCredentialHome>[2] = {},\n): Promise<ProviderProfile> {\n const providers = resolveCodexProfile(config)[\"model_providers\"];\n const name = `codex_security_${randomUUID()}`;\n const path = join(codexHome, `${name}.config.toml`);\n if ((options.platform ?? process.platform) === \"win32\") {\n await mkdir(codexHome, { recursive: true, mode: 0o700 });\n await requirePrivateCredentialHome(\n await lstat(codexHome),\n codexHome,\n options,\n );\n }\n await writeCodexConfig(path, {\n model_providers: isRecord(providers) ? providers : {},\n });\n return { name, path, cleanup: () => rm(path, { force: true }) };\n}\n\n/** The pinned SDK lacks the native CLI's private profile-file option. */\nexport async function createProfileCodex(\n options: CodexOptions,\n profileName: string,\n requestedPermissionProfile?: string,\n): Promise<Codex> {\n const command =\n options.codexPathOverride ?? resolveCodexCommand(options.env).command;\n const client = await nativeProfileClient();\n return client.createCodexProfileClient({\n ...options,\n codexPathOverride: executablePathForSpawn(command),\n profileName,\n requestedPermissionProfile,\n ...(options.env === undefined\n ? {}\n : { env: bundledCodexSdkEnvironment(command, options.env) }),\n }) as Codex;\n}\n\n/** Verify the effective helper policy before starting exec with a private profile. */\nexport async function preflightReadOnlyProfileCodex(\n options: CodexOptions,\n expectedProfile: JsonObject,\n providerConfig: JsonObject,\n cwd: string,\n signal?: AbortSignal,\n): Promise<{ permissionProfileId: string; configOverrides: string[] }> {\n const preflight = await nativePermissionPreflight();\n const permissionProfileId =\n preflight.DEEP_SCAN_WORKER_PERMISSION_PROFILE_ID as string;\n const configOverrides = [\n ...(options.configOverrides ?? []),\n `default_permissions=${JSON.stringify(permissionProfileId)}`,\n `permissions.${permissionProfileId}=${inlineToml(expectedProfile)}`,\n ];\n const command =\n options.codexPathOverride ?? resolveCodexCommand(options.env).command;\n const client = await nativeProfileClient();\n const providers = resolveCodexProfile(providerConfig)[\"model_providers\"];\n const definitions = isRecord(providers)\n ? (client.preflightProviderDefinitions(providers) as JsonObject)\n : {};\n const env =\n options.env === undefined\n ? undefined\n : bundledCodexSdkEnvironment(command, options.env);\n await withCodexPreflightLock(env, signal, async () => {\n await preflight.preflightDeepScanWorkerPermissionProfile({\n codexPath: executablePathForSpawn(command),\n cwd,\n configOverrides: [\n ...client.profileConfigOverrides(options.config ?? {}),\n ...configOverrides,\n ],\n providerConfigOverrides: modelProviderConfigOverride({\n model_providers: definitions,\n }),\n ...(env === undefined\n ? {}\n : {\n env: {\n ...env,\n ...(options.apiKey === undefined\n ? {}\n : { CODEX_API_KEY: options.apiKey }),\n },\n }),\n expectedProfile,\n signal: signal ?? new AbortController().signal,\n context: \"helper\",\n });\n });\n return { permissionProfileId, configOverrides };\n}\n\nexport async function withCodexPreflightLock<T>(\n env: Record<string, string> | undefined,\n signal: AbortSignal | undefined,\n operation: () => Promise<T>,\n): Promise<T> {\n // App-server treats concurrent cold-home SQLite initialization as fatal.\n // Keep the lock in a private child so a readable native home stays readable.\n const lockDirectory = join(\n configuredCodexHome(env ?? process.env),\n \".codex-security-preflight\",\n );\n await mkdir(lockDirectory, { recursive: true, mode: 0o700 });\n const release = await acquireCodexSecurityCredentialHomeLock(\n lockDirectory,\n signal,\n );\n try {\n return await operation();\n } finally {\n await release();\n }\n}\n\nasync function nativePermissionPreflight() {\n return await import(\n pathToFileURL(\n join(\n await bundledPluginRoot(),\n \"mcp\",\n \"permission-profile-preflight.mjs\",\n ),\n ).href\n );\n}\n\nasync function nativeProfileClient() {\n return await import(\n pathToFileURL(\n join(await bundledPluginRoot(), \"scripts\", \"codex_profile.mjs\"),\n ).href\n );\n}\n"]}
|
|
@@ -16,21 +16,18 @@ export type ClaimResolution = {
|
|
|
16
16
|
issueIdentifier: string;
|
|
17
17
|
url?: string;
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
interface CreateEvidence {
|
|
20
20
|
source: "event";
|
|
21
|
-
status: "completed";
|
|
22
21
|
rawLine: string;
|
|
23
22
|
ownerFindingId?: string;
|
|
24
23
|
argumentsValid: boolean;
|
|
25
24
|
resolution: ClaimResolution;
|
|
26
25
|
}
|
|
27
|
-
export interface
|
|
28
|
-
|
|
26
|
+
export interface CompletedCreateEvidence extends CreateEvidence {
|
|
27
|
+
status: "completed";
|
|
28
|
+
}
|
|
29
|
+
export interface FailedCreateEvidence extends CreateEvidence {
|
|
29
30
|
status: "failed";
|
|
30
|
-
rawLine: string;
|
|
31
|
-
ownerFindingId?: string;
|
|
32
|
-
argumentsValid: boolean;
|
|
33
|
-
resolution: ClaimResolution;
|
|
34
31
|
error: string;
|
|
35
32
|
}
|
|
36
33
|
export type PublicationEventEvidence = CompletedCreateEvidence | FailedCreateEvidence;
|
|
@@ -40,4 +37,5 @@ export declare function matchPublicationIssue(publication: PreparedScanPublicati
|
|
|
40
37
|
export declare function resolvePublicationClaims(value: unknown): ClaimResolution;
|
|
41
38
|
export declare function resolveClaims(claims: readonly PublicationClaim[]): ClaimResolution;
|
|
42
39
|
export declare function publicationClaimAliases(claim: PublicationClaim): PublicationClaim[];
|
|
40
|
+
export {};
|
|
43
41
|
//# sourceMappingURL=publication-events.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publication-events.d.ts","sourceRoot":"","sources":["../src/publication-events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"publication-events.d.ts","sourceRoot":"","sources":["../src/publication-events.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,oCAAoC,wEACsB,CAAC;AAExE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,YAAY,GAAG,UAAU,GAAG,KAAK,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,eAAe,GACvB;IAAE,KAAK,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,gBAAgB,EAAE,CAAA;CAAE,GAC/C;IAAE,KAAK,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,gBAAgB,EAAE,CAAA;CAAE,GACpD;IACE,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEN,UAAU,cAAc;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,eAAe,CAAC;CAC7B;AAED,MAAM,WAAW,uBAAwB,SAAQ,cAAc;IAC7D,MAAM,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,MAAM,EAAE,QAAQ,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,wBAAwB,GAClC,uBAAuB,GAAG,oBAAoB,CAAC;AAEjD,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,uBAAuB,EACpC,cAAc,EAAE,MAAM,GACrB,wBAAwB,EAAE,CAyC5B;AAED,wBAAgB,+BAA+B,CAC7C,WAAW,EAAE,uBAAuB,EACpC,KAAK,EAAE,wBAAwB,EAC/B,MAAM,EAAE,OAAO,GACd,OAAO,CAUT;AAED,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,uBAAuB,EACpC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,wBAAwB,GAAG,SAAS,CActC;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAIxE;AAED,wBAAgB,aAAa,CAC3B,MAAM,EAAE,SAAS,gBAAgB,EAAE,GAClC,eAAe,CA2CjB;AAmHD,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,gBAAgB,GACtB,gBAAgB,EAAE,CAMpB"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { parseJson } from "./value.js";
|
|
1
2
|
import { isLinearIssueIdentifier, linearIssueReference } from "./linear.js";
|
|
3
|
+
import { isRecord } from "./record.js";
|
|
2
4
|
import { linearPublicationArguments, } from "./publication.js";
|
|
3
5
|
export const MISSING_PUBLICATION_IDENTIFIER_ERROR = "The connected Linear app did not return a created issue identifier.";
|
|
4
6
|
export function collectPublicationEvents(output, publication, failureMessage) {
|
|
@@ -6,13 +8,7 @@ export function collectPublicationEvents(output, publication, failureMessage) {
|
|
|
6
8
|
for (const rawLine of output.split(/\r?\n/)) {
|
|
7
9
|
if (rawLine.trim().length === 0)
|
|
8
10
|
continue;
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
event = JSON.parse(rawLine);
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
11
|
+
const event = parseJson(() => rawLine);
|
|
16
12
|
if (!isRecord(event) || event["type"] !== "item.completed")
|
|
17
13
|
continue;
|
|
18
14
|
const item = event["item"];
|
|
@@ -24,29 +20,27 @@ export function collectPublicationEvents(output, publication, failureMessage) {
|
|
|
24
20
|
: undefined;
|
|
25
21
|
const argumentsValid = owner !== undefined &&
|
|
26
22
|
hasExpectedPublicationArguments(publication, owner, arguments_);
|
|
27
|
-
|
|
28
|
-
evidence.push({
|
|
29
|
-
source: "event",
|
|
30
|
-
status: "completed",
|
|
31
|
-
rawLine,
|
|
32
|
-
...(owner === undefined ? {} : { ownerFindingId: owner.findingId }),
|
|
33
|
-
argumentsValid,
|
|
34
|
-
resolution: resolvePublicationClaims(item["result"]),
|
|
35
|
-
});
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
const error = item["error"];
|
|
39
|
-
evidence.push({
|
|
23
|
+
const completed = {
|
|
40
24
|
source: "event",
|
|
41
|
-
status: "
|
|
25
|
+
status: "completed",
|
|
42
26
|
rawLine,
|
|
43
27
|
...(owner === undefined ? {} : { ownerFindingId: owner.findingId }),
|
|
44
28
|
argumentsValid,
|
|
45
29
|
resolution: resolvePublicationClaims(item["result"]),
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
30
|
+
};
|
|
31
|
+
if (item["status"] === "completed") {
|
|
32
|
+
evidence.push(completed);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const error = item["error"];
|
|
36
|
+
evidence.push({
|
|
37
|
+
...completed,
|
|
38
|
+
status: "failed",
|
|
39
|
+
error: isRecord(error) && typeof error["message"] === "string"
|
|
40
|
+
? error["message"]
|
|
41
|
+
: failureMessage,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
50
44
|
}
|
|
51
45
|
return evidence;
|
|
52
46
|
}
|
|
@@ -74,38 +68,26 @@ export function resolvePublicationClaims(value) {
|
|
|
74
68
|
return resolveClaims(claims);
|
|
75
69
|
}
|
|
76
70
|
export function resolveClaims(claims) {
|
|
77
|
-
const
|
|
78
|
-
|
|
71
|
+
const normalized = new Map();
|
|
72
|
+
claims.forEach((claim) => {
|
|
79
73
|
const trimmed = claim.value.trim();
|
|
80
74
|
if (trimmed.length === 0)
|
|
81
|
-
return
|
|
75
|
+
return;
|
|
82
76
|
const value = isCanonicalUuid(trimmed) ? trimmed.toLowerCase() : trimmed;
|
|
83
|
-
|
|
77
|
+
const kind = claim.kind;
|
|
78
|
+
normalized.set(`${kind}\0${value}`, { kind, value });
|
|
84
79
|
});
|
|
85
|
-
const retained = normalized
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
})
|
|
93
|
-
.sort(compareClaims);
|
|
94
|
-
const identifiers = new Set(retained
|
|
95
|
-
.filter((claim) => claim.kind === "identifier")
|
|
96
|
-
.map((claim) => claim.value));
|
|
97
|
-
const entityIds = new Set(retained
|
|
98
|
-
.filter((claim) => claim.kind === "entityId")
|
|
99
|
-
.map((claim) => claim.value));
|
|
100
|
-
const urls = new Set(retained
|
|
101
|
-
.filter((claim) => claim.kind === "url")
|
|
102
|
-
.map((claim) => claim.value));
|
|
80
|
+
const retained = [...normalized.values()].sort(compareClaims);
|
|
81
|
+
const identifiers = new Set();
|
|
82
|
+
const entityIds = new Set();
|
|
83
|
+
const urls = new Set();
|
|
84
|
+
const byKind = { identifier: identifiers, entityId: entityIds, url: urls };
|
|
85
|
+
for (const { kind, value } of retained)
|
|
86
|
+
byKind[kind]?.add?.(value);
|
|
103
87
|
const canonicalUrls = new Set([...urls].map(canonicalPublicationUrlClaim));
|
|
104
88
|
const urlContradictsIdentifier = identifiers.size > 0 &&
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
.some((reference) => reference !== undefined && !identifiers.has(reference.id));
|
|
108
|
-
const overlappingIdentity = [...identifiers].some((identifier) => entityIds.has(identifier));
|
|
89
|
+
Array.from(urls, linearIssueReferenceFromUrl).some((reference) => reference !== undefined && !identifiers.has(reference.id));
|
|
90
|
+
const overlappingIdentity = !identifiers.isDisjointFrom(entityIds);
|
|
109
91
|
if (identifiers.size > 1 ||
|
|
110
92
|
entityIds.size > 1 ||
|
|
111
93
|
canonicalUrls.size > 1 ||
|
|
@@ -133,13 +115,9 @@ function isLinearCreateCall(item) {
|
|
|
133
115
|
item["tool"] === "linear_save_issue"));
|
|
134
116
|
}
|
|
135
117
|
function collectPublicationClaims(value, claims) {
|
|
136
|
-
const
|
|
137
|
-
const pending = [value];
|
|
118
|
+
const pending = isRecord(value) ? [value] : [];
|
|
138
119
|
while (pending.length > 0) {
|
|
139
120
|
const candidate = pending.pop();
|
|
140
|
-
if (!isRecord(candidate) || visited.has(candidate))
|
|
141
|
-
continue;
|
|
142
|
-
visited.add(candidate);
|
|
143
121
|
collectDirectClaims(candidate, claims);
|
|
144
122
|
const data = candidate["data"];
|
|
145
123
|
const nested = [
|
|
@@ -153,17 +131,14 @@ function collectPublicationClaims(value, claims) {
|
|
|
153
131
|
if (!isRecord(content) || typeof content["text"] !== "string") {
|
|
154
132
|
continue;
|
|
155
133
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
catch {
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
134
|
+
const parsed = parseJson(() => content["text"]);
|
|
135
|
+
if (isRecord(parsed))
|
|
136
|
+
nested.push(parsed);
|
|
162
137
|
}
|
|
163
138
|
}
|
|
164
|
-
for (
|
|
165
|
-
if (isRecord(
|
|
166
|
-
pending.push(
|
|
139
|
+
for (const child of nested.reverse()) {
|
|
140
|
+
if (isRecord(child))
|
|
141
|
+
pending.push(child);
|
|
167
142
|
}
|
|
168
143
|
}
|
|
169
144
|
}
|
|
@@ -207,19 +182,8 @@ function isCanonicalUuid(value) {
|
|
|
207
182
|
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu.test(value);
|
|
208
183
|
}
|
|
209
184
|
function linearIssueReferenceFromUrl(value) {
|
|
210
|
-
let url;
|
|
211
|
-
try {
|
|
212
|
-
url = new URL(value);
|
|
213
|
-
}
|
|
214
|
-
catch {
|
|
215
|
-
return undefined;
|
|
216
|
-
}
|
|
217
185
|
// Recognize every scheme linearIssueReference parses, so a plain HTTP URL
|
|
218
186
|
// still resolves to the issue it names instead of an unrecognized claim.
|
|
219
|
-
if ((url.protocol !== "https:" && url.protocol !== "http:") ||
|
|
220
|
-
url.hostname !== "linear.app") {
|
|
221
|
-
return undefined;
|
|
222
|
-
}
|
|
223
187
|
try {
|
|
224
188
|
const reference = linearIssueReference(value);
|
|
225
189
|
return reference.workspace === undefined
|
|
@@ -254,7 +218,4 @@ function containsIdentifier(value, identifier) {
|
|
|
254
218
|
const escaped = identifier.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
255
219
|
return new RegExp(`(?<![\\w-])${escaped}(?![\\w-])`, "u").test(value);
|
|
256
220
|
}
|
|
257
|
-
function isRecord(value) {
|
|
258
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
259
|
-
}
|
|
260
221
|
//# sourceMappingURL=publication-events.js.map
|