@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
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Render saved structured or Markdown threat models without running analysis."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import json
|
|
8
|
+
import sys
|
|
9
|
+
from collections.abc import Callable
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
# Keep sibling helpers importable when Python starts in isolated mode.
|
|
14
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
15
|
+
import report_projection as report
|
|
16
|
+
|
|
17
|
+
_STRUCTURED_SECTIONS = (
|
|
18
|
+
("Assets", "assets"),
|
|
19
|
+
("Trust Boundaries", "trustBoundaries"),
|
|
20
|
+
("Attacker Capabilities", "attackerCapabilities"),
|
|
21
|
+
("Security Objectives", "securityObjectives"),
|
|
22
|
+
("Assumptions", "assumptions"),
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _is_structured_model(model: dict[str, Any]) -> bool:
|
|
27
|
+
summary = model.get("summary")
|
|
28
|
+
return (
|
|
29
|
+
isinstance(summary, str)
|
|
30
|
+
and bool(summary)
|
|
31
|
+
and all(
|
|
32
|
+
isinstance(values := model.get(key, []), list)
|
|
33
|
+
and all(isinstance(value, str) and value for value in values)
|
|
34
|
+
for _, key in _STRUCTURED_SECTIONS
|
|
35
|
+
)
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _markdown_content(model: dict[str, Any]) -> str | None:
|
|
40
|
+
content = model.get("content")
|
|
41
|
+
if model.get("format") == "markdown" and isinstance(content, str) and content.strip():
|
|
42
|
+
return content
|
|
43
|
+
return None
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def threat_model_body(model: dict[str, Any]) -> str:
|
|
47
|
+
"""Keep authored Markdown intact, including summaries from older scans."""
|
|
48
|
+
content = _markdown_content(model)
|
|
49
|
+
if content is not None:
|
|
50
|
+
# The structured schema permits legacy metadata as extension fields.
|
|
51
|
+
if _is_structured_model(model):
|
|
52
|
+
return content
|
|
53
|
+
if "origin" in model and model["origin"] not in (
|
|
54
|
+
"generated",
|
|
55
|
+
"provided",
|
|
56
|
+
"reconciled",
|
|
57
|
+
"recovered",
|
|
58
|
+
):
|
|
59
|
+
raise ValueError("threatModel.origin: unsupported value")
|
|
60
|
+
if "scope" in model:
|
|
61
|
+
scope = model["scope"]
|
|
62
|
+
if not isinstance(scope, dict) or "includePaths" not in scope:
|
|
63
|
+
raise ValueError("threatModel.scope: expected an object with includePaths")
|
|
64
|
+
for key in ("includePaths", "excludePaths"):
|
|
65
|
+
if key in scope and (
|
|
66
|
+
not isinstance(scope[key], list)
|
|
67
|
+
or not all(isinstance(path, str) and path for path in scope[key])
|
|
68
|
+
):
|
|
69
|
+
raise ValueError(
|
|
70
|
+
f"threatModel.scope.{key}: expected an array of non-empty strings"
|
|
71
|
+
)
|
|
72
|
+
if "summary" in scope and (
|
|
73
|
+
not isinstance(scope["summary"], str) or not scope["summary"]
|
|
74
|
+
):
|
|
75
|
+
raise ValueError("threatModel.scope.summary: expected a non-empty string")
|
|
76
|
+
return content
|
|
77
|
+
summary = model.get("summary")
|
|
78
|
+
if not isinstance(summary, str) or not summary:
|
|
79
|
+
if model.get("format") == "markdown":
|
|
80
|
+
raise ValueError("threatModel.content: expected non-empty Markdown")
|
|
81
|
+
raise ValueError("threatModel.summary: expected a non-empty string")
|
|
82
|
+
sections = [
|
|
83
|
+
summary if summary.strip() else "No explicit canonical threat-model summary was recorded."
|
|
84
|
+
]
|
|
85
|
+
for heading, key in _STRUCTURED_SECTIONS:
|
|
86
|
+
values = model.get(key, [])
|
|
87
|
+
if not isinstance(values, list):
|
|
88
|
+
raise ValueError(f"threatModel.{key}: expected an array")
|
|
89
|
+
if not values:
|
|
90
|
+
continue
|
|
91
|
+
for index, value in enumerate(values):
|
|
92
|
+
if not isinstance(value, str) or not value:
|
|
93
|
+
raise ValueError(f"threatModel.{key}[{index}]: expected a non-empty string")
|
|
94
|
+
sections.append(f"## {heading}")
|
|
95
|
+
sections.append("\n".join("- " + value.replace("\n", "\n ") for value in values))
|
|
96
|
+
return "\n\n".join(sections)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _scope_lines(scope: Any, label: str, text: Callable[[Any, str], str]) -> list[str]:
|
|
100
|
+
# Older structured models may use these extension names for unrelated data.
|
|
101
|
+
included = scope.get("includePaths") if isinstance(scope, dict) else None
|
|
102
|
+
if not isinstance(included, list) or not all(isinstance(path, str) for path in included):
|
|
103
|
+
return [f"- {label}: not recorded"]
|
|
104
|
+
lines = [f"- {label}: {text(', '.join(included), 'none')}"]
|
|
105
|
+
excluded = scope.get("excludePaths")
|
|
106
|
+
if isinstance(excluded, list) and excluded and all(isinstance(path, str) for path in excluded):
|
|
107
|
+
lines.append(f"- {label} exclusions: {text(', '.join(excluded), 'none')}")
|
|
108
|
+
summary = scope.get("summary")
|
|
109
|
+
if isinstance(summary, str) and summary:
|
|
110
|
+
lines.append(f"- {label} description: {text(summary, 'not recorded')}")
|
|
111
|
+
return lines
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def render_threat_model(model: dict[str, Any], provenance: dict[str, Any] | None = None) -> bytes:
|
|
115
|
+
"""Render a portable document with authored content and recorded provenance."""
|
|
116
|
+
body = threat_model_body(model)
|
|
117
|
+
if _markdown_content(model) is None:
|
|
118
|
+
body = "# Threat Model\n\n" + body
|
|
119
|
+
text = report._text
|
|
120
|
+
provenance = provenance or {}
|
|
121
|
+
footer = ["---", "", "## Saved Model Context", ""]
|
|
122
|
+
for key, label in (
|
|
123
|
+
("source", "Source"),
|
|
124
|
+
("scanId", "Scan"),
|
|
125
|
+
("target", "Target"),
|
|
126
|
+
("revision", "Revision"),
|
|
127
|
+
("snapshotDigest", "Snapshot"),
|
|
128
|
+
("status", "Result status"),
|
|
129
|
+
):
|
|
130
|
+
if provenance.get(key):
|
|
131
|
+
footer.append(f"- {label}: {text(str(provenance[key]), 'not recorded')}")
|
|
132
|
+
footer.append(
|
|
133
|
+
f"- Model origin: {text(str(model.get('origin', 'not recorded')), 'not recorded')}"
|
|
134
|
+
)
|
|
135
|
+
footer.extend(_scope_lines(model.get("scope"), "Model scope", text))
|
|
136
|
+
scan_scope = provenance.get("scanScope")
|
|
137
|
+
if isinstance(scan_scope, dict):
|
|
138
|
+
footer.extend(_scope_lines(scan_scope, "Scan scope", text))
|
|
139
|
+
if provenance.get("provisional"):
|
|
140
|
+
footer.extend(["", "This is a provisional model saved before successful completion."])
|
|
141
|
+
return (body + ("\n" if body.endswith("\n") else "\n\n") + "\n".join(footer) + "\n").encode(
|
|
142
|
+
"utf-8"
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def main() -> int:
|
|
147
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
148
|
+
parser.add_argument("--input-json-stdin", action="store_true", required=True)
|
|
149
|
+
parser.parse_args()
|
|
150
|
+
try:
|
|
151
|
+
payload = json.load(sys.stdin)
|
|
152
|
+
sys.stdout.buffer.write(
|
|
153
|
+
render_threat_model(payload["threatModel"], payload.get("provenance"))
|
|
154
|
+
)
|
|
155
|
+
except (KeyError, TypeError, ValueError) as exc:
|
|
156
|
+
parser.error(str(exc))
|
|
157
|
+
return 0
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
if __name__ == "__main__":
|
|
161
|
+
raise SystemExit(main())
|
|
@@ -4,25 +4,14 @@
|
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
|
|
6
6
|
import argparse
|
|
7
|
-
import importlib.util
|
|
8
7
|
import json
|
|
9
8
|
import sys
|
|
10
9
|
from pathlib import Path
|
|
11
|
-
from types import ModuleType
|
|
12
10
|
from typing import Any
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
spec = importlib.util.spec_from_file_location("codex_security_scan_contract", script)
|
|
18
|
-
if spec is None or spec.loader is None:
|
|
19
|
-
raise RuntimeError(f"could not load scan contract validator: {script}")
|
|
20
|
-
module = importlib.util.module_from_spec(spec)
|
|
21
|
-
spec.loader.exec_module(module)
|
|
22
|
-
return module
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
FINALIZER = _load_finalizer()
|
|
12
|
+
# Keep sibling helpers importable when Python starts in isolated mode.
|
|
13
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
14
|
+
import finalize_scan_contract as FINALIZER
|
|
26
15
|
|
|
27
16
|
|
|
28
17
|
def validate_contract(scan_dir: Path) -> dict[str, Any]:
|
|
@@ -39,26 +28,7 @@ def validate_contract(scan_dir: Path) -> dict[str, Any]:
|
|
|
39
28
|
FINALIZER.validate_against_schema(manifest, schema_dir / "scan-manifest.schema.json")
|
|
40
29
|
|
|
41
30
|
scan = FINALIZER._require_dict(manifest, "scan", "manifest")
|
|
42
|
-
|
|
43
|
-
coverage_ref = scan["coverageRef"]
|
|
44
|
-
findings, findings_bytes = FINALIZER._read_scan_local_json_bytes(
|
|
45
|
-
scan_dir,
|
|
46
|
-
findings_ref,
|
|
47
|
-
findings_ref,
|
|
48
|
-
)
|
|
49
|
-
coverage, coverage_bytes = FINALIZER._read_scan_local_json_bytes(
|
|
50
|
-
scan_dir,
|
|
51
|
-
coverage_ref,
|
|
52
|
-
coverage_ref,
|
|
53
|
-
)
|
|
54
|
-
FINALIZER._validate_existing_seal(
|
|
55
|
-
scan_dir,
|
|
56
|
-
scan,
|
|
57
|
-
artifact_contents={
|
|
58
|
-
findings_ref: findings_bytes,
|
|
59
|
-
coverage_ref: coverage_bytes,
|
|
60
|
-
},
|
|
61
|
-
)
|
|
31
|
+
findings, coverage, _ = FINALIZER._read_sealed_artifacts(scan_dir, scan)
|
|
62
32
|
findings_for_validation = FINALIZER._legacy_sealed_findings_for_validation(findings)
|
|
63
33
|
FINALIZER._validate_findings(manifest, findings_for_validation)
|
|
64
34
|
FINALIZER._validate_derived_finding_identities(manifest, findings)
|
|
@@ -4,24 +4,14 @@
|
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
|
|
6
6
|
import argparse
|
|
7
|
-
import importlib.util
|
|
8
7
|
import sys
|
|
9
8
|
from pathlib import Path
|
|
10
|
-
from types import ModuleType
|
|
11
9
|
from typing import Any
|
|
12
10
|
|
|
11
|
+
# Keep sibling helpers importable when Python starts in isolated mode.
|
|
12
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
13
|
+
import validate_scan_contract as SCAN_CONTRACT
|
|
13
14
|
|
|
14
|
-
def _load_scan_contract_validator() -> ModuleType:
|
|
15
|
-
script = Path(__file__).resolve().with_name("validate_scan_contract.py")
|
|
16
|
-
spec = importlib.util.spec_from_file_location("codex_security_scan_validator", script)
|
|
17
|
-
if spec is None or spec.loader is None:
|
|
18
|
-
raise RuntimeError(f"could not load scan contract validator: {script}")
|
|
19
|
-
module = importlib.util.module_from_spec(spec)
|
|
20
|
-
spec.loader.exec_module(module)
|
|
21
|
-
return module
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
SCAN_CONTRACT = _load_scan_contract_validator()
|
|
25
15
|
FINALIZER = SCAN_CONTRACT.FINALIZER
|
|
26
16
|
validate_contract = SCAN_CONTRACT.validate_contract
|
|
27
17
|
|
|
@@ -4,13 +4,16 @@ Windows does not implement Python's descriptor-relative ``dir_fd`` APIs or
|
|
|
4
4
|
``O_NOFOLLOW``. This module provides the three operations needed by the scan
|
|
5
5
|
finalizer without falling back to check-then-use path validation.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
and
|
|
9
|
-
open without ``FILE_SHARE_DELETE`` for the full
|
|
7
|
+
Scan-local reads, writes, and deletes open every directory with
|
|
8
|
+
``FILE_FLAG_OPEN_REPARSE_POINT`` and reject all reparse points, including junctions.
|
|
9
|
+
Directory handles remain open without ``FILE_SHARE_DELETE`` for the full
|
|
10
|
+
operation, which prevents an
|
|
10
11
|
already-validated ancestor from being renamed or replaced during a read,
|
|
11
12
|
write, or delete. Writes rename the exact temporary-file handle into place so
|
|
12
13
|
an attacker cannot substitute another file at the temporary name.
|
|
13
14
|
|
|
15
|
+
The snapshot helper copies junction metadata without opening the link target.
|
|
16
|
+
|
|
14
17
|
Importing this module and comparing streams work on every platform. Filesystem
|
|
15
18
|
operations raise ``WindowsScanLocalFileError`` outside Windows.
|
|
16
19
|
"""
|
|
@@ -202,6 +205,19 @@ if os.name == "nt":
|
|
|
202
205
|
]
|
|
203
206
|
_WriteFile.restype = wintypes.BOOL
|
|
204
207
|
|
|
208
|
+
_DeviceIoControl = _kernel32.DeviceIoControl
|
|
209
|
+
_DeviceIoControl.argtypes = [
|
|
210
|
+
wintypes.HANDLE,
|
|
211
|
+
wintypes.DWORD,
|
|
212
|
+
wintypes.LPVOID,
|
|
213
|
+
wintypes.DWORD,
|
|
214
|
+
wintypes.LPVOID,
|
|
215
|
+
wintypes.DWORD,
|
|
216
|
+
ctypes.POINTER(wintypes.DWORD),
|
|
217
|
+
wintypes.LPVOID,
|
|
218
|
+
]
|
|
219
|
+
_DeviceIoControl.restype = wintypes.BOOL
|
|
220
|
+
|
|
205
221
|
_FlushFileBuffers = _kernel32.FlushFileBuffers
|
|
206
222
|
_FlushFileBuffers.argtypes = [wintypes.HANDLE]
|
|
207
223
|
_FlushFileBuffers.restype = wintypes.BOOL
|
|
@@ -309,6 +325,34 @@ def _create_file(
|
|
|
309
325
|
return _OwnedHandle(int(handle))
|
|
310
326
|
|
|
311
327
|
|
|
328
|
+
def copy_directory_junction(source: Path, destination: Path) -> None:
|
|
329
|
+
"""Copy raw junction data to an empty directory without opening the link target."""
|
|
330
|
+
# MAXIMUM_REPARSE_DATA_BUFFER_SIZE, including the reparse data header.
|
|
331
|
+
data = ctypes.create_string_buffer(16 * 1024)
|
|
332
|
+
size = wintypes.DWORD()
|
|
333
|
+
for path, write in ((source, False), (destination, True)):
|
|
334
|
+
handle = _create_file(
|
|
335
|
+
path,
|
|
336
|
+
access=_GENERIC_WRITE if write else _FILE_READ_ATTRIBUTES,
|
|
337
|
+
share=_FILE_SHARE_READ | _FILE_SHARE_WRITE,
|
|
338
|
+
disposition=_OPEN_EXISTING,
|
|
339
|
+
flags=_FILE_FLAG_BACKUP_SEMANTICS | _FILE_FLAG_OPEN_REPARSE_POINT,
|
|
340
|
+
)
|
|
341
|
+
assert handle is not None
|
|
342
|
+
with handle:
|
|
343
|
+
if not _DeviceIoControl(
|
|
344
|
+
handle.value,
|
|
345
|
+
0x000900A4 if write else 0x000900A8, # FSCTL_SET/GET_REPARSE_POINT.
|
|
346
|
+
data if write else None,
|
|
347
|
+
size.value if write else 0,
|
|
348
|
+
None if write else data,
|
|
349
|
+
0 if write else len(data),
|
|
350
|
+
ctypes.byref(size),
|
|
351
|
+
None,
|
|
352
|
+
):
|
|
353
|
+
_raise_last_error("Copy directory junction", path)
|
|
354
|
+
|
|
355
|
+
|
|
312
356
|
def _attributes(handle: int) -> _FileAttributeTagInfo:
|
|
313
357
|
info = _FileAttributeTagInfo()
|
|
314
358
|
if not _GetFileInformationByHandleEx(
|
|
@@ -453,6 +497,12 @@ def scan_root_identity(scan_dir: Path) -> tuple[Path, tuple[int, int]]:
|
|
|
453
497
|
def open_read_fd(scan_dir: Path, relative_path: str, context: str) -> int:
|
|
454
498
|
"""Open a verified regular file and return an owned binary read descriptor."""
|
|
455
499
|
|
|
500
|
+
return open_read_fd_with_path(scan_dir, relative_path, context)[0]
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
def open_read_fd_with_path(scan_dir: Path, relative_path: str, context: str) -> tuple[int, str]:
|
|
504
|
+
"""Return the descriptor and its filename while the verified parents are held."""
|
|
505
|
+
|
|
456
506
|
try:
|
|
457
507
|
with _locked_parent(scan_dir, relative_path, create=False) as (parent_path, leaf_name):
|
|
458
508
|
path = parent_path / leaf_name
|
|
@@ -467,10 +517,13 @@ def open_read_fd(scan_dir: Path, relative_path: str, context: str) -> int:
|
|
|
467
517
|
assert handle is not None and handle.value is not None
|
|
468
518
|
with handle:
|
|
469
519
|
_verify_regular_file(handle.value, path)
|
|
520
|
+
filename = Path(_final_path(handle.value)).name
|
|
521
|
+
resolved_path = PurePosixPath(relative_path).with_name(filename).as_posix()
|
|
470
522
|
raw_handle = handle.detach()
|
|
471
523
|
try:
|
|
472
524
|
assert _msvcrt is not None
|
|
473
|
-
|
|
525
|
+
descriptor = _msvcrt.open_osfhandle(raw_handle, os.O_RDONLY | os.O_BINARY)
|
|
526
|
+
return descriptor, resolved_path
|
|
474
527
|
except BaseException:
|
|
475
528
|
_close_handle(raw_handle)
|
|
476
529
|
raise
|
|
@@ -654,6 +707,7 @@ def atomic_write(
|
|
|
654
707
|
try:
|
|
655
708
|
_mark_handle_for_deletion(temp_handle.value)
|
|
656
709
|
except OSError:
|
|
710
|
+
# Cleanup must not replace the original write or rename failure.
|
|
657
711
|
pass
|
|
658
712
|
raise
|
|
659
713
|
|
|
@@ -686,9 +740,5 @@ def unlink_if_exists(scan_dir: Path, relative_path: str) -> None:
|
|
|
686
740
|
_mark_handle_for_deletion(handle.value)
|
|
687
741
|
|
|
688
742
|
|
|
689
|
-
def main() -> None:
|
|
690
|
-
argparse.ArgumentParser(description=__doc__).parse_args()
|
|
691
|
-
|
|
692
|
-
|
|
693
743
|
if __name__ == "__main__":
|
|
694
|
-
|
|
744
|
+
argparse.ArgumentParser(description=__doc__).parse_args()
|
|
@@ -4,7 +4,6 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import argparse
|
|
6
6
|
import sqlite3
|
|
7
|
-
from collections.abc import Callable
|
|
8
7
|
from typing import Any
|
|
9
8
|
|
|
10
9
|
from workbench_validation import optional_text, require_uuid
|
|
@@ -51,21 +50,17 @@ def validate_handoff_delivery_thread(
|
|
|
51
50
|
|
|
52
51
|
|
|
53
52
|
def claim_handoff_delivery(
|
|
53
|
+
wb: Any,
|
|
54
54
|
connection: sqlite3.Connection,
|
|
55
55
|
args: argparse.Namespace,
|
|
56
|
-
*,
|
|
57
|
-
now: Callable[[], str],
|
|
58
|
-
require_scan: Callable[[sqlite3.Connection, str], sqlite3.Row],
|
|
59
|
-
stale_claim_before: Callable[[], str],
|
|
60
|
-
workspace_state: Callable[[sqlite3.Connection, str], dict[str, Any]],
|
|
61
56
|
) -> dict[str, Any]:
|
|
62
57
|
scan_id = require_uuid(args.scan_id, "scan-id")
|
|
63
58
|
claim_token = require_handoff_claim_token(args.claim_token)
|
|
64
|
-
timestamp = now()
|
|
59
|
+
timestamp = wb.now()
|
|
65
60
|
with connection:
|
|
66
|
-
scan = require_scan(connection, scan_id)
|
|
61
|
+
scan = wb.require_scan(connection, scan_id)
|
|
67
62
|
if scan["handoff_status"] != "pending" or scan["handoff_claim_token"] == claim_token:
|
|
68
|
-
return workspace_state(connection, scan["workspace_id"])
|
|
63
|
+
return wb.workspace_state(connection, scan["workspace_id"])
|
|
69
64
|
updated = connection.execute(
|
|
70
65
|
"""
|
|
71
66
|
UPDATE scans
|
|
@@ -94,27 +89,24 @@ def claim_handoff_delivery(
|
|
|
94
89
|
timestamp,
|
|
95
90
|
scan["id"],
|
|
96
91
|
int(args.take_over_stale),
|
|
97
|
-
stale_claim_before(),
|
|
92
|
+
wb.stale_claim_before(),
|
|
98
93
|
),
|
|
99
94
|
)
|
|
100
95
|
if updated.rowcount != 1:
|
|
101
|
-
return workspace_state(connection, scan["workspace_id"])
|
|
102
|
-
return workspace_state(connection, scan["workspace_id"])
|
|
96
|
+
return wb.workspace_state(connection, scan["workspace_id"])
|
|
97
|
+
return wb.workspace_state(connection, scan["workspace_id"])
|
|
103
98
|
|
|
104
99
|
|
|
105
100
|
def release_handoff_delivery(
|
|
101
|
+
wb: Any,
|
|
106
102
|
connection: sqlite3.Connection,
|
|
107
103
|
args: argparse.Namespace,
|
|
108
|
-
*,
|
|
109
|
-
now: Callable[[], str],
|
|
110
|
-
require_scan: Callable[[sqlite3.Connection, str], sqlite3.Row],
|
|
111
|
-
workspace_state: Callable[[sqlite3.Connection, str], dict[str, Any]],
|
|
112
104
|
) -> dict[str, Any]:
|
|
113
105
|
scan_id = require_uuid(args.scan_id, "scan-id")
|
|
114
106
|
claim_token = require_handoff_claim_token(args.claim_token)
|
|
115
|
-
timestamp = now()
|
|
107
|
+
timestamp = wb.now()
|
|
116
108
|
with connection:
|
|
117
|
-
scan = require_scan(connection, scan_id)
|
|
109
|
+
scan = wb.require_scan(connection, scan_id)
|
|
118
110
|
connection.execute(
|
|
119
111
|
"""
|
|
120
112
|
UPDATE scans
|
|
@@ -126,16 +118,13 @@ def release_handoff_delivery(
|
|
|
126
118
|
""",
|
|
127
119
|
(timestamp, scan["id"], claim_token),
|
|
128
120
|
)
|
|
129
|
-
return workspace_state(connection, scan["workspace_id"])
|
|
121
|
+
return wb.workspace_state(connection, scan["workspace_id"])
|
|
130
122
|
|
|
131
123
|
|
|
132
124
|
def attach_scan_continuation_thread(
|
|
125
|
+
wb: Any,
|
|
133
126
|
connection: sqlite3.Connection,
|
|
134
127
|
args: argparse.Namespace,
|
|
135
|
-
*,
|
|
136
|
-
now: Callable[[], str],
|
|
137
|
-
require_scan: Callable[[sqlite3.Connection, str], sqlite3.Row],
|
|
138
|
-
workspace_state: Callable[[sqlite3.Connection, str], dict[str, Any]],
|
|
139
128
|
) -> dict[str, Any]:
|
|
140
129
|
scan_id = require_uuid(args.scan_id, "scan-id")
|
|
141
130
|
claim_token = require_handoff_claim_token(args.claim_token)
|
|
@@ -143,9 +132,9 @@ def attach_scan_continuation_thread(
|
|
|
143
132
|
if thread_id is None:
|
|
144
133
|
raise SystemExit("Codex Security continuation thread ID is required.")
|
|
145
134
|
connection.execute("BEGIN IMMEDIATE")
|
|
146
|
-
|
|
147
|
-
timestamp = now()
|
|
148
|
-
scan = require_scan(connection, scan_id)
|
|
135
|
+
with connection:
|
|
136
|
+
timestamp = wb.now()
|
|
137
|
+
scan = wb.require_scan(connection, scan_id)
|
|
149
138
|
if scan["handoff_claim_token"] != claim_token:
|
|
150
139
|
raise SystemExit("Codex Security continuation thread claim token does not match.")
|
|
151
140
|
if scan["continuation_thread_id"] is not None:
|
|
@@ -154,8 +143,8 @@ def attach_scan_continuation_thread(
|
|
|
154
143
|
"Codex Security scan continuation is owned by another continuation."
|
|
155
144
|
)
|
|
156
145
|
connection.commit()
|
|
157
|
-
return workspace_state(connection, scan["workspace_id"])
|
|
158
|
-
|
|
146
|
+
return wb.workspace_state(connection, scan["workspace_id"])
|
|
147
|
+
connection.execute(
|
|
159
148
|
"""
|
|
160
149
|
UPDATE scans
|
|
161
150
|
SET continuation_thread_id = ?,
|
|
@@ -168,33 +157,23 @@ def attach_scan_continuation_thread(
|
|
|
168
157
|
""",
|
|
169
158
|
(thread_id, thread_id, timestamp, scan["id"], claim_token),
|
|
170
159
|
)
|
|
171
|
-
|
|
172
|
-
raise SystemExit("Codex Security continuation thread could not be attached.")
|
|
173
|
-
connection.commit()
|
|
174
|
-
except BaseException:
|
|
175
|
-
connection.rollback()
|
|
176
|
-
raise
|
|
177
|
-
return workspace_state(connection, scan["workspace_id"])
|
|
160
|
+
return wb.workspace_state(connection, scan["workspace_id"])
|
|
178
161
|
|
|
179
162
|
|
|
180
163
|
def mark_handoff_delivered(
|
|
164
|
+
wb: Any,
|
|
181
165
|
connection: sqlite3.Connection,
|
|
182
166
|
args: argparse.Namespace,
|
|
183
|
-
*,
|
|
184
|
-
now: Callable[[], str],
|
|
185
|
-
require_scan: Callable[[sqlite3.Connection, str], sqlite3.Row],
|
|
186
|
-
require_workspace: Callable[[sqlite3.Connection, str], sqlite3.Row],
|
|
187
|
-
workspace_state: Callable[[sqlite3.Connection, str], dict[str, Any]],
|
|
188
167
|
) -> dict[str, Any]:
|
|
189
168
|
scan_id = require_uuid(args.scan_id, "scan-id")
|
|
190
169
|
claim_token = require_handoff_claim_token(args.claim_token)
|
|
191
170
|
thread_id = optional_text(args.thread_id, maximum=512)
|
|
192
171
|
connection.execute("BEGIN IMMEDIATE")
|
|
193
|
-
|
|
194
|
-
timestamp = now()
|
|
195
|
-
scan = require_scan(connection, scan_id)
|
|
172
|
+
with connection:
|
|
173
|
+
timestamp = wb.now()
|
|
174
|
+
scan = wb.require_scan(connection, scan_id)
|
|
196
175
|
if thread_id is not None:
|
|
197
|
-
workspace = require_workspace(connection, scan["workspace_id"])
|
|
176
|
+
workspace = wb.require_workspace(connection, scan["workspace_id"])
|
|
198
177
|
validate_handoff_delivery_thread(
|
|
199
178
|
scan["continuation_thread_id"] or workspace["thread_id"],
|
|
200
179
|
thread_id,
|
|
@@ -206,7 +185,7 @@ def mark_handoff_delivered(
|
|
|
206
185
|
"Codex Security handoff delivery is owned by another continuation."
|
|
207
186
|
)
|
|
208
187
|
connection.commit()
|
|
209
|
-
return workspace_state(connection, scan["workspace_id"])
|
|
188
|
+
return wb.workspace_state(connection, scan["workspace_id"])
|
|
210
189
|
updated = connection.execute(
|
|
211
190
|
"""
|
|
212
191
|
UPDATE scans
|
|
@@ -231,8 +210,4 @@ def mark_handoff_delivered(
|
|
|
231
210
|
""",
|
|
232
211
|
(timestamp, scan["id"]),
|
|
233
212
|
)
|
|
234
|
-
|
|
235
|
-
except BaseException:
|
|
236
|
-
connection.rollback()
|
|
237
|
-
raise
|
|
238
|
-
return workspace_state(connection, scan["workspace_id"])
|
|
213
|
+
return wb.workspace_state(connection, scan["workspace_id"])
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Load TOML using the supported Python runtime."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
__all__ = ["tomllib"]
|
|
6
|
+
|
|
7
|
+
if sys.version_info < (3, 10):
|
|
8
|
+
raise SystemExit(
|
|
9
|
+
"Codex Security requires Python 3.10 or later. Update the Codex managed runtime "
|
|
10
|
+
"or set PYTHON to a supported interpreter, then restart Codex."
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
import tomllib as tomllib
|
|
15
|
+
except ModuleNotFoundError: # Python 3.10
|
|
16
|
+
try:
|
|
17
|
+
import tomli as tomllib
|
|
18
|
+
except ModuleNotFoundError as exc:
|
|
19
|
+
raise SystemExit(
|
|
20
|
+
"Codex Security requires tomli with Python 3.10. Install tomli for the selected "
|
|
21
|
+
"interpreter or set PYTHON to Python 3.11 or later, then restart Codex."
|
|
22
|
+
) from exc
|
|
@@ -6,13 +6,28 @@ import os
|
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
def state_dir() -> Path:
|
|
10
|
-
|
|
11
|
-
if
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
def state_dir(*, canonical: bool = True) -> Path:
|
|
10
|
+
configured = os.environ.get("CODEX_SECURITY_STATE_DIR")
|
|
11
|
+
if configured:
|
|
12
|
+
path = Path(configured).expanduser()
|
|
13
|
+
else:
|
|
14
|
+
codex_home = Path(
|
|
15
|
+
os.environ["CODEX_HOME"] if os.environ.get("CODEX_HOME", "").strip() else "~/.codex"
|
|
16
|
+
).expanduser()
|
|
17
|
+
path = codex_home / "state" / "plugins" / "codex-security"
|
|
18
|
+
return path.resolve() if canonical else path.absolute()
|
|
15
19
|
|
|
16
20
|
|
|
17
21
|
def resolve_scan_root(scan_root: str | None) -> Path:
|
|
18
22
|
return Path(scan_root).expanduser().resolve() if scan_root else state_dir() / "scans"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def create_private_directory(path: Path) -> None:
|
|
26
|
+
"""Create missing directories privately without changing existing permissions."""
|
|
27
|
+
try:
|
|
28
|
+
path.mkdir(mode=0o700, exist_ok=True)
|
|
29
|
+
except FileNotFoundError:
|
|
30
|
+
if path.parent == path:
|
|
31
|
+
raise
|
|
32
|
+
create_private_directory(path.parent)
|
|
33
|
+
path.mkdir(mode=0o700, exist_ok=True)
|