Arijit/log sanitation - #46
Open
arijitroy003 wants to merge 6 commits into
Open
Conversation
Introduce LogSanitizer class with regex-based detection and redaction of PII (emails, SSNs, phone numbers, credit cards) and credentials (Bearer/Basic tokens, JWTs, API keys, passwords, AWS keys, GitHub tokens). Provides a structlog processor factory and header sanitization helper for defence-in-depth integration. Made-with: Cursor
Add LOG_SANITIZATION_ENABLED and LOG_SANITIZATION_CUSTOM_PATTERNS configuration fields to Settings, allowing sanitization to be toggled and extended with custom regex patterns via environment variables. Made-with: Cursor
Insert the sanitize processor into the structlog processor chain and Uvicorn foreign_pre_chain so all log output is automatically redacted. Apply header-level sanitization in RequestLoggingMiddleware for defence-in-depth on Authorization, X-Token, and Cookie headers. Made-with: Cursor
39 tests covering PII pattern detection, credential redaction, header sanitization, recursive dict/list handling, disabled mode, custom patterns, structlog processor integration, and non-sensitive data passthrough. Made-with: Cursor
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Add missing __init__ docstring (pydocstyle D107) and apply ruff formatting to log_sanitizer.py and test_log_sanitizer.py. Made-with: Cursor
Add tests for empty string sanitization, disabled processor path, settings import fallback, and middleware header sanitization via TestClient. Middleware tests skip gracefully when heavy deps are unavailable locally but run in CI. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addressing Issue
#31