fix(logger): redact sensitive fields in structured logging#6223
Conversation
|
@tamilr0727-ux is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
📦 Next.js Bundle Size Report (Gzipped Sizes)
📊 Summary of Totals
|
Aamod-Dev
left a comment
There was a problem hiding this comment.
Thank you for adding this crucial layer of defense to our logging system. Recursively sanitizing sensitive fields like tokens and passwords before JSON.stringify serialization in lib/logger.ts prevents accidental credentials exposure in log aggregation systems. The test cases covering nested structures and multiple fields ensure this works exactly as intended. Approved!
|
🎉 Congratulations @tamilr0727-ux! Your PR has been successfully merged. 🚀 Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.
Keep building! 💻✨ |
Description
Adds sensitive-data redaction to
lib/logger.tsto prevent accidental exposure of credentials, PII, and security-sensitive metadata in structured logs.Problem
The existing logger serialized context objects directly using
JSON.stringify(ctx)without filtering sensitive fields.As a result, log entries could contain:
When logs are forwarded to centralized logging systems, this information becomes accessible to anyone with log access and may create compliance and security risks.
Changes
Added Redaction Layer
Implemented recursive sanitization of structured logging metadata before serialization.
Protected sensitive fields including:
tokenkeysecretpasswordauthorizationcookieemailSensitive values are replaced with:
Recursive Object Protection
Logger Hardening
Security Impact
Before
Potential exposure of:
After
Test Coverage
Added tests validating:
Validation
✅ All tests pass successfully.
✅ Existing logger functionality remains intact.
✅ Sensitive values are consistently replaced with
[REDACTED].Impact
Fixes #6183
Pillar
Visual Preview
Can Check in the files Changed Section
Checklist before requesting a review:
CONTRIBUTING.mdfile.localhost:3000/api/streak?user=YOUR_USERNAME).npm run formatandnpm run lintlocally and resolved all errors (CI will fail otherwise).feat(themes): ...,fix(calculate): ...).README.mdif I added a new theme or URL parameter.