Skip to content

Arijit/log sanitation - #46

Open
arijitroy003 wants to merge 6 commits into
redhat-data-and-ai:mainfrom
arijitroy003:arijit/log-sanitation
Open

Arijit/log sanitation#46
arijitroy003 wants to merge 6 commits into
redhat-data-and-ai:mainfrom
arijitroy003:arijit/log-sanitation

Conversation

@arijitroy003

Copy link
Copy Markdown
Member

Addressing Issue

#31

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-commenter

codecov-commenter commented Mar 25, 2026

Copy link
Copy Markdown

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
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.

2 participants