Skip to content

Add security header sweep for /api/audit - #974

Open
DANTE-1903 wants to merge 1 commit into
CalloraOrg:mainfrom
DANTE-1903:feature/security-headers-audit
Open

Add security header sweep for /api/audit#974
DANTE-1903 wants to merge 1 commit into
CalloraOrg:mainfrom
DANTE-1903:feature/security-headers-audit

Conversation

@DANTE-1903

Copy link
Copy Markdown

Summary

Set/verify CSP, X-Content-Type-Options, Referrer-Policy on /api/audit responses with a dedicated route-level middleware for defense-in-depth.

Changes

  • src/middleware/securityHeaders.ts (new): Middleware that sets Content-Security-Policy, X-Content-Type-Options: nosniff, and Referrer-Policy: strict-origin-when-cross-origin on every response from the audit route
  • src/routes/admin/audit.ts: Wired securityHeaders via router.use so all sub-routes (including /replay) inherit the headers
  • src/middleware/securityHeaders.test.ts (new): 5 unit tests covering each header individually, all three together, and next() delegation
  • src/routes/admin/audit.test.ts: 5 integration tests verifying headers on success responses, error responses, and the replay sub-route

Testing

PASS src/middleware/securityHeaders.test.ts (5/5)
PASS src/routes/admin/audit.test.ts (20/20, 5 new + 15 existing)

Closes #905

- Create src/middleware/securityHeaders.ts with CSP, X-Content-Type-Options,
  Referrer-Policy headers for audit endpoint
- Wire securityHeaders middleware into createAdminAuditRouter via router.use
- Add 5 unit tests for the middleware itself
- Add 5 integration tests verifying headers on /api/admin/audit responses

Closes CalloraOrg#905
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@DANTE-1903 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Add security header sweep for /api/audit [b#040]

1 participant