feat: add security agent audit log backend for SOC2 compliance#449
Merged
jeanduplessis merged 2 commits intomainfrom Feb 24, 2026
Merged
feat: add security agent audit log backend for SOC2 compliance#449jeanduplessis merged 2 commits intomainfrom
jeanduplessis merged 2 commits intomainfrom
Conversation
Contributor
Code Review SummaryStatus: No New Issues Found | Recommendation: Address existing comments before merge All significant issues have already been identified by prior reviewers. The existing inline comments cover:
Existing Issues (already commented)WARNING
SUGGESTION
Review NotesWhat looks good
Minor observations (not blocking)
Files Reviewed (10 files)
|
2e6bc85 to
1ee0a7e
Compare
081c94e to
c02f609
Compare
5b08274 to
8daba2f
Compare
d1fee64 to
25e9f63
Compare
eshurakov
reviewed
Feb 24, 2026
eshurakov
approved these changes
Feb 24, 2026
Add an append-only security_audit_log table with XOR ownership, a SecurityAuditLogAction enum enforced at the DB level via enumCheck, and a fire-and-forget logging service. Integrate audit log calls into all security agent mutations (both personal and org routers) and backend services (auto-dismiss, sync, analysis callback). Add tRPC query routers (list, getSummary, getActionTypes, export) for both personal and org contexts with cursor-based pagination, filtering, and CSV/JSON export capped at 10k rows. Update softDeleteUser to anonymize actor PII on org-owned audit rows (user-owned rows cascade-delete via FK), with corresponding test.
25e9f63 to
5ae0484
Compare
src/routers/organizations/organization-security-audit-log-router.ts
Outdated
Show resolved
Hide resolved
Fix cursor-based pagination dropping valid items instead of the overflow sentinel when using the 'after' cursor, by slicing before reversing. Use explicit column selection in export endpoints to exclude internal ownership columns (owned_by_organization_id/owned_by_user_id) from exported CSV/JSON data.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
security_audit_logtable with XOR ownership (org or user),SecurityAuditLogActionenum enforced at the DB level viaenumCheck, and a fire-and-forgetlogSecurityAuditservicelist(cursor-based pagination, filtering by action/actor/resource/date range/fuzzy search on metadata),getSummary,getActionTypes, andexport(CSV/JSON, capped at 10k rows)softDeleteUserto anonymize actor PII on org-owned audit rows (user-owned rows cascade-delete via FK), with corresponding testActions Logged
security.finding.dismissedsecurity.finding.auto_dismissedsecurity.finding.analysis_startedsecurity.finding.analysis_completedsecurity.finding.deletedsecurity.config.enabledsecurity.config.disabledsecurity.config.updatedsecurity.sync.triggeredsecurity.sync.completedsecurity.audit_log.exportedTest Plan
SecurityAuditLogActionsoftDeleteUseranonymizesactor_email/actor_nameon org-owned security audit log rows while preservingactor_idand actionpnpm typecheckpasses clean