Description
apps/backend/tests/compliance/verification.test.ts validates audit trail requirements but the actual routes do not emit audit log entries when PII fields (email, environment_variables) are read or written. This is a compliance gap.
Requirements and context
- Must be secure, tested, and documented where applicable
- Should stay reviewable and fit the current monorepo structure
- Relevant files:
apps/backend/tests/compliance/verification.test.ts, apps/backend/src/app/api/auth/profile/route.ts, apps/backend/src/app/api/deployments/[id]/route.ts, apps/backend/src/lib/api/logger.ts
Suggested execution
- Create branch:
issue-020-audit-trail-pii-field-access
- Keep changes scoped to the issue and reference the task IDs in the PR
Implement changes
- Extend
createLogger to support an audit log level that writes to a separate sink
- Emit audit entries on: profile read/write, environment_variables read, deployment delete
- Include
userId, action, resourceId, and timestamp in each entry
Test and commit
- Add tests verifying audit entries are emitted for each PII-touching operation
- Verify audit entries are not emitted for non-PII reads (e.g., template list)
- Security note: audit log entries must never contain the PII values themselves
Example commit message
feat(audit): emit audit log entries for PII field access
Guidelines
- Prefer small, reviewable PRs
- Keep naming and data contracts consistent with the spec docs
Description
apps/backend/tests/compliance/verification.test.tsvalidates audit trail requirements but the actual routes do not emit audit log entries when PII fields (email,environment_variables) are read or written. This is a compliance gap.Requirements and context
apps/backend/tests/compliance/verification.test.ts,apps/backend/src/app/api/auth/profile/route.ts,apps/backend/src/app/api/deployments/[id]/route.ts,apps/backend/src/lib/api/logger.tsSuggested execution
issue-020-audit-trail-pii-field-accessImplement changes
createLoggerto support anauditlog level that writes to a separate sinkuserId,action,resourceId, andtimestampin each entryTest and commit
Example commit message
Guidelines