Skip to content

Implement structured audit logging interceptor for sensitive administrative and financial endpoints #108

Description

@Cjay-Cyber-2

Description — what to implement and the why/impact.

Regulatory compliance and security governance for AI agent financial operations require an immutable, structured audit trail of every state-mutating request made to sensitive endpoints. This issue implements a NestJS interceptor that automatically records detailed audit metadata (actor, IP address, user agent, route, request body summary, and timestamp) for all financial and administrative controllers.

Context & Requirements — background, constraints, design references, edge cases;

  • Located in src/common/interceptors or src/modules/audit.
  • Filter out sensitive fields (such as passwords, private keys, secrets) from recorded request bodies.
  • Save audit records asynchronously to the database via Prisma.

Acceptance Criteria — a checklist ("- [ ] ...") of specific, testable conditions that define "done".

  • Create AuditLogInterceptor capturing request context, actor identity, and payload.
  • Implement data sanitization helper to strip sensitive keys from audit payloads.
  • Apply interceptor globally or via controller decorators on sensitive modules.
  • Add unit tests verifying correct audit record creation and payload sanitization.

Implementation Guidance — likely files/modules to touch and a suggested approach

  • Touch files under src/common/interceptors/ and src/modules/audit/.
  • Follow existing repository patterns for interceptor implementation and dependency injection.

Testing & Validation — how the contributor should prove it works

  • Run npm test and npm run typecheck.
  • Add unit tests verifying sensitive secrets are omitted in saved audit entries.

Submission Guidelines — must open a PR that includes "Closes #"; assignment is required before starting; follow the repo's existing style and conventions.


Wave complexity: Medium

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions