fix(logging): redact telegram bot urls
This commit is contained in:
23
apps/api/tests/test_logging_redaction.py
Normal file
23
apps/api/tests/test_logging_redaction.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from src.core.logging import SensitiveURLRedactionFilter
|
||||
|
||||
|
||||
def test_sensitive_url_redaction_filter_redacts_log_record_args() -> None:
|
||||
record = logging.LogRecord(
|
||||
name="httpx",
|
||||
level=logging.INFO,
|
||||
pathname=__file__,
|
||||
lineno=1,
|
||||
msg="HTTP Request: %s",
|
||||
args=("https://api.telegram.org/bot123456:SECRET/getWebhookInfo",),
|
||||
exc_info=None,
|
||||
)
|
||||
|
||||
assert SensitiveURLRedactionFilter().filter(record) is True
|
||||
|
||||
rendered = record.getMessage()
|
||||
assert "SECRET" not in rendered
|
||||
assert "bot<redacted>" in rendered
|
||||
Reference in New Issue
Block a user