Skip to content

feat(security): audit account routes + allowlist cleanup - #887

Merged
2witstudios merged 2 commits into
masterfrom
pu/audit-account-cleanup
Apr 11, 2026
Merged

2witstudios merged 2 commits into
masterfrom
pu/audit-account-cleanup

Conversation

@2witstudios

@2witstudios 2witstudios commented Apr 11, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Add SecurityAuditService coverage to 2 account sub-routes (drives-status, verification-status)
  • Remove 34 TODO/follow-up entries from AUDIT_EXEMPT_ROUTES allowlist
  • Remove monitoring/[metric] entry (already covered by withAdminAuth wrapper)
  • Allowlist shrinks from ~48 to ~14 genuinely exempt entries

Test plan

  • pnpm --filter web vitest run src/app/api/__tests__/security-audit-coverage.test.ts passes (after sibling PRs merge)
  • Verify no PII in any logAuditEvent details objects
  • Verify allowlist only contains genuinely exempt routes

Note: This PR must merge after the 3 sibling audit PRs.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Implemented comprehensive audit logging for account endpoints to enhance security monitoring and compliance tracking.

@vercel

vercel Bot commented Apr 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pagespace-master-plan Ready Ready Preview, Comment Apr 11, 2026 0:12am

@coderabbitai

coderabbitai Bot commented Apr 11, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e7de6058-fa05-4bba-baae-b394e5680ff6

📥 Commits

Reviewing files that changed from the base of the PR and between 7de1b55 and 0bfeece.

📒 Files selected for processing (3)
  • apps/web/src/app/api/__tests__/security-audit-coverage.test.ts
  • apps/web/src/app/api/account/drives-status/route.ts
  • apps/web/src/app/api/account/verification-status/route.ts
💤 Files with no reviewable changes (1)
  • apps/web/src/app/api/tests/security-audit-coverage.test.ts

📝 Walkthrough

Walkthrough

These changes add audit logging to account-related API endpoints (drives status and verification checks) and remove audit exemptions for previously exempt routes, requiring them to implement audit instrumentation.

Changes

Cohort / File(s) Summary
Audit Coverage Test
apps/web/src/app/api/__tests__/security-audit-coverage.test.ts
Removed 38 lines of AUDIT_EXEMPT_ROUTES entries for drive-related (drives/[driveId]/*), page-related (pages/[pageId]/*), account-related (account/*), and monitoring routes, requiring these routes to now include audit logging instrumentation.
Account API Endpoints
apps/web/src/app/api/account/drives-status/route.ts, apps/web/src/app/api/account/verification-status/route.ts
Added audit logging via logAuditEvent to capture 'read' events with relevant metadata: drives-status logs view actions with solo/multi-member drive counts; verification-status logs check verification status actions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 Audit trails now sing their song,
Where drives and verifications belong,
No more exempt from watchful eyes,
Logging truths in plain disguise! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding audit logging to account routes and removing exempt entries from the allowlist.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pu/audit-account-cleanup

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0bfeece2d5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 76 to 79
['ai/ollama/models', 'Local Ollama model discovery, no user data'],
['ai/lmstudio/models', 'Local LMStudio model discovery, no user data'],

// --- Drive sub-routes (read-only data fetches, covered by parent drive audit) ---
// TODO: Add audit coverage in follow-up PR
['drives/[driveId]/access', 'Read-only access check — follow-up'],
['drives/[driveId]/agents', 'Agent list for drive — follow-up'],
['drives/[driveId]/assignees', 'Assignee list for drive — follow-up'],
['drives/[driveId]/history', 'Drive history view — follow-up'],
['drives/[driveId]/integrations', 'Integration list for drive — follow-up'],
['drives/[driveId]/integrations/audit', 'Integration audit log — follow-up'],
['drives/[driveId]/pages', 'Page list for drive — follow-up'],
['drives/[driveId]/permissions-tree', 'Permissions tree view — follow-up'],
['drives/[driveId]/search/glob', 'Glob search within drive — follow-up'],
['drives/[driveId]/search/regex', 'Regex search within drive — follow-up'],
['drives/[driveId]/trash', 'Trash list for drive — follow-up'],

// --- Page sub-routes (read-only data fetches, covered by parent page audit) ---
// TODO: Add audit coverage in follow-up PR
['pages/[pageId]/agent-config', 'Page agent config — follow-up'],
['pages/[pageId]/ai-usage', 'AI usage stats — follow-up'],
['pages/[pageId]/breadcrumbs', 'Breadcrumb navigation — follow-up'],
['pages/[pageId]/children', 'Child page list — follow-up'],
['pages/[pageId]/history', 'Page history view — follow-up'],
['pages/[pageId]/permissions/check', 'Permission check — follow-up'],
['pages/[pageId]/processing-status', 'Processing status poll — follow-up'],
['pages/[pageId]/reprocess', 'Reprocess trigger — follow-up'],
['pages/[pageId]/tasks/[taskId]', 'Individual task CRUD — follow-up'],
['pages/[pageId]/tasks/reorder', 'Task reorder — follow-up'],
['pages/[pageId]/tasks/statuses', 'Task status list — follow-up'],
['pages/[pageId]/versions/compare', 'Version comparison — follow-up'],
['pages/[pageId]/view', 'Page view endpoint — follow-up'],
['pages/tree', 'Page tree navigation — follow-up'],

// --- Account sub-routes (status checks) ---
// TODO: Add audit coverage in follow-up PR
['account/drives-status', 'Drive status check — follow-up'],
['account/verification-status', 'Email verification status — follow-up'],

// --- Monitoring with admin auth (already audited via withAdminAuth wrapper) ---
['monitoring/[metric]', 'Uses withAdminAuth which includes audit — verify after merge'],
]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore exemptions until remaining routes are audited

This change removes the drive/page follow-up entries from AUDIT_EXEMPT_ROUTES, but this commit only adds logAuditEvent to two account routes; at this snapshot, the coverage gate still finds 25 unaudited non-exempt routes (for example drives/[driveId]/access, pages/[pageId]/view, and pages/tree). Running security-audit-coverage.test.ts on commit 63f88df therefore fails immediately, so the branch is not green unless those other route handlers are updated in the same change.

Useful? React with 👍 / 👎.

2witstudios and others added 2 commits April 11, 2026 07:11
Add SecurityAuditService coverage to account/drives-status and
account/verification-status routes. Remove all 34 TODO/follow-up
entries from AUDIT_EXEMPT_ROUTES allowlist (drives, pages, account,
monitoring sections) now that sibling PRs provide actual coverage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

This branch was previously deployed

1 inactive deployment
Preview — a92c281e Deployed Apr 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant