feat: governed analyst investigation console (#62) - #97
Conversation
|
Warning Review limit reached
Next review available in: 8 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (26)
📝 WalkthroughWalkthroughAdds a governed investigation console with typed trusted handlers, scoped execution, approval and cancellation lifecycle controls, bounded result storage, evidence linking, REST endpoints, database persistence, and integration tests. ChangesInvestigation console
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant InvestigationAPI
participant ExecutionCore
participant Database
participant Handler
Client->>InvestigationAPI: Submit authenticated command
InvestigationAPI->>ExecutionCore: Execute command with scopes and context
ExecutionCore->>Database: Create or reuse execution
ExecutionCore->>Handler: Run validated trusted handler
Handler-->>ExecutionCore: Return structured result
ExecutionCore->>Database: Persist status and result metadata
ExecutionCore-->>InvestigationAPI: Return public execution
InvestigationAPI-->>Client: Return execution response
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Close security findings on #62 / PR #97: - previous_cases filters results with filterCasesForActor (no restricted leak) - list executions without caseId omits rows the actor cannot know_exists - save-evidence authorizes source case and forbids body.caseId mismatch - approve/reject/cancel/links require authorizeCase when execution is case-bound - write dual-control stores paramsSealed (never public); refuse approve from redacted placeholders - idempotency unique on (organisation_id, idempotency_key)
Register investigation commands with typed params, scopes, read/write class, timeouts, rate/size limits, redaction, and dual-control approval for writes. Persist executions and result storage refs (0036). Expose list/execute/history/cancel/approve/reject/save-evidence/link APIs. Prohibits shell, scripts, and arbitrary destination URLs. Closes #62
Close security findings on #62 / PR #97: - previous_cases filters results with filterCasesForActor (no restricted leak) - list executions without caseId omits rows the actor cannot know_exists - save-evidence authorizes source case and forbids body.caseId mismatch - approve/reject/cancel/links require authorizeCase when execution is case-bound - write dual-control stores paramsSealed (never public); refuse approve from redacted placeholders - idempotency unique on (organisation_id, idempotency_key)
Main already has 0036 post-incident review and 0037 investigation graph. Fold console base schema and ACL follow-up into a single 0038 migration.
Main took 0036 for post-incident review and 0037 for investigation graph. Emit investigation console schema (base tables, params_sealed, org-scoped idempotency unique) as a single 0038 migration with a correct snapshot prevId chain after rebase.
Summary
Adds a governed investigation console so analysts can run approved, trusted query/connector commands from case/entity/evidence context without arbitrary shell, scripts, or free-form outbound URLs.
Closes #62
Schema (migration
0036_parallel_bloodaxe)investigation_executions— durable run history with redacted params, approval fields, cancel markers, result summary/storage/hash, evidence save link, entity/alert linksinvestigation_result_refs— storage key + sha256 + size for large resultsinvestigation_command_favourites— per-user favourites/templatesTrusted handler registry
kelpie.previous_casesvirustotal.reportsafeFetch; mock when unconfiguredkelpie.flag_entity_reviewedEach handler declares name/version, typed Zod params, required scopes, read/write class, timeout, size/rate limits, approval policy, redaction keys, and result renderers (
table|json|markdown).Hard prohibitions
API (
/api/v1/investigation/...)GET commands·GET/POST executions·GET executions/:idPOST .../cancel·.../approve·.../rejectPOST .../save-evidence(preserves command version, redacted params, provider request id, timestamps, hash)POST .../links(entities/alerts)Scopes:
investigation:read,investigation:execute. Case context usesauthorizeCase. Token scopes fail closed. Save-evidence also requiresevidence:write.Tests
npm run test:investigation-consolecovers schema rejection, injection/SSRF, scopes, approval, timeout/cancel, redaction, tenant isolation, and evidence save.Test plan
npm run test:investigation-console(Postgres; all assertions pass)npx tsc --noEmit0036on a staging DB and exercise list → execute previous_cases → save evidenceSummary by CodeRabbit
New Features
Documentation
Tests