fix(logging): redact telegram bot urls
All checks were successful
Code Review / ai-code-review (push) Successful in 17s
CD Pipeline / tests (push) Successful in 1m14s
CD Pipeline / build-and-deploy (push) Successful in 3m19s
CD Pipeline / post-deploy-checks (push) Successful in 1m15s

This commit is contained in:
Your Name
2026-05-06 16:54:00 +08:00
parent 38a4748e17
commit 33f85ec8ca
3 changed files with 60 additions and 4 deletions

View 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