feat: add log scrubbing utility and expand logger redaction paths#1108
feat: add log scrubbing utility and expand logger redaction paths#1108zeroknowledge0x wants to merge 1 commit into
Conversation
Closes sublime247#1014 Changes: - Expand pino redaction paths in logger.ts to cover API keys, private keys, master keys, service keys, connection strings, webhook secrets, and more - Add src/utils/scrub.ts utility for scrubbing secrets from console output (env-based + pattern-based scrubbing for Bearer tokens, connection strings, query-string credentials, key=value pairs) - Apply scrub() to database.ts error logging to prevent connection string leaks - Add comprehensive test suite for scrub utility
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| - | - | JSON Web Token | 45e3b17 | src/utils/tests/scrub.test.ts | View secret |
| - | - | Bearer Token | 45e3b17 | src/utils/tests/scrub.test.ts | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
|
@unsiqasik you are definitely not okay with what you are doing, linking somebody else issues🤦🏽 |
Closes #1014
Summary
Adds a centralized log scrubbing utility and expands pino redaction paths to prevent PII master keys and other secrets from leaking into console outputs.
Changes
1. Expanded Logger Redaction (src/utils/logger.ts)
Added redaction paths for:
2. Scrub Utility (src/utils/scrub.ts)
New utility for scrubbing secrets from console output:
3. Applied to Critical Paths (src/config/database.ts)
Applied scrub() to error logging in:
4. Test Suite (src/utils/tests/scrub.test.ts)
Comprehensive tests covering:
Testing
Run:
npx jest src/utils/__tests__/scrub.test.ts