@openai/codex-security 0.2.0 → 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 +437 -2692
- package/_bundled_plugin/.app.json +5 -1
- package/_bundled_plugin/.codex-plugin/plugin.json +9 -5
- package/_bundled_plugin/.mcp.json +2 -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 +6 -213
- 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 +2 -2
- package/_bundled_plugin/references/config-preflight.md +0 -4
- package/_bundled_plugin/references/core-scan.md +21 -9
- package/_bundled_plugin/references/final-report.md +10 -12
- 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 +1 -2
- package/_bundled_plugin/references/scan-contract.md +9 -4
- 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 +1 -1
- package/_bundled_plugin/schemas/coverage.schema.json +1 -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 +18 -45
- 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 +169 -294
- 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 +26 -62
- package/_bundled_plugin/scripts/deep_scan_config.py +9 -11
- package/_bundled_plugin/scripts/deep_scan_workbench.py +129 -150
- package/_bundled_plugin/scripts/finalize_scan_contract.py +315 -232
- package/_bundled_plugin/scripts/finding_preview.py +39 -9
- package/_bundled_plugin/scripts/generate_in_scope_files.py +27 -77
- package/_bundled_plugin/scripts/generate_rank_input.py +99 -829
- package/_bundled_plugin/scripts/launch_codex_security_mcp +35 -10
- package/_bundled_plugin/scripts/launch_codex_security_mcp.cmd +5 -5
- package/_bundled_plugin/scripts/rank_preview.py +42 -918
- package/_bundled_plugin/scripts/report_projection.py +117 -172
- package/_bundled_plugin/scripts/snapshot_sqlite.py +6 -1
- package/_bundled_plugin/scripts/threat_model_projection.py +4 -7
- 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 +48 -3
- 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 +10 -6
- package/_bundled_plugin/scripts/workbench_cli.py +94 -179
- package/_bundled_plugin/scripts/workbench_db.py +427 -463
- package/_bundled_plugin/scripts/workbench_feedback.py +6 -3
- package/_bundled_plugin/scripts/workbench_finding_index.py +19 -1
- 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 +27 -14
- package/_bundled_plugin/scripts/workbench_progress.py +14 -58
- package/_bundled_plugin/scripts/workbench_publication.py +33 -57
- package/_bundled_plugin/scripts/workbench_remediation.py +12 -0
- package/_bundled_plugin/scripts/workbench_saved_results.py +172 -49
- package/_bundled_plugin/scripts/workbench_scan_history.py +57 -57
- package/_bundled_plugin/scripts/workbench_scan_start.py +105 -41
- package/_bundled_plugin/scripts/workbench_scan_usage.py +23 -34
- package/_bundled_plugin/scripts/workbench_schema.py +37 -1151
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +11 -1
- package/_bundled_plugin/scripts/workbench_target.py +430 -142
- package/_bundled_plugin/scripts/workbench_validation.py +16 -27
- 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 +3 -3
- 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 +1 -1
- package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +13 -1
- package/_bundled_plugin/skills/threat-model/SKILL.md +1 -1
- 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 +60 -10
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +803 -380
- package/dist/api.js.map +1 -1
- package/dist/artifact-export.d.ts +1 -1
- package/dist/artifact-export.d.ts.map +1 -1
- package/dist/artifact-export.js +28 -13
- package/dist/artifact-export.js.map +1 -1
- package/dist/auth.d.ts +2 -6
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +19 -9
- package/dist/auth.js.map +1 -1
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +1 -0
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/classify-severity.d.ts +26 -9
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +13 -30
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-help.d.ts.map +1 -1
- package/dist/cli-help.js +17 -13
- package/dist/cli-help.js.map +1 -1
- 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 +4 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1087 -900
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +10 -9
- 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-sdk-environment.d.ts +1 -0
- package/dist/codex-sdk-environment.d.ts.map +1 -1
- package/dist/codex-sdk-environment.js +40 -2
- package/dist/codex-sdk-environment.js.map +1 -1
- package/dist/component-plan.d.ts +2 -5
- package/dist/component-plan.d.ts.map +1 -1
- package/dist/component-plan.js +38 -30
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.d.ts +6 -5
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +23 -35
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +64 -74
- package/dist/config.js.map +1 -1
- package/dist/contract.d.ts +15 -3
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +87 -252
- 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 +14 -4
- 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 +102 -104
- package/dist/cost.js.map +1 -1
- package/dist/custom-validation-prompt.d.ts.map +1 -1
- package/dist/custom-validation-prompt.js +6 -5
- 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 +9 -3
- 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 +23 -9
- package/dist/deduplication/checkpointed-review.js.map +1 -1
- package/dist/deduplication/codex-review.d.ts +7 -1
- package/dist/deduplication/codex-review.d.ts.map +1 -1
- package/dist/deduplication/codex-review.js +126 -17
- 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 +57 -47
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/deduplication.d.ts.map +1 -1
- package/dist/deduplication/deduplication.js +19 -51
- 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 +11 -24
- package/dist/deduplication/records-protocol.js.map +1 -1
- package/dist/deduplication/records.d.ts +186 -11
- package/dist/deduplication/records.d.ts.map +1 -1
- package/dist/deduplication/records.js +10 -18
- package/dist/deduplication/records.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 +158 -39
- 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 +4 -4
- package/dist/deep-config.js.map +1 -1
- package/dist/deep-progress.d.ts +2 -0
- package/dist/deep-progress.d.ts.map +1 -1
- package/dist/deep-progress.js +13 -10
- 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 +2 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -0
- 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 +4 -8
- 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 +14 -6
- 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 +12 -30
- package/dist/findings-import.js.map +1 -1
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +7 -1
- package/dist/github.js.map +1 -1
- package/dist/import-scan.d.ts.map +1 -1
- package/dist/import-scan.js +48 -38
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -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 +114 -46
- package/dist/knowledge-base.js.map +1 -1
- package/dist/linear.d.ts.map +1 -1
- package/dist/linear.js +2 -7
- 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 +0 -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 +193 -126
- 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 +67 -8
- package/dist/owner-evidence.js.map +1 -1
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +3 -2
- package/dist/patch-tui.js.map +1 -1
- package/dist/project-config.js +3 -3
- package/dist/project-config.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 +25 -50
- package/dist/publication-events.js.map +1 -1
- package/dist/publication-store.d.ts.map +1 -1
- package/dist/publication-store.js +40 -64
- 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 +2 -8
- 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 +109 -160
- package/dist/publish.js.map +1 -1
- 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/runtime.d.ts +15 -4
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +430 -138
- 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 +6 -12
- package/dist/saved-scan.js.map +1 -1
- package/dist/scan-activity.js +11 -8
- package/dist/scan-activity.js.map +1 -1
- package/dist/scan-comparison.d.ts +28 -15
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +276 -281
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +3 -0
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +345 -77
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +54 -13
- 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 +12 -6
- 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 +17 -0
- package/dist/scan-sessions.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 +7 -27
- package/dist/security-policy-cli.js.map +1 -1
- package/dist/security-policy.d.ts +9 -5
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js +33 -14
- 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 +10 -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 +54 -44
- 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 +19 -24
- 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 +4 -2
- package/dist/suggest-owners.d.ts.map +1 -1
- package/dist/suggest-owners.js +11 -5
- package/dist/suggest-owners.js.map +1 -1
- package/dist/targets.d.ts +11 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +106 -47
- package/dist/targets.js.map +1 -1
- package/dist/trusted-executable.d.ts +2 -2
- package/dist/trusted-executable.d.ts.map +1 -1
- package/dist/trusted-executable.js +8 -6
- package/dist/trusted-executable.js.map +1 -1
- package/dist/value.js +7 -0
- package/dist/value.js.map +1 -1
- package/dist/version.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 +1 -0
- package/dist/worker-progress.d.ts.map +1 -1
- package/dist/worker-progress.js +27 -12
- package/dist/worker-progress.js.map +1 -1
- package/docs/cli.md +1778 -0
- package/docs/findings-service.md +402 -0
- package/package.json +18 -19
- package/_bundled_plugin/schemas/tools/worker-threat-model.schema.json +0 -18
- 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 -122
- 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/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 -7
- package/dist/server/routes.d.ts.map +0 -1
- package/dist/server/routes.js +0 -98
- 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 -16
- 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
|
@@ -4,934 +4,39 @@ import argparse
|
|
|
4
4
|
import json
|
|
5
5
|
import sqlite3
|
|
6
6
|
from collections.abc import Callable
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
target_title TEXT,
|
|
17
|
-
target_summary TEXT,
|
|
18
|
-
default_scope TEXT NOT NULL DEFAULT '.',
|
|
19
|
-
default_mode TEXT NOT NULL DEFAULT 'standard'
|
|
20
|
-
CHECK (default_mode IN ('diff', 'standard', 'deep')),
|
|
21
|
-
user_context TEXT,
|
|
22
|
-
diff_target_kind TEXT
|
|
23
|
-
CHECK (diff_target_kind IN ('working_tree', 'commit', 'range')),
|
|
24
|
-
diff_base_revision TEXT,
|
|
25
|
-
diff_head_revision TEXT,
|
|
26
|
-
diff_content_digest TEXT,
|
|
27
|
-
diff_resolution_id TEXT,
|
|
28
|
-
submitted INTEGER NOT NULL DEFAULT 0 CHECK (submitted IN (0, 1)),
|
|
29
|
-
active_scan_id TEXT REFERENCES scans(id) ON DELETE SET NULL,
|
|
30
|
-
created_at TEXT NOT NULL,
|
|
31
|
-
updated_at TEXT NOT NULL
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
CREATE TABLE scans (
|
|
35
|
-
id TEXT PRIMARY KEY,
|
|
36
|
-
workspace_id TEXT NOT NULL REFERENCES workspaces(id) ON DELETE CASCADE,
|
|
37
|
-
target_path TEXT NOT NULL,
|
|
38
|
-
target_revision TEXT NOT NULL,
|
|
39
|
-
target_snapshot_digest TEXT,
|
|
40
|
-
scope TEXT NOT NULL,
|
|
41
|
-
mode TEXT NOT NULL CHECK (mode IN ('diff', 'standard', 'deep')),
|
|
42
|
-
user_context TEXT,
|
|
43
|
-
diff_target_kind TEXT
|
|
44
|
-
CHECK (diff_target_kind IN ('working_tree', 'commit', 'range')),
|
|
45
|
-
diff_base_revision TEXT,
|
|
46
|
-
diff_head_revision TEXT,
|
|
47
|
-
diff_content_digest TEXT,
|
|
48
|
-
scan_dir TEXT NOT NULL UNIQUE,
|
|
49
|
-
status TEXT NOT NULL CHECK (status IN ('running', 'complete', 'failed')),
|
|
50
|
-
phase TEXT NOT NULL CHECK (
|
|
51
|
-
phase IN ('preflight', 'threat_model', 'discovery', 'validation', 'attack_path', 'reporting')
|
|
52
|
-
),
|
|
53
|
-
handoff_status TEXT NOT NULL DEFAULT 'pending'
|
|
54
|
-
CHECK (handoff_status IN ('pending', 'delivered')),
|
|
55
|
-
failure_message TEXT,
|
|
56
|
-
started_at TEXT NOT NULL,
|
|
57
|
-
completed_at TEXT,
|
|
58
|
-
created_at TEXT NOT NULL,
|
|
59
|
-
updated_at TEXT NOT NULL
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
CREATE TABLE scan_progress (
|
|
63
|
-
scan_id TEXT PRIMARY KEY REFERENCES scans(id) ON DELETE CASCADE,
|
|
64
|
-
review_items_total INTEGER NOT NULL DEFAULT 0 CHECK (review_items_total >= 0),
|
|
65
|
-
review_items_completed INTEGER NOT NULL DEFAULT 0
|
|
66
|
-
CHECK (review_items_completed >= 0 AND review_items_completed <= review_items_total),
|
|
67
|
-
reportable_findings_count INTEGER NOT NULL DEFAULT 0
|
|
68
|
-
CHECK (reportable_findings_count >= 0),
|
|
69
|
-
deep_review_pass INTEGER CHECK (deep_review_pass IS NULL OR deep_review_pass >= 1),
|
|
70
|
-
updated_at TEXT NOT NULL
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
CREATE TABLE scan_artifacts (
|
|
74
|
-
scan_id TEXT NOT NULL REFERENCES scans(id) ON DELETE CASCADE,
|
|
75
|
-
kind TEXT NOT NULL CHECK (
|
|
76
|
-
kind IN ('coverage', 'findings', 'manifest', 'markdownReport')
|
|
77
|
-
),
|
|
78
|
-
path TEXT NOT NULL,
|
|
79
|
-
created_at TEXT NOT NULL,
|
|
80
|
-
PRIMARY KEY (scan_id, kind)
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
CREATE TABLE findings (
|
|
84
|
-
id TEXT PRIMARY KEY,
|
|
85
|
-
fingerprint TEXT NOT NULL UNIQUE,
|
|
86
|
-
rule_id TEXT NOT NULL,
|
|
87
|
-
identity_anchor TEXT NOT NULL,
|
|
88
|
-
identity_instance TEXT,
|
|
89
|
-
created_at TEXT NOT NULL,
|
|
90
|
-
updated_at TEXT NOT NULL
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
CREATE TABLE finding_occurrences (
|
|
94
|
-
id TEXT PRIMARY KEY,
|
|
95
|
-
finding_id TEXT NOT NULL REFERENCES findings(id),
|
|
96
|
-
scan_id TEXT NOT NULL REFERENCES scans(id) ON DELETE CASCADE,
|
|
97
|
-
title TEXT NOT NULL,
|
|
98
|
-
summary TEXT NOT NULL,
|
|
99
|
-
severity TEXT NOT NULL,
|
|
100
|
-
confidence TEXT NOT NULL,
|
|
101
|
-
remediation TEXT NOT NULL,
|
|
102
|
-
created_at TEXT NOT NULL,
|
|
103
|
-
UNIQUE (scan_id, finding_id)
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
CREATE TABLE finding_locations (
|
|
107
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
108
|
-
occurrence_id TEXT NOT NULL REFERENCES finding_occurrences(id) ON DELETE CASCADE,
|
|
109
|
-
relative_path TEXT NOT NULL,
|
|
110
|
-
start_line INTEGER NOT NULL CHECK (start_line >= 1),
|
|
111
|
-
end_line INTEGER NOT NULL CHECK (end_line >= start_line),
|
|
112
|
-
role TEXT,
|
|
113
|
-
sort_order INTEGER NOT NULL CHECK (sort_order >= 0),
|
|
114
|
-
UNIQUE (occurrence_id, sort_order)
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
CREATE UNIQUE INDEX scans_one_running_per_workspace
|
|
118
|
-
ON scans(workspace_id)
|
|
119
|
-
WHERE status = 'running';
|
|
120
|
-
""",
|
|
121
|
-
),
|
|
122
|
-
(
|
|
123
|
-
2,
|
|
124
|
-
"persist capability preflight summaries",
|
|
125
|
-
"""
|
|
126
|
-
ALTER TABLE workspaces ADD COLUMN capability_preflight_json TEXT;
|
|
127
|
-
""",
|
|
128
|
-
),
|
|
129
|
-
(
|
|
130
|
-
3,
|
|
131
|
-
"finding management schema",
|
|
132
|
-
"""
|
|
133
|
-
CREATE TABLE finding_triage (
|
|
134
|
-
occurrence_id TEXT PRIMARY KEY REFERENCES finding_occurrences(id) ON DELETE CASCADE,
|
|
135
|
-
status TEXT NOT NULL CHECK (status IN ('open', 'closed')),
|
|
136
|
-
close_reason TEXT CHECK (
|
|
137
|
-
close_reason IS NULL OR close_reason IN ('already_fixed', 'wont_fix', 'false_positive')
|
|
138
|
-
),
|
|
139
|
-
note TEXT,
|
|
140
|
-
updated_at TEXT NOT NULL,
|
|
141
|
-
CHECK (
|
|
142
|
-
(status = 'open' AND close_reason IS NULL)
|
|
143
|
-
OR (status = 'closed' AND close_reason IS NOT NULL)
|
|
144
|
-
)
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
CREATE TABLE finding_remediation_attempts (
|
|
148
|
-
request_id TEXT PRIMARY KEY,
|
|
149
|
-
occurrence_id TEXT NOT NULL REFERENCES finding_occurrences(id) ON DELETE CASCADE,
|
|
150
|
-
state TEXT NOT NULL CHECK (
|
|
151
|
-
state IN ('idle', 'requested', 'generated', 'applied', 'verifying', 'verified', 'failed', 'superseded')
|
|
152
|
-
),
|
|
153
|
-
version INTEGER NOT NULL CHECK (version >= 1),
|
|
154
|
-
base_revision TEXT NOT NULL,
|
|
155
|
-
base_content_digest TEXT,
|
|
156
|
-
applied_content_digest TEXT,
|
|
157
|
-
pending_action TEXT CHECK (
|
|
158
|
-
pending_action IS NULL OR pending_action IN ('generate', 'apply', 'verify')
|
|
159
|
-
),
|
|
160
|
-
patch_path TEXT,
|
|
161
|
-
patch_digest TEXT,
|
|
162
|
-
summary TEXT,
|
|
163
|
-
verification_summary TEXT,
|
|
164
|
-
created_at TEXT NOT NULL,
|
|
165
|
-
updated_at TEXT NOT NULL
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
CREATE INDEX finding_remediation_attempts_by_occurrence
|
|
169
|
-
ON finding_remediation_attempts(occurrence_id, created_at DESC);
|
|
170
|
-
|
|
171
|
-
ALTER TABLE finding_occurrences
|
|
172
|
-
ADD COLUMN details_json TEXT NOT NULL DEFAULT '{}';
|
|
173
|
-
|
|
174
|
-
""",
|
|
175
|
-
),
|
|
176
|
-
(
|
|
177
|
-
4,
|
|
178
|
-
"scan handoff delivery claims",
|
|
179
|
-
"""
|
|
180
|
-
ALTER TABLE scans
|
|
181
|
-
ADD COLUMN handoff_claimed_at TEXT;
|
|
182
|
-
|
|
183
|
-
ALTER TABLE scans
|
|
184
|
-
ADD COLUMN handoff_claim_token TEXT;
|
|
185
|
-
""",
|
|
186
|
-
),
|
|
187
|
-
(
|
|
188
|
-
5,
|
|
189
|
-
"finding remediation action claims",
|
|
190
|
-
"""
|
|
191
|
-
ALTER TABLE finding_remediation_attempts
|
|
192
|
-
ADD COLUMN pending_action_claimed_at TEXT;
|
|
193
|
-
|
|
194
|
-
ALTER TABLE finding_remediation_attempts
|
|
195
|
-
ADD COLUMN pending_action_claim_token TEXT;
|
|
196
|
-
""",
|
|
197
|
-
),
|
|
198
|
-
(
|
|
199
|
-
6,
|
|
200
|
-
"thread-scoped workspaces",
|
|
201
|
-
"""
|
|
202
|
-
ALTER TABLE workspaces
|
|
203
|
-
ADD COLUMN thread_id TEXT;
|
|
204
|
-
|
|
205
|
-
CREATE INDEX workspaces_by_thread_and_updated_at
|
|
206
|
-
ON workspaces(thread_id, updated_at DESC);
|
|
207
|
-
""",
|
|
208
|
-
),
|
|
209
|
-
(
|
|
210
|
-
7,
|
|
211
|
-
"remediation host delivery state",
|
|
212
|
-
"""
|
|
213
|
-
ALTER TABLE finding_remediation_attempts
|
|
214
|
-
ADD COLUMN pending_action_delivered_at TEXT;
|
|
215
|
-
""",
|
|
216
|
-
),
|
|
217
|
-
(
|
|
218
|
-
8,
|
|
219
|
-
"sealed manifest digests",
|
|
220
|
-
"""
|
|
221
|
-
ALTER TABLE scans
|
|
222
|
-
ADD COLUMN seal_manifest_digest TEXT;
|
|
223
|
-
""",
|
|
224
|
-
),
|
|
225
|
-
(
|
|
226
|
-
9,
|
|
227
|
-
"scan target filesystem identity",
|
|
228
|
-
"""
|
|
229
|
-
ALTER TABLE scans
|
|
230
|
-
ADD COLUMN target_device INTEGER;
|
|
231
|
-
|
|
232
|
-
ALTER TABLE scans
|
|
233
|
-
ADD COLUMN target_inode INTEGER;
|
|
234
|
-
""",
|
|
235
|
-
),
|
|
236
|
-
(
|
|
237
|
-
10,
|
|
238
|
-
"scan cancellation state",
|
|
239
|
-
"""
|
|
240
|
-
ALTER TABLE scans
|
|
241
|
-
ADD COLUMN canceled_at TEXT;
|
|
242
|
-
""",
|
|
243
|
-
),
|
|
244
|
-
(
|
|
245
|
-
11,
|
|
246
|
-
"deep scan orchestration state",
|
|
247
|
-
"""
|
|
248
|
-
ALTER TABLE scans
|
|
249
|
-
ADD COLUMN deep_scan_owner_thread_id TEXT;
|
|
250
|
-
|
|
251
|
-
UPDATE scans
|
|
252
|
-
SET deep_scan_owner_thread_id = (
|
|
253
|
-
SELECT workspaces.thread_id
|
|
254
|
-
FROM workspaces
|
|
255
|
-
WHERE workspaces.id = scans.workspace_id
|
|
256
|
-
)
|
|
257
|
-
WHERE mode = 'deep'
|
|
258
|
-
AND status = 'running'
|
|
259
|
-
AND id IN (
|
|
260
|
-
SELECT MIN(active_scans.id)
|
|
261
|
-
FROM scans AS active_scans
|
|
262
|
-
JOIN workspaces AS active_workspaces
|
|
263
|
-
ON active_workspaces.id = active_scans.workspace_id
|
|
264
|
-
WHERE active_scans.mode = 'deep'
|
|
265
|
-
AND active_scans.status = 'running'
|
|
266
|
-
AND active_workspaces.thread_id IS NOT NULL
|
|
267
|
-
GROUP BY active_workspaces.thread_id,
|
|
268
|
-
active_scans.target_path,
|
|
269
|
-
active_scans.scope
|
|
270
|
-
);
|
|
271
|
-
|
|
272
|
-
CREATE UNIQUE INDEX scans_one_running_deep_per_owner_target
|
|
273
|
-
ON scans(deep_scan_owner_thread_id, target_path, scope)
|
|
274
|
-
WHERE mode = 'deep'
|
|
275
|
-
AND status = 'running'
|
|
276
|
-
AND deep_scan_owner_thread_id IS NOT NULL;
|
|
277
|
-
|
|
278
|
-
CREATE TABLE deep_scan_runs (
|
|
279
|
-
scan_id TEXT PRIMARY KEY REFERENCES scans(id) ON DELETE CASCADE,
|
|
280
|
-
schema_version INTEGER NOT NULL CHECK (schema_version = 1),
|
|
281
|
-
workflow_version TEXT NOT NULL,
|
|
282
|
-
coordinator_generation INTEGER NOT NULL DEFAULT 1
|
|
283
|
-
CHECK (coordinator_generation >= 1),
|
|
284
|
-
status TEXT NOT NULL CHECK (
|
|
285
|
-
status IN ('running', 'succeeded', 'failed', 'canceled', 'interrupted')
|
|
286
|
-
),
|
|
287
|
-
phase TEXT NOT NULL CHECK (
|
|
288
|
-
phase IN ('setup', 'discovery', 'reducing', 'terminal')
|
|
289
|
-
),
|
|
290
|
-
workers INTEGER NOT NULL CHECK (workers >= 1),
|
|
291
|
-
subagents INTEGER NOT NULL CHECK (subagents >= 0),
|
|
292
|
-
stop_after_no_new INTEGER NOT NULL CHECK (stop_after_no_new >= 1),
|
|
293
|
-
max_discovery_runs INTEGER NOT NULL CHECK (max_discovery_runs >= 1),
|
|
294
|
-
discovery_runs_dispatched INTEGER NOT NULL DEFAULT 0
|
|
295
|
-
CHECK (discovery_runs_dispatched >= 0),
|
|
296
|
-
completion_sequence INTEGER NOT NULL DEFAULT 0
|
|
297
|
-
CHECK (completion_sequence >= 0),
|
|
298
|
-
consecutive_no_new INTEGER NOT NULL DEFAULT 0
|
|
299
|
-
CHECK (consecutive_no_new >= 0),
|
|
300
|
-
cancel_requested INTEGER NOT NULL DEFAULT 0
|
|
301
|
-
CHECK (cancel_requested IN (0, 1)),
|
|
302
|
-
canonical_inventory_path TEXT,
|
|
303
|
-
canonical_finding_report_path TEXT,
|
|
304
|
-
canonical_candidates_path TEXT,
|
|
305
|
-
dedupe_report_path TEXT,
|
|
306
|
-
seed_research_path TEXT,
|
|
307
|
-
work_ledger_path TEXT,
|
|
308
|
-
raw_candidates_path TEXT,
|
|
309
|
-
coverage_ledger_path TEXT,
|
|
310
|
-
findings_dir TEXT,
|
|
311
|
-
manifest_path TEXT,
|
|
312
|
-
terminal_reason TEXT CHECK (
|
|
313
|
-
terminal_reason IS NULL OR terminal_reason IN ('saturated', 'capped')
|
|
314
|
-
),
|
|
315
|
-
error_message TEXT,
|
|
316
|
-
created_at TEXT NOT NULL,
|
|
317
|
-
updated_at TEXT NOT NULL,
|
|
318
|
-
completed_at TEXT,
|
|
319
|
-
CHECK (
|
|
320
|
-
(
|
|
321
|
-
canonical_inventory_path IS NULL
|
|
322
|
-
AND canonical_finding_report_path IS NULL
|
|
323
|
-
AND canonical_candidates_path IS NULL
|
|
324
|
-
AND dedupe_report_path IS NULL
|
|
325
|
-
AND seed_research_path IS NULL
|
|
326
|
-
AND work_ledger_path IS NULL
|
|
327
|
-
AND raw_candidates_path IS NULL
|
|
328
|
-
AND coverage_ledger_path IS NULL
|
|
329
|
-
AND findings_dir IS NULL
|
|
330
|
-
) OR (
|
|
331
|
-
canonical_inventory_path IS NOT NULL
|
|
332
|
-
AND canonical_finding_report_path IS NOT NULL
|
|
333
|
-
AND canonical_candidates_path IS NOT NULL
|
|
334
|
-
AND dedupe_report_path IS NOT NULL
|
|
335
|
-
AND seed_research_path IS NOT NULL
|
|
336
|
-
AND work_ledger_path IS NOT NULL
|
|
337
|
-
AND raw_candidates_path IS NOT NULL
|
|
338
|
-
AND coverage_ledger_path IS NOT NULL
|
|
339
|
-
AND findings_dir IS NOT NULL
|
|
340
|
-
)
|
|
341
|
-
)
|
|
342
|
-
);
|
|
343
|
-
|
|
344
|
-
CREATE TABLE deep_scan_workers (
|
|
345
|
-
id TEXT PRIMARY KEY,
|
|
346
|
-
scan_id TEXT NOT NULL REFERENCES deep_scan_runs(scan_id) ON DELETE CASCADE,
|
|
347
|
-
kind TEXT NOT NULL CHECK (kind IN ('setup', 'discovery', 'dedup')),
|
|
348
|
-
status TEXT NOT NULL CHECK (
|
|
349
|
-
status IN ('queued', 'running', 'succeeded', 'failed', 'canceled')
|
|
350
|
-
),
|
|
351
|
-
merge_state TEXT NOT NULL DEFAULT 'none' CHECK (
|
|
352
|
-
merge_state IN ('none', 'buffered', 'merging', 'merged')
|
|
353
|
-
),
|
|
354
|
-
prompt_path TEXT NOT NULL,
|
|
355
|
-
artifact_dir TEXT NOT NULL,
|
|
356
|
-
result_manifest_path TEXT,
|
|
357
|
-
attempt INTEGER NOT NULL DEFAULT 0 CHECK (attempt >= 0),
|
|
358
|
-
sdk_thread_id TEXT,
|
|
359
|
-
completion_sequence INTEGER CHECK (completion_sequence >= 1),
|
|
360
|
-
error_message TEXT,
|
|
361
|
-
created_at TEXT NOT NULL,
|
|
362
|
-
started_at TEXT,
|
|
363
|
-
completed_at TEXT,
|
|
364
|
-
updated_at TEXT NOT NULL,
|
|
365
|
-
UNIQUE (scan_id, id),
|
|
366
|
-
CHECK (kind = 'discovery' OR merge_state = 'none'),
|
|
367
|
-
CHECK (kind = 'discovery' OR completion_sequence IS NULL)
|
|
368
|
-
);
|
|
369
|
-
|
|
370
|
-
CREATE UNIQUE INDEX deep_scan_workers_completion_sequence
|
|
371
|
-
ON deep_scan_workers(scan_id, completion_sequence)
|
|
372
|
-
WHERE completion_sequence IS NOT NULL;
|
|
373
|
-
|
|
374
|
-
CREATE INDEX deep_scan_workers_by_scan_status
|
|
375
|
-
ON deep_scan_workers(scan_id, status, kind, created_at);
|
|
376
|
-
|
|
377
|
-
CREATE TABLE deep_scan_dedup_inputs (
|
|
378
|
-
scan_id TEXT NOT NULL,
|
|
379
|
-
dedup_worker_id TEXT NOT NULL,
|
|
380
|
-
discovery_worker_id TEXT NOT NULL,
|
|
381
|
-
input_order INTEGER NOT NULL CHECK (input_order >= 0),
|
|
382
|
-
PRIMARY KEY (dedup_worker_id, discovery_worker_id),
|
|
383
|
-
UNIQUE (dedup_worker_id, input_order),
|
|
384
|
-
FOREIGN KEY (scan_id, dedup_worker_id)
|
|
385
|
-
REFERENCES deep_scan_workers(scan_id, id) ON DELETE CASCADE,
|
|
386
|
-
FOREIGN KEY (scan_id, discovery_worker_id)
|
|
387
|
-
REFERENCES deep_scan_workers(scan_id, id) ON DELETE CASCADE
|
|
388
|
-
);
|
|
389
|
-
""",
|
|
390
|
-
),
|
|
391
|
-
(
|
|
392
|
-
12,
|
|
393
|
-
"scan continuation threads",
|
|
394
|
-
"""
|
|
395
|
-
ALTER TABLE scans
|
|
396
|
-
ADD COLUMN continuation_thread_id TEXT;
|
|
397
|
-
""",
|
|
398
|
-
),
|
|
399
|
-
(
|
|
400
|
-
13,
|
|
401
|
-
"scan scope file counts",
|
|
402
|
-
"""
|
|
403
|
-
ALTER TABLE scan_progress
|
|
404
|
-
ADD COLUMN scope_file_count INTEGER
|
|
405
|
-
CHECK (scope_file_count >= 0);
|
|
406
|
-
""",
|
|
407
|
-
),
|
|
408
|
-
(
|
|
409
|
-
14,
|
|
410
|
-
"imported triage results",
|
|
411
|
-
"""
|
|
412
|
-
CREATE TABLE triage_results (
|
|
413
|
-
id TEXT PRIMARY KEY,
|
|
414
|
-
repository_path TEXT NOT NULL,
|
|
415
|
-
repository_revision TEXT,
|
|
416
|
-
finding_count INTEGER NOT NULL CHECK (finding_count >= 0),
|
|
417
|
-
result_json TEXT NOT NULL,
|
|
418
|
-
created_at TEXT NOT NULL,
|
|
419
|
-
updated_at TEXT NOT NULL
|
|
420
|
-
);
|
|
421
|
-
|
|
422
|
-
CREATE INDEX triage_results_by_updated_at
|
|
423
|
-
ON triage_results(updated_at DESC, id);
|
|
424
|
-
""",
|
|
425
|
-
),
|
|
426
|
-
(
|
|
427
|
-
15,
|
|
428
|
-
"append-only finding decisions",
|
|
429
|
-
"""
|
|
430
|
-
CREATE TABLE finding_decisions (
|
|
431
|
-
id TEXT PRIMARY KEY,
|
|
432
|
-
occurrence_id TEXT NOT NULL REFERENCES finding_occurrences(id) ON DELETE CASCADE,
|
|
433
|
-
status TEXT NOT NULL CHECK (status IN ('open', 'closed')),
|
|
434
|
-
close_reason TEXT CHECK (
|
|
435
|
-
close_reason IS NULL OR close_reason IN ('already_fixed', 'wont_fix', 'false_positive')
|
|
436
|
-
),
|
|
437
|
-
note TEXT,
|
|
438
|
-
created_at TEXT NOT NULL,
|
|
439
|
-
CHECK (
|
|
440
|
-
(status = 'open' AND close_reason IS NULL)
|
|
441
|
-
OR (status = 'closed' AND close_reason IS NOT NULL)
|
|
442
|
-
)
|
|
443
|
-
);
|
|
444
|
-
|
|
445
|
-
CREATE INDEX finding_decisions_by_occurrence
|
|
446
|
-
ON finding_decisions(occurrence_id, created_at DESC, id DESC);
|
|
447
|
-
|
|
448
|
-
INSERT INTO finding_decisions (
|
|
449
|
-
id, occurrence_id, status, close_reason, note, created_at
|
|
450
|
-
)
|
|
451
|
-
SELECT
|
|
452
|
-
'legacy_' || occurrence_id,
|
|
453
|
-
occurrence_id,
|
|
454
|
-
status,
|
|
455
|
-
close_reason,
|
|
456
|
-
note,
|
|
457
|
-
updated_at
|
|
458
|
-
FROM finding_triage;
|
|
459
|
-
""",
|
|
460
|
-
),
|
|
461
|
-
(
|
|
462
|
-
16,
|
|
463
|
-
"stable repository targets",
|
|
464
|
-
"""
|
|
465
|
-
CREATE TABLE security_targets (
|
|
466
|
-
id TEXT PRIMARY KEY,
|
|
467
|
-
current_path TEXT NOT NULL UNIQUE,
|
|
468
|
-
display_name TEXT NOT NULL,
|
|
469
|
-
created_at TEXT NOT NULL,
|
|
470
|
-
updated_at TEXT NOT NULL
|
|
471
|
-
);
|
|
472
|
-
|
|
473
|
-
ALTER TABLE workspaces
|
|
474
|
-
ADD COLUMN target_id TEXT REFERENCES security_targets(id);
|
|
475
|
-
|
|
476
|
-
ALTER TABLE scans
|
|
477
|
-
ADD COLUMN target_id TEXT REFERENCES security_targets(id);
|
|
478
|
-
|
|
479
|
-
CREATE INDEX scans_by_target
|
|
480
|
-
ON scans(target_id, started_at DESC, id);
|
|
481
|
-
""",
|
|
482
|
-
),
|
|
483
|
-
(
|
|
484
|
-
17,
|
|
485
|
-
"scan target summaries",
|
|
486
|
-
"""
|
|
487
|
-
ALTER TABLE scans
|
|
488
|
-
ADD COLUMN target_summary TEXT;
|
|
489
|
-
""",
|
|
490
|
-
),
|
|
491
|
-
(
|
|
492
|
-
18,
|
|
493
|
-
"clear legacy delivered handoff claims",
|
|
494
|
-
"""
|
|
495
|
-
UPDATE scans
|
|
496
|
-
SET handoff_claimed_at = NULL, handoff_claim_token = NULL
|
|
497
|
-
WHERE handoff_status = 'delivered';
|
|
498
|
-
""",
|
|
499
|
-
),
|
|
500
|
-
(
|
|
501
|
-
19,
|
|
502
|
-
"persist setup workspace preference",
|
|
503
|
-
"""
|
|
504
|
-
CREATE TABLE setup_preferences (
|
|
505
|
-
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
506
|
-
skip_setup_ui INTEGER NOT NULL CHECK (skip_setup_ui IN (0, 1)),
|
|
507
|
-
updated_at TEXT NOT NULL
|
|
508
|
-
);
|
|
509
|
-
""",
|
|
510
|
-
),
|
|
511
|
-
(
|
|
512
|
-
20,
|
|
513
|
-
"phase-specific scan progress",
|
|
514
|
-
"""
|
|
515
|
-
ALTER TABLE scan_progress
|
|
516
|
-
ADD COLUMN phase_items_total INTEGER NOT NULL DEFAULT 0
|
|
517
|
-
CHECK (phase_items_total >= 0);
|
|
518
|
-
|
|
519
|
-
ALTER TABLE scan_progress
|
|
520
|
-
ADD COLUMN phase_items_completed INTEGER NOT NULL DEFAULT 0
|
|
521
|
-
CHECK (phase_items_completed >= 0 AND phase_items_completed <= phase_items_total);
|
|
522
|
-
|
|
523
|
-
ALTER TABLE scan_progress
|
|
524
|
-
ADD COLUMN phase_progress_unit TEXT CHECK (
|
|
525
|
-
phase_progress_unit IS NULL OR phase_progress_unit IN (
|
|
526
|
-
'checks',
|
|
527
|
-
'threat_surfaces',
|
|
528
|
-
'review_receipts',
|
|
529
|
-
'candidate_findings',
|
|
530
|
-
'validated_findings',
|
|
531
|
-
'report_artifacts'
|
|
532
|
-
)
|
|
533
|
-
);
|
|
534
|
-
""",
|
|
535
|
-
),
|
|
536
|
-
(
|
|
537
|
-
21,
|
|
538
|
-
"current scan preflight state",
|
|
539
|
-
"""
|
|
540
|
-
ALTER TABLE scan_progress
|
|
541
|
-
ADD COLUMN preflight_issues_json TEXT NOT NULL DEFAULT '[]';
|
|
542
|
-
|
|
543
|
-
ALTER TABLE scan_progress
|
|
544
|
-
ADD COLUMN preflight_checks_total INTEGER NOT NULL DEFAULT 0
|
|
545
|
-
CHECK (preflight_checks_total >= 0);
|
|
546
|
-
|
|
547
|
-
ALTER TABLE scan_progress
|
|
548
|
-
ADD COLUMN preflight_checks_completed INTEGER NOT NULL DEFAULT 0
|
|
549
|
-
CHECK (
|
|
550
|
-
preflight_checks_completed >= 0
|
|
551
|
-
AND preflight_checks_completed <= preflight_checks_total
|
|
552
|
-
);
|
|
553
|
-
|
|
554
|
-
""",
|
|
555
|
-
),
|
|
556
|
-
(
|
|
557
|
-
22,
|
|
558
|
-
"replayable scan launch recipes",
|
|
559
|
-
"""
|
|
560
|
-
ALTER TABLE scans ADD COLUMN recipe_json TEXT;
|
|
561
|
-
ALTER TABLE scans ADD COLUMN parent_scan_id TEXT REFERENCES scans(id) ON DELETE SET NULL;
|
|
562
|
-
""",
|
|
563
|
-
),
|
|
564
|
-
(
|
|
565
|
-
23,
|
|
566
|
-
"semantic scan comparison matches",
|
|
567
|
-
"""
|
|
568
|
-
CREATE TABLE scan_comparisons (
|
|
569
|
-
before_scan_id TEXT NOT NULL REFERENCES scans(id) ON DELETE CASCADE,
|
|
570
|
-
after_scan_id TEXT NOT NULL REFERENCES scans(id) ON DELETE CASCADE,
|
|
571
|
-
result_json TEXT NOT NULL,
|
|
572
|
-
created_at TEXT NOT NULL,
|
|
573
|
-
updated_at TEXT NOT NULL,
|
|
574
|
-
PRIMARY KEY (before_scan_id, after_scan_id),
|
|
575
|
-
CHECK (before_scan_id != after_scan_id)
|
|
576
|
-
);
|
|
577
|
-
|
|
578
|
-
CREATE TABLE scan_comparison_matches (
|
|
579
|
-
before_scan_id TEXT NOT NULL,
|
|
580
|
-
after_scan_id TEXT NOT NULL,
|
|
581
|
-
before_occurrence_id TEXT NOT NULL
|
|
582
|
-
REFERENCES finding_occurrences(id) ON DELETE CASCADE,
|
|
583
|
-
after_occurrence_id TEXT NOT NULL
|
|
584
|
-
REFERENCES finding_occurrences(id) ON DELETE CASCADE,
|
|
585
|
-
reason TEXT NOT NULL,
|
|
586
|
-
PRIMARY KEY (
|
|
587
|
-
before_scan_id, after_scan_id, before_occurrence_id, after_occurrence_id
|
|
588
|
-
),
|
|
589
|
-
FOREIGN KEY (before_scan_id, after_scan_id)
|
|
590
|
-
REFERENCES scan_comparisons(before_scan_id, after_scan_id) ON DELETE CASCADE
|
|
591
|
-
);
|
|
592
|
-
|
|
593
|
-
CREATE INDEX scan_comparison_matches_by_before_occurrence
|
|
594
|
-
ON scan_comparison_matches(before_occurrence_id);
|
|
595
|
-
|
|
596
|
-
CREATE INDEX scan_comparison_matches_by_after_occurrence
|
|
597
|
-
ON scan_comparison_matches(after_occurrence_id);
|
|
598
|
-
""",
|
|
599
|
-
),
|
|
600
|
-
(
|
|
601
|
-
24,
|
|
602
|
-
"persist scan cost estimates",
|
|
603
|
-
"""
|
|
604
|
-
ALTER TABLE scans ADD COLUMN cost_json TEXT;
|
|
605
|
-
""",
|
|
606
|
-
),
|
|
607
|
-
(
|
|
608
|
-
25,
|
|
609
|
-
"persist scan model settings",
|
|
610
|
-
"""
|
|
611
|
-
ALTER TABLE scans ADD COLUMN model TEXT;
|
|
612
|
-
ALTER TABLE scans ADD COLUMN reasoning_effort TEXT;
|
|
613
|
-
""",
|
|
614
|
-
),
|
|
615
|
-
(
|
|
616
|
-
26,
|
|
617
|
-
"persist scan completion warnings",
|
|
618
|
-
"""
|
|
619
|
-
ALTER TABLE scans
|
|
620
|
-
ADD COLUMN completion_warnings_json TEXT NOT NULL DEFAULT '[]';
|
|
621
|
-
""",
|
|
622
|
-
),
|
|
623
|
-
(
|
|
624
|
-
27,
|
|
625
|
-
"persist deep scan consecutive discovery failures",
|
|
626
|
-
"""
|
|
627
|
-
ALTER TABLE deep_scan_runs
|
|
628
|
-
ADD COLUMN stop_after_consecutive_errors INTEGER NOT NULL DEFAULT 1
|
|
629
|
-
CHECK (stop_after_consecutive_errors >= 1);
|
|
630
|
-
|
|
631
|
-
ALTER TABLE deep_scan_runs
|
|
632
|
-
ADD COLUMN consecutive_errors INTEGER NOT NULL DEFAULT 0
|
|
633
|
-
CHECK (consecutive_errors >= 0);
|
|
634
|
-
|
|
635
|
-
UPDATE deep_scan_runs
|
|
636
|
-
SET stop_after_consecutive_errors = stop_after_no_new;
|
|
637
|
-
""",
|
|
638
|
-
),
|
|
639
|
-
(
|
|
640
|
-
28,
|
|
641
|
-
"persist deep scan discovery time limit",
|
|
642
|
-
"""
|
|
643
|
-
ALTER TABLE deep_scan_runs
|
|
644
|
-
ADD COLUMN max_time_hours REAL NOT NULL DEFAULT 96;
|
|
645
|
-
""",
|
|
646
|
-
),
|
|
647
|
-
(
|
|
648
|
-
29,
|
|
649
|
-
"persist finding publication associations",
|
|
650
|
-
"""
|
|
651
|
-
CREATE TABLE finding_publications (
|
|
652
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
653
|
-
scan_id TEXT NOT NULL REFERENCES scans(id) ON DELETE CASCADE,
|
|
654
|
-
finding_id TEXT NOT NULL REFERENCES findings(id),
|
|
655
|
-
occurrence_id TEXT NOT NULL
|
|
656
|
-
REFERENCES finding_occurrences(id) ON DELETE CASCADE,
|
|
657
|
-
destination_type TEXT NOT NULL,
|
|
658
|
-
team_id TEXT,
|
|
659
|
-
project_id TEXT,
|
|
660
|
-
external_id TEXT NOT NULL,
|
|
661
|
-
external_url TEXT,
|
|
662
|
-
created_at TEXT NOT NULL,
|
|
663
|
-
UNIQUE (occurrence_id, destination_type, team_id, project_id, external_id),
|
|
664
|
-
UNIQUE (destination_type, team_id, project_id, external_id)
|
|
665
|
-
);
|
|
666
|
-
|
|
667
|
-
CREATE INDEX finding_publications_by_scan
|
|
668
|
-
ON finding_publications(scan_id, occurrence_id, id);
|
|
669
|
-
|
|
670
|
-
CREATE INDEX finding_publications_by_finding
|
|
671
|
-
ON finding_publications(finding_id, id);
|
|
672
|
-
""",
|
|
673
|
-
),
|
|
674
|
-
(
|
|
675
|
-
30,
|
|
676
|
-
"preserve team-only finding publication associations",
|
|
677
|
-
"""
|
|
678
|
-
CREATE UNIQUE INDEX finding_publications_team_only_occurrence
|
|
679
|
-
ON finding_publications(occurrence_id, destination_type, team_id, external_id)
|
|
680
|
-
WHERE project_id IS NULL;
|
|
681
|
-
|
|
682
|
-
CREATE UNIQUE INDEX finding_publications_team_only_external_issue
|
|
683
|
-
ON finding_publications(destination_type, team_id, external_id)
|
|
684
|
-
WHERE project_id IS NULL;
|
|
685
|
-
""",
|
|
686
|
-
),
|
|
687
|
-
(
|
|
688
|
-
31,
|
|
689
|
-
"freeze stopped scan source digests",
|
|
690
|
-
"""
|
|
691
|
-
ALTER TABLE scans ADD COLUMN retained_source_digests_json TEXT;
|
|
692
|
-
""",
|
|
693
|
-
),
|
|
694
|
-
(
|
|
695
|
-
32,
|
|
696
|
-
"separate deep scan publication failures",
|
|
697
|
-
"""
|
|
698
|
-
ALTER TABLE deep_scan_runs ADD COLUMN publication_error_message TEXT;
|
|
699
|
-
""",
|
|
700
|
-
),
|
|
701
|
-
(
|
|
702
|
-
33,
|
|
703
|
-
"store complete findings and embeddings without a scan",
|
|
704
|
-
"""
|
|
705
|
-
ALTER TABLE findings ADD COLUMN details_json TEXT;
|
|
706
|
-
|
|
707
|
-
UPDATE findings SET details_json = (
|
|
708
|
-
SELECT details_json FROM finding_occurrences
|
|
709
|
-
WHERE finding_id = findings.id AND details_json != '{}'
|
|
710
|
-
ORDER BY created_at DESC, id DESC LIMIT 1
|
|
711
|
-
);
|
|
712
|
-
|
|
713
|
-
CREATE TABLE finding_embeddings (
|
|
714
|
-
finding_id TEXT PRIMARY KEY REFERENCES findings(id) ON DELETE CASCADE,
|
|
715
|
-
model TEXT NOT NULL,
|
|
716
|
-
vector_json TEXT NOT NULL
|
|
717
|
-
);
|
|
718
|
-
|
|
719
|
-
CREATE TRIGGER invalidate_finding_embedding
|
|
720
|
-
AFTER UPDATE OF details_json ON findings
|
|
721
|
-
WHEN OLD.details_json IS NOT NEW.details_json
|
|
722
|
-
BEGIN
|
|
723
|
-
DELETE FROM finding_embeddings WHERE finding_id = NEW.id;
|
|
724
|
-
END;
|
|
725
|
-
""",
|
|
726
|
-
),
|
|
727
|
-
(
|
|
728
|
-
34,
|
|
729
|
-
"associate findings with repositories",
|
|
730
|
-
"""
|
|
731
|
-
CREATE TABLE finding_repositories (
|
|
732
|
-
repository_id TEXT NOT NULL,
|
|
733
|
-
finding_id TEXT NOT NULL REFERENCES findings(id) ON DELETE CASCADE,
|
|
734
|
-
PRIMARY KEY (repository_id, finding_id)
|
|
735
|
-
);
|
|
736
|
-
|
|
737
|
-
INSERT OR IGNORE INTO finding_repositories (repository_id, finding_id)
|
|
738
|
-
SELECT scans.target_id, finding_occurrences.finding_id
|
|
739
|
-
FROM finding_occurrences JOIN scans ON scans.id = finding_occurrences.scan_id
|
|
740
|
-
WHERE scans.target_id IS NOT NULL;
|
|
741
|
-
""",
|
|
742
|
-
),
|
|
743
|
-
(
|
|
744
|
-
35,
|
|
745
|
-
"persist finding dedupe groups",
|
|
746
|
-
"""
|
|
747
|
-
CREATE TABLE finding_dedupe_groups (
|
|
748
|
-
id TEXT PRIMARY KEY,
|
|
749
|
-
created_at TEXT NOT NULL
|
|
750
|
-
);
|
|
751
|
-
|
|
752
|
-
CREATE TABLE finding_dedupe_group_members (
|
|
753
|
-
group_id TEXT NOT NULL REFERENCES finding_dedupe_groups(id) ON DELETE CASCADE,
|
|
754
|
-
finding_id TEXT NOT NULL REFERENCES findings(id),
|
|
755
|
-
PRIMARY KEY (group_id, finding_id)
|
|
756
|
-
);
|
|
757
|
-
|
|
758
|
-
CREATE INDEX finding_dedupe_groups_by_finding
|
|
759
|
-
ON finding_dedupe_group_members(finding_id, group_id);
|
|
760
|
-
""",
|
|
761
|
-
),
|
|
762
|
-
(
|
|
763
|
-
36,
|
|
764
|
-
"persist local findings workflows",
|
|
765
|
-
"""
|
|
766
|
-
CREATE TABLE finding_workflows (
|
|
767
|
-
id TEXT PRIMARY KEY,
|
|
768
|
-
state_json TEXT NOT NULL,
|
|
769
|
-
created_at TEXT NOT NULL,
|
|
770
|
-
updated_at TEXT NOT NULL
|
|
771
|
-
);
|
|
772
|
-
""",
|
|
773
|
-
),
|
|
774
|
-
(
|
|
775
|
-
37,
|
|
776
|
-
"checkpoint validated dedupe reviews",
|
|
777
|
-
"""
|
|
778
|
-
CREATE TABLE finding_workflow_reviews (
|
|
779
|
-
workflow_id TEXT NOT NULL REFERENCES finding_workflows(id) ON DELETE CASCADE,
|
|
780
|
-
review_key TEXT NOT NULL,
|
|
781
|
-
binding_json TEXT NOT NULL,
|
|
782
|
-
result_json TEXT NOT NULL,
|
|
783
|
-
created_at TEXT NOT NULL,
|
|
784
|
-
PRIMARY KEY (workflow_id, review_key)
|
|
785
|
-
);
|
|
786
|
-
""",
|
|
787
|
-
),
|
|
788
|
-
(
|
|
789
|
-
38,
|
|
790
|
-
"store findings workflow metadata in columns",
|
|
791
|
-
"""
|
|
792
|
-
ALTER TABLE finding_workflows RENAME COLUMN state_json TO results_json;
|
|
793
|
-
ALTER TABLE finding_workflows ADD COLUMN repository_path TEXT;
|
|
794
|
-
ALTER TABLE finding_workflows ADD COLUMN scan_request_digest TEXT;
|
|
795
|
-
ALTER TABLE finding_workflows ADD COLUMN scan_id TEXT;
|
|
796
|
-
ALTER TABLE finding_workflows ADD COLUMN scan_dir TEXT;
|
|
797
|
-
ALTER TABLE finding_workflows ADD COLUMN artifact_digest TEXT;
|
|
798
|
-
ALTER TABLE finding_workflows ADD COLUMN destination TEXT;
|
|
799
|
-
ALTER TABLE finding_workflows ADD COLUMN scope_repository_id TEXT;
|
|
800
|
-
ALTER TABLE finding_workflows ADD COLUMN scope_all_repositories INTEGER;
|
|
801
|
-
ALTER TABLE finding_workflows ADD COLUMN scan_status TEXT NOT NULL DEFAULT 'pending';
|
|
802
|
-
ALTER TABLE finding_workflows ADD COLUMN scan_error TEXT;
|
|
803
|
-
ALTER TABLE finding_workflows ADD COLUMN publish_status TEXT NOT NULL DEFAULT 'pending';
|
|
804
|
-
ALTER TABLE finding_workflows ADD COLUMN publish_error TEXT;
|
|
805
|
-
ALTER TABLE finding_workflows ADD COLUMN dedupe_status TEXT NOT NULL DEFAULT 'pending';
|
|
806
|
-
ALTER TABLE finding_workflows ADD COLUMN dedupe_error TEXT;
|
|
807
|
-
""",
|
|
808
|
-
),
|
|
809
|
-
(
|
|
810
|
-
39,
|
|
811
|
-
"store dedupe checkpoint bindings in columns",
|
|
812
|
-
"""
|
|
813
|
-
ALTER TABLE finding_workflow_reviews RENAME COLUMN binding_json TO prompt_digest;
|
|
814
|
-
ALTER TABLE finding_workflow_reviews ADD COLUMN review_contract_version INTEGER;
|
|
815
|
-
ALTER TABLE finding_workflow_reviews ADD COLUMN codex_version TEXT;
|
|
816
|
-
ALTER TABLE finding_workflow_reviews ADD COLUMN source_repository_path TEXT;
|
|
817
|
-
ALTER TABLE finding_workflow_reviews ADD COLUMN source_revision TEXT;
|
|
818
|
-
ALTER TABLE finding_workflow_reviews ADD COLUMN source_refs_digest TEXT;
|
|
819
|
-
ALTER TABLE finding_workflow_reviews ADD COLUMN source_content_digest TEXT;
|
|
820
|
-
ALTER TABLE finding_workflow_reviews ADD COLUMN scope_repository_id TEXT;
|
|
821
|
-
ALTER TABLE finding_workflow_reviews ADD COLUMN scope_all_repositories INTEGER;
|
|
822
|
-
ALTER TABLE finding_workflow_reviews ADD COLUMN model TEXT;
|
|
823
|
-
ALTER TABLE finding_workflow_reviews ADD COLUMN effort TEXT;
|
|
824
|
-
ALTER TABLE finding_workflow_reviews ADD COLUMN settings_digest TEXT;
|
|
825
|
-
ALTER TABLE finding_workflow_reviews ADD COLUMN contract_digest TEXT;
|
|
826
|
-
""",
|
|
827
|
-
),
|
|
828
|
-
(
|
|
829
|
-
40,
|
|
830
|
-
"index finding identity and comparison history",
|
|
831
|
-
"""
|
|
832
|
-
CREATE INDEX finding_occurrences_by_finding
|
|
833
|
-
ON finding_occurrences(finding_id, id);
|
|
834
|
-
|
|
835
|
-
CREATE INDEX scan_comparisons_by_after_scan
|
|
836
|
-
ON scan_comparisons(after_scan_id, before_scan_id);
|
|
837
|
-
""",
|
|
838
|
-
),
|
|
839
|
-
(
|
|
840
|
-
41,
|
|
841
|
-
"checkpoint finding severity assessments",
|
|
842
|
-
"""
|
|
843
|
-
CREATE TABLE finding_severity_assessments (
|
|
844
|
-
finding_id TEXT PRIMARY KEY REFERENCES findings(id) ON DELETE CASCADE,
|
|
845
|
-
occurrence_id TEXT,
|
|
846
|
-
input_sha256 TEXT NOT NULL,
|
|
847
|
-
rubric_sha256 TEXT,
|
|
848
|
-
knowledge_base_sha256 TEXT,
|
|
849
|
-
assessed_at TEXT NOT NULL,
|
|
850
|
-
source TEXT NOT NULL CHECK (source IN ('existing-severity', 'rubric')),
|
|
851
|
-
decision TEXT NOT NULL CHECK (decision IN ('assessed', 'excluded')),
|
|
852
|
-
level TEXT CHECK (level IN ('critical', 'high', 'medium', 'low', 'informational')),
|
|
853
|
-
rubric_label TEXT,
|
|
854
|
-
rationale TEXT NOT NULL,
|
|
855
|
-
confidence TEXT CHECK (confidence IN ('high', 'medium', 'low')),
|
|
856
|
-
review_trigger TEXT,
|
|
857
|
-
CHECK ((decision = 'assessed' AND level IS NOT NULL)
|
|
858
|
-
OR (decision = 'excluded' AND level IS NULL AND rubric_label IS NULL))
|
|
859
|
-
);
|
|
860
|
-
|
|
861
|
-
CREATE TABLE scan_severity_classifications (
|
|
862
|
-
scan_id TEXT PRIMARY KEY,
|
|
863
|
-
finding_ids_json TEXT NOT NULL,
|
|
864
|
-
assessed_at TEXT NOT NULL,
|
|
865
|
-
rubric_sha256 TEXT,
|
|
866
|
-
knowledge_base_sha256 TEXT
|
|
867
|
-
);
|
|
868
|
-
""",
|
|
869
|
-
),
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
_SHARED = Path(__file__).resolve().parents[1] / "shared"
|
|
10
|
+
_HISTORY = json.loads((_SHARED / "workbench-migrations.json").read_text(encoding="utf-8"))
|
|
11
|
+
_REPAIR_HISTORY = json.dumps(_HISTORY)
|
|
12
|
+
_REPAIR_PLAN = json.loads((_SHARED / "workbench-history-repairs.json").read_text(encoding="utf-8"))
|
|
13
|
+
MIGRATIONS = tuple(
|
|
14
|
+
(migration["version"], migration["name"], "\n".join(migration["statements"]))
|
|
15
|
+
for migration in _HISTORY
|
|
870
16
|
)
|
|
871
17
|
|
|
872
18
|
|
|
873
|
-
def
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
scope = binding["scope"]
|
|
880
|
-
connection.execute(
|
|
881
|
-
"""UPDATE finding_workflow_reviews SET review_contract_version = ?, codex_version = ?,
|
|
882
|
-
source_repository_path = ?, source_revision = ?, source_refs_digest = ?,
|
|
883
|
-
source_content_digest = ?, scope_repository_id = ?, scope_all_repositories = ?,
|
|
884
|
-
model = ?, effort = ?, settings_digest = ?, prompt_digest = ?, contract_digest = ?
|
|
885
|
-
WHERE workflow_id = ? AND review_key = ?""",
|
|
886
|
-
(
|
|
887
|
-
binding["version"],
|
|
888
|
-
binding["codexVersion"],
|
|
889
|
-
source["repository"],
|
|
890
|
-
source["revision"],
|
|
891
|
-
source["refsDigest"],
|
|
892
|
-
source["content"],
|
|
893
|
-
scope.get("repositoryId"),
|
|
894
|
-
scope.get("allRepositories"),
|
|
895
|
-
binding["model"],
|
|
896
|
-
binding["effort"],
|
|
897
|
-
binding.get("settingsDigest"),
|
|
898
|
-
binding["promptDigest"],
|
|
899
|
-
binding["contractDigest"],
|
|
900
|
-
row["workflow_id"],
|
|
901
|
-
row["review_key"],
|
|
902
|
-
),
|
|
903
|
-
)
|
|
19
|
+
def migration_json_extract(document: str, path: str) -> str | int | float | None:
|
|
20
|
+
# The fixed scalar paths in migrations 38/39 must retain embedded NULs on older SQLite.
|
|
21
|
+
value = json.loads(document)
|
|
22
|
+
for key in path[2:].split("."):
|
|
23
|
+
value = value.get(key) if isinstance(value, dict) else None
|
|
24
|
+
return value
|
|
904
25
|
|
|
905
26
|
|
|
906
|
-
def
|
|
907
|
-
# Rename/backfill in place so existing checkpoint foreign keys and rows survive.
|
|
27
|
+
def migrate_finding_workflow_results(connection: sqlite3.Connection) -> None:
|
|
908
28
|
for row in connection.execute("SELECT id, results_json FROM finding_workflows").fetchall():
|
|
909
|
-
|
|
910
|
-
scope = state.get("scope", {})
|
|
911
|
-
stages = state["stages"]
|
|
29
|
+
stages = json.loads(row["results_json"])["stages"]
|
|
912
30
|
results = {stage: value["result"] for stage, value in stages.items() if "result" in value}
|
|
913
31
|
if "pendingWrite" in stages["dedupe"]:
|
|
914
32
|
results["dedupePendingWrite"] = stages["dedupe"]["pendingWrite"]
|
|
33
|
+
# SQLite JSON extraction on older runtimes truncates embedded NULs in diagnostics.
|
|
915
34
|
connection.execute(
|
|
916
|
-
"
|
|
917
|
-
|
|
918
|
-
artifact_digest = ?, destination = ?, scope_repository_id = ?, scope_all_repositories = ?,
|
|
919
|
-
scan_status = ?, scan_error = ?, publish_status = ?, publish_error = ?,
|
|
920
|
-
dedupe_status = ?, dedupe_error = ?, results_json = ? WHERE id = ?""",
|
|
35
|
+
"UPDATE finding_workflows SET scan_error = ?, publish_error = ?, dedupe_error = ?, "
|
|
36
|
+
"results_json = ? WHERE id = ?",
|
|
921
37
|
(
|
|
922
|
-
state.get("repositoryPath"),
|
|
923
|
-
state.get("scanRequestDigest"),
|
|
924
|
-
state.get("scanId"),
|
|
925
|
-
state.get("scanDir"),
|
|
926
|
-
state.get("artifactDigest"),
|
|
927
|
-
state.get("destination"),
|
|
928
|
-
scope.get("repositoryId"),
|
|
929
|
-
scope.get("allRepositories"),
|
|
930
|
-
stages["scan"]["status"],
|
|
931
38
|
stages["scan"].get("error"),
|
|
932
|
-
stages["publish"]["status"],
|
|
933
39
|
stages["publish"].get("error"),
|
|
934
|
-
stages["dedupe"]["status"],
|
|
935
40
|
stages["dedupe"].get("error"),
|
|
936
41
|
json.dumps(results, allow_nan=False),
|
|
937
42
|
row["id"],
|
|
@@ -970,17 +75,18 @@ def apply_migrations(
|
|
|
970
75
|
elif version == 16:
|
|
971
76
|
should_backfill_targets = repair_stable_targets_migration(connection)
|
|
972
77
|
elif version in applied:
|
|
973
|
-
if version in (2, 12, 13, 26, 28, 31, 32):
|
|
78
|
+
if version in (2, 12, 13, 26, 28, 31, 32, 47):
|
|
974
79
|
repair_additive_migration(connection, version)
|
|
975
80
|
elif version == 11:
|
|
976
81
|
repair_deep_scan_migration(connection)
|
|
977
82
|
else:
|
|
83
|
+
if version in (38, 39):
|
|
84
|
+
connection.create_function("migration_json_extract", 2, migration_json_extract)
|
|
85
|
+
sql = sql.replace("json_extract(", "migration_json_extract(")
|
|
978
86
|
for statement in sql_statements(sql):
|
|
979
87
|
connection.execute(statement)
|
|
980
88
|
if version == 38:
|
|
981
|
-
|
|
982
|
-
elif version == 39:
|
|
983
|
-
migrate_finding_workflow_review_columns(connection)
|
|
89
|
+
migrate_finding_workflow_results(connection)
|
|
984
90
|
if version not in applied:
|
|
985
91
|
connection.execute(
|
|
986
92
|
"INSERT INTO schema_migrations (version, name, applied_at) VALUES (?, ?, ?)",
|
|
@@ -992,239 +98,19 @@ def apply_migrations(
|
|
|
992
98
|
backfill_security_targets(connection)
|
|
993
99
|
|
|
994
100
|
|
|
995
|
-
def normalize_pre_release_execution_profile_migrations(
|
|
996
|
-
connection: sqlite3.Connection, timestamp: str
|
|
997
|
-
) -> None:
|
|
998
|
-
scan_columns = {row["name"] for row in connection.execute("PRAGMA table_info(scans)")}
|
|
999
|
-
workspace_columns = {row["name"] for row in connection.execute("PRAGMA table_info(workspaces)")}
|
|
1000
|
-
legacy_columns = {"execution_model", "reasoning_effort"}
|
|
1001
|
-
renamed_columns = {
|
|
1002
|
-
"legacy_execution_model",
|
|
1003
|
-
"legacy_reasoning_effort",
|
|
1004
|
-
}
|
|
1005
|
-
execution_migrations = {
|
|
1006
|
-
row["version"]: row["name"]
|
|
1007
|
-
for row in connection.execute(
|
|
1008
|
-
"SELECT version, name FROM schema_migrations WHERE version IN (11, 12, 25)"
|
|
1009
|
-
)
|
|
1010
|
-
}
|
|
1011
|
-
supported_execution_migrations = {
|
|
1012
|
-
11: {"deep scan orchestration state", "scan execution profiles"},
|
|
1013
|
-
12: {
|
|
1014
|
-
"scan continuation threads",
|
|
1015
|
-
"scan execution profiles",
|
|
1016
|
-
"dynamic scan execution profiles",
|
|
1017
|
-
},
|
|
1018
|
-
}
|
|
1019
|
-
model_migration_name = "persist scan model settings"
|
|
1020
|
-
if execution_migrations.get(25) == "dynamic scan execution profiles":
|
|
1021
|
-
connection.execute(
|
|
1022
|
-
"UPDATE schema_migrations SET name = ? WHERE version = 25 AND name = ?",
|
|
1023
|
-
(model_migration_name, "dynamic scan execution profiles"),
|
|
1024
|
-
)
|
|
1025
|
-
execution_migrations[25] = model_migration_name
|
|
1026
|
-
has_legacy_profile_history = any(
|
|
1027
|
-
execution_migrations.get(version) in legacy_names
|
|
1028
|
-
for version, legacy_names in (
|
|
1029
|
-
(11, {"scan execution profiles"}),
|
|
1030
|
-
(12, {"scan execution profiles", "dynamic scan execution profiles"}),
|
|
1031
|
-
)
|
|
1032
|
-
)
|
|
1033
|
-
has_legacy_profile_columns = any(
|
|
1034
|
-
column in columns
|
|
1035
|
-
for column, columns in (
|
|
1036
|
-
("execution_model", scan_columns),
|
|
1037
|
-
("execution_model", workspace_columns),
|
|
1038
|
-
("reasoning_effort", workspace_columns),
|
|
1039
|
-
)
|
|
1040
|
-
)
|
|
1041
|
-
if not (has_legacy_profile_history or has_legacy_profile_columns):
|
|
1042
|
-
return
|
|
1043
|
-
|
|
1044
|
-
if any(
|
|
1045
|
-
execution_migrations.get(version) not in ({None} | supported_names)
|
|
1046
|
-
for version, supported_names in supported_execution_migrations.items()
|
|
1047
|
-
):
|
|
1048
|
-
raise SystemExit(
|
|
1049
|
-
"The Codex Security database has an unsupported execution-profile migration history."
|
|
1050
|
-
)
|
|
1051
|
-
|
|
1052
|
-
if has_legacy_profile_columns and not (
|
|
1053
|
-
legacy_columns <= scan_columns
|
|
1054
|
-
and legacy_columns <= workspace_columns
|
|
1055
|
-
and not renamed_columns.intersection(scan_columns | workspace_columns)
|
|
1056
|
-
):
|
|
1057
|
-
raise SystemExit(
|
|
1058
|
-
"The Codex Security database has an unsupported execution-profile migration history."
|
|
1059
|
-
)
|
|
1060
|
-
if has_legacy_profile_history and not has_legacy_profile_columns:
|
|
1061
|
-
raise SystemExit(
|
|
1062
|
-
"The Codex Security database has an unsupported execution-profile migration history."
|
|
1063
|
-
)
|
|
1064
|
-
|
|
1065
|
-
if execution_migrations.get(25) not in (None, model_migration_name):
|
|
1066
|
-
raise SystemExit(
|
|
1067
|
-
"The Codex Security database has an unsupported execution-profile migration history."
|
|
1068
|
-
)
|
|
1069
|
-
|
|
1070
|
-
# Keep the historical values and constraints for recovery while moving
|
|
1071
|
-
# them out of the namespace used by the current independent scan settings.
|
|
1072
|
-
for table in ("workspaces", "scans"):
|
|
1073
|
-
connection.execute(
|
|
1074
|
-
f"ALTER TABLE {table} RENAME COLUMN execution_model TO legacy_execution_model"
|
|
1075
|
-
)
|
|
1076
|
-
connection.execute(
|
|
1077
|
-
f"ALTER TABLE {table} RENAME COLUMN reasoning_effort TO legacy_reasoning_effort"
|
|
1078
|
-
)
|
|
1079
|
-
repair_additive_migration(connection, 25)
|
|
1080
|
-
connection.execute(
|
|
1081
|
-
"""
|
|
1082
|
-
UPDATE scans
|
|
1083
|
-
SET model = COALESCE(model, legacy_execution_model),
|
|
1084
|
-
reasoning_effort = COALESCE(reasoning_effort, legacy_reasoning_effort)
|
|
1085
|
-
"""
|
|
1086
|
-
)
|
|
1087
|
-
for version, name in (
|
|
1088
|
-
(11, "scan execution profiles"),
|
|
1089
|
-
(12, "scan execution profiles"),
|
|
1090
|
-
(12, "dynamic scan execution profiles"),
|
|
1091
|
-
):
|
|
1092
|
-
connection.execute(
|
|
1093
|
-
"DELETE FROM schema_migrations WHERE version = ? AND name = ?",
|
|
1094
|
-
(version, name),
|
|
1095
|
-
)
|
|
1096
|
-
if execution_migrations.get(25) is None:
|
|
1097
|
-
connection.execute(
|
|
1098
|
-
"INSERT INTO schema_migrations (version, name, applied_at) VALUES (?, ?, ?)",
|
|
1099
|
-
(25, model_migration_name, timestamp),
|
|
1100
|
-
)
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
def move_pre_release_migration(
|
|
1104
|
-
connection: sqlite3.Connection, old_version: int, new_version: int, name: str
|
|
1105
|
-
) -> None:
|
|
1106
|
-
migration = connection.execute(
|
|
1107
|
-
"SELECT name FROM schema_migrations WHERE version = ?", (old_version,)
|
|
1108
|
-
).fetchone()
|
|
1109
|
-
if migration is None or migration["name"] != name:
|
|
1110
|
-
return
|
|
1111
|
-
if (
|
|
1112
|
-
connection.execute(
|
|
1113
|
-
"SELECT 1 FROM schema_migrations WHERE version = ?", (new_version,)
|
|
1114
|
-
).fetchone()
|
|
1115
|
-
is not None
|
|
1116
|
-
):
|
|
1117
|
-
raise SystemExit(
|
|
1118
|
-
"The Codex Security database has an unsupported pre-release migration history."
|
|
1119
|
-
)
|
|
1120
|
-
connection.execute(
|
|
1121
|
-
"UPDATE schema_migrations SET version = ? WHERE version = ? AND name = ?",
|
|
1122
|
-
(new_version, old_version, name),
|
|
1123
|
-
)
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
101
|
def normalize_pre_release_migrations(connection: sqlite3.Connection, timestamp: str) -> None:
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
(19, {"structured scan guidance context", "idempotent scan lifecycle requests"}),
|
|
1140
|
-
(20, {"retain superseded scan lifecycle requests", "threat model publication receipts"}),
|
|
1141
|
-
(21, {"scan progress projection and activity", "deep coordinator manifest receipts"}),
|
|
1142
|
-
(22, {"dynamic scan execution profiles"}),
|
|
1143
|
-
):
|
|
1144
|
-
migration = connection.execute(
|
|
1145
|
-
"SELECT name FROM schema_migrations WHERE version = ?", (version,)
|
|
1146
|
-
).fetchone()
|
|
1147
|
-
if migration is None or migration["name"] not in legacy_names:
|
|
1148
|
-
continue
|
|
1149
|
-
_, name, sql = next(migration for migration in MIGRATIONS if migration[0] == version)
|
|
1150
|
-
if version == 18:
|
|
1151
|
-
connection.execute(
|
|
1152
|
-
"UPDATE scans SET handoff_claimed_at = NULL, handoff_claim_token = NULL "
|
|
1153
|
-
"WHERE handoff_status = 'delivered'"
|
|
1154
|
-
)
|
|
1155
|
-
elif version == 19:
|
|
1156
|
-
for statement in sql_statements(sql):
|
|
1157
|
-
connection.execute(
|
|
1158
|
-
statement.replace("CREATE TABLE ", "CREATE TABLE IF NOT EXISTS ", 1)
|
|
1159
|
-
)
|
|
1160
|
-
else:
|
|
1161
|
-
repair_additive_migration(connection, version)
|
|
1162
|
-
connection.execute(
|
|
1163
|
-
"UPDATE schema_migrations SET name = ? WHERE version = ? AND name = ?",
|
|
1164
|
-
(name, version, migration["name"]),
|
|
1165
|
-
)
|
|
1166
|
-
|
|
1167
|
-
migration = connection.execute(
|
|
1168
|
-
"SELECT name FROM schema_migrations WHERE version = 2"
|
|
1169
|
-
).fetchone()
|
|
1170
|
-
if migration is None or migration["name"] != "finding management schema":
|
|
1171
|
-
return
|
|
1172
|
-
|
|
1173
|
-
legacy_versions = {
|
|
1174
|
-
row["version"]: row["name"]
|
|
1175
|
-
for row in connection.execute(
|
|
1176
|
-
"SELECT version, name FROM schema_migrations WHERE version BETWEEN 2 AND 5"
|
|
1177
|
-
)
|
|
1178
|
-
}
|
|
1179
|
-
expected = {
|
|
1180
|
-
2: "finding management schema",
|
|
1181
|
-
3: "scan handoff delivery claims",
|
|
1182
|
-
4: "finding remediation action claims",
|
|
1183
|
-
5: "scan target snapshot digests",
|
|
1184
|
-
}
|
|
1185
|
-
for version, name in legacy_versions.items():
|
|
1186
|
-
if expected.get(version) != name:
|
|
1187
|
-
raise SystemExit(
|
|
1188
|
-
"The Codex Security database has an unsupported pre-release migration history."
|
|
1189
|
-
)
|
|
1190
|
-
|
|
1191
|
-
connection.execute(
|
|
1192
|
-
"DELETE FROM schema_migrations WHERE version = 5 AND name = ?",
|
|
1193
|
-
(expected[5],),
|
|
1194
|
-
)
|
|
1195
|
-
for old_version, new_version in ((4, 5), (3, 4), (2, 3)):
|
|
1196
|
-
connection.execute(
|
|
1197
|
-
"UPDATE schema_migrations SET version = ? WHERE version = ? AND name = ?",
|
|
1198
|
-
(new_version, old_version, expected[old_version]),
|
|
1199
|
-
)
|
|
1200
|
-
repair_additive_migration(connection, 2)
|
|
1201
|
-
add_column_if_missing(connection, "scans", "target_snapshot_digest", "TEXT")
|
|
1202
|
-
connection.execute(
|
|
1203
|
-
"INSERT INTO schema_migrations (version, name, applied_at) VALUES (?, ?, ?)",
|
|
1204
|
-
(2, "persist capability preflight summaries", timestamp),
|
|
1205
|
-
)
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
def normalize_mirror_lineage_migrations(connection: sqlite3.Connection) -> None:
|
|
1209
|
-
mirror_names = {
|
|
1210
|
-
29: "freeze stopped scan source digests",
|
|
1211
|
-
30: "separate deep scan publication failures",
|
|
1212
|
-
}
|
|
1213
|
-
migrations = {
|
|
1214
|
-
row["version"]: row["name"]
|
|
1215
|
-
for row in connection.execute(
|
|
1216
|
-
"SELECT version, name FROM schema_migrations WHERE version BETWEEN 29 AND 32"
|
|
1217
|
-
)
|
|
1218
|
-
}
|
|
1219
|
-
if not any(migrations.get(version) == name for version, name in mirror_names.items()):
|
|
1220
|
-
return
|
|
1221
|
-
if migrations != mirror_names:
|
|
1222
|
-
raise SystemExit("The Codex Security database has an unsupported mirror migration history.")
|
|
1223
|
-
for old_version, new_version in ((30, 32), (29, 31)):
|
|
1224
|
-
connection.execute(
|
|
1225
|
-
"UPDATE schema_migrations SET version = ? WHERE version = ? AND name = ?",
|
|
1226
|
-
(new_version, old_version, mirror_names[old_version]),
|
|
1227
|
-
)
|
|
102
|
+
for query in _REPAIR_PLAN:
|
|
103
|
+
actions = connection.execute("\n".join(query), {"history": _REPAIR_HISTORY}).fetchall()
|
|
104
|
+
for action in actions:
|
|
105
|
+
operation, value = action["operation"], action["value"]
|
|
106
|
+
if operation == "error":
|
|
107
|
+
raise SystemExit(value)
|
|
108
|
+
if operation == "additive":
|
|
109
|
+
repair_additive_migration(connection, value)
|
|
110
|
+
elif operation == "column":
|
|
111
|
+
add_migration_column(connection, value)
|
|
112
|
+
else:
|
|
113
|
+
connection.execute(value, (timestamp,) if operation == "timestamp" else ())
|
|
1228
114
|
|
|
1229
115
|
|
|
1230
116
|
def repair_deep_scan_migration(connection: sqlite3.Connection) -> None:
|