Repository navigation
feat(convex): scheduled audit-log integrity check + append-only test - #1805
Conversation
The hash-chain + checkpoint verification (verifyIntegrity) only ran when an admin opened the audit-log page. Add continuous monitoring expected by SOC 2 / ISO 27001: a daily cron (02:00 UTC) re-verifies every org's chain server-side and raises an alert — a structured console.error plus a security-category audit row — on any chain break, truncation, checkpoint mismatch, or unsigned PII scrub. - Extract the core verification into a reusable verifyAuditChain(ctx,args) helper; the admin-gated verifyIntegrity query keeps its gate and delegates. - New audit_logs/integrity_check.ts: list audited orgs (genesis table), a no-auth internalQuery, and the orchestrating internalAction. - Append-only regression test: the chain detects an out-of-band field mutation and a mid-chain deletion (RLS allows the chain-link patch, so append-only is enforced by detection, not denial). - Document the scheduled check in the audit-logs admin page (en/de/fr). Refs #1505, #1803
|
Warning Review limit reached
More reviews will be available in 27 minutes and 20 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (7)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
Closes the open half of #1505: the audit-log hash-chain + checkpoint verification (
verifyIntegrity) previously ran only when an admin opened the audit-log page. SOC 2 / ISO 27001 (CC7.2 / A.8.15) expect continuous monitoring. This adds:02:00UTC — clear of the01:00legal-hold and04:00retention sweeps) that re-verifies every org's chain server-side and, on a genuine failure, raises an alert: a structuredconsole.errorand asecurity-category audit row.How
verifyIntegrityquery into a reusableverifyAuditChain(ctx, args). The public query keeps its admin gate and delegates; a new no-authinternalQuery(verifyAuditChainForOrg) reuses the same logic for the cron.audit_logs/integrity_check.ts: lists audited orgs from theauditLogChainGenesistable (one row per org that has written audit logs; capped + logged, never silent), verifies each, and writes the alert row on!valid.!result.valid(covers both a hash break and a checkpoint mismatch).truncatedis a coverage limit →console.warn, not a failure;unsignedScrubCountis only non-zero on deployments with no signing key (expected legacy state) → never alerted. Each org is verified in its own try/catch so one failure can't abort the sweep.createAuditLogperforms, so append-only is enforced by detection (the hash chain), not by an RLS denial. The test asserts detection: a clean chain verifies, an out-of-band field mutation is caught (firstBrokenAt), and a mid-chain deletion breaks the linkage.Verification
convex/audit_logs/append_only.test.ts(convex-test) — 3 cases, all green.convex devdeploys the new functions cleanly (validated against the local backend);convex/_generated/api.d.tsregenerated (2-line diff).bun run check✓ (incl. 71k+ platform tests, docs parity/loanword tests). CodeRabbit findings (per-org try/catch + truncated-not-a-failure) applied.Known follow-up
Very large chains (> the per-run window) are verified oldest-first and the overflow is logged, not failed. Full paging of such chains via
fromTimestampis a follow-up (the continuation semantics need their own verification).Pre-PR checklist
bun run check— green.messages/{en,de,fr}.json— N/A (no UI strings)./docs/{en,de,fr}/— audit-logs admin page notes the scheduled check.README.*— N/A.Part of #1803
Refs #1505