Skip to content

fix(api): account-scope dashboard audit-log reads + memoize sidebar nav (audit 2026-06-10) - #160

Merged
agjs merged 2 commits into
mainfrom
chore/audit-fixes-20260610-2234
Jun 10, 2026
Merged

fix(api): account-scope dashboard audit-log reads + memoize sidebar nav (audit 2026-06-10)#160
agjs merged 2 commits into
mainfrom
chore/audit-fixes-20260610-2234

Conversation

@agjs

@agjs agjs commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • F001 (high, security): Dashboard summary/activity queries filtered auditLog by userId only, so a user belonging to multiple accounts saw their audit events from every account in any one account's dashboard. Queries now also require targetAccountId = current account (or NULL for user-level events like logins), with accountId threaded from the auth context. Guardrail-first: new lint-meta source-text rule audit-log-read-account-scoped flagged the exact 4 defect lines before the fix and now blocks the whole class (userId-filtered auditLog reads without account scoping); rule test added, RULES.md + docs catalog regenerated.
  • F002 (low, perf): useAppSidebar rebuilt the icon record and items array on every render, giving the items prop a new identity each time. The computation now lives in a single useMemo keyed on [showBilling, t].
  • Produced and executed via the audit-monorepoexecute-audit skill pair (report 20260610-2252); 3 blocked_or_uncertain items skipped by design (osv allowlist expiry automation, Starlight markdown-remark override removal, trivy-vs-osv divergence in infra-bootstrap).

Test plan

  • cd apps/api && bun run check — green (typecheck, eslint, lint:meta incl. new rule, knip)
  • cd apps/ui && bun run check — green
  • apps/api lint-meta + dashboard suites: 121 pass / 0 fail; new multi-account isolation tests included (DB-backed assertions execute in CI's postgres service)
  • apps/ui AppSidebar unit tests: 6/6
  • cd apps/docs && bun run check:docs-data — catalog fresh
  • Full pre-push gate (incl. smoke stack) passed on push

App merge bars

Area Command
API cd apps/api && bun run validate
UI cd apps/ui && bun run validate
Docs cd apps/docs && bun run build:ci
Repo drift bun run check (from repo root)

Conventions

  • No any, no blind as, no !
  • New env vars in schema + .env.example (+ SECURITY.md when relevant) — n/a, none added
  • Tests updated for changed behavior

Screenshots

n/a — UI change is render-identity only (no visual difference).

agjs added 2 commits June 10, 2026 22:58
Dashboard summary and activity queries filtered auditLog by userId
only, so a multi-account user saw events from every account they
belong to. Queries now also require targetAccountId = current account
(or null for user-level events), threaded from the auth context.

Guardrail: new lint-meta source-text rule
audit-log-read-account-scoped flags any src/ auditLog read filtered by
userId without targetAccountId scoping; covered in tests/lint-meta and
the rule docs/catalog are regenerated.

Audit: F001
useAppSidebar rebuilt the icon record and items array on every render,
giving the items prop a new identity each time and defeating
memoization in the sidebar subtree. The computation is now inside
useMemo keyed on [showBilling, t].

Audit: F002
@agjs
agjs merged commit 42c8f88 into main Jun 10, 2026
28 checks passed
@agjs
agjs deleted the chore/audit-fixes-20260610-2234 branch June 10, 2026 21:38
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