feat: redact user id in logs
Some checks failed
Mirror to Codeberg / mirror-to-codeberg (push) Has been cancelled

This commit is contained in:
aclist 2026-07-24 01:13:00 +09:00
parent 7edb66c311
commit 525de56036
2 changed files with 10 additions and 1 deletions

View File

@ -4,8 +4,9 @@ from typing import Literal
api_filter = r"(.*&key=)([^&]*)(.*)"
home_filter = r"(/home/)([^\s'\/]*)(.*)"
user_filter = r"(.*Steam/userdata/)([^/]*)(.*)"
REDACTED = r"\1REDACTED\3"
REDACTION_PATTERNS = [api_filter, home_filter]
REDACTION_PATTERNS = [api_filter, home_filter, user_filter]
def redact_home(text: str) -> str:

View File

@ -37,6 +37,14 @@ class RecordsListHandler(logging.Handler):
"Error in directory: '/home/SENSITIVE_USERNAME'",
"Error in directory: '/home/REDACTED'",
),
(
"User directory: /home/user/.local/share/Steam/userdata/999999/grid",
"User directory: /home/REDACTED/.local/share/Steam/userdata/REDACTED/grid",
),
(
"User directory: /drive/.local/share/Steam/userdata/999999",
"User directory: /drive/.local/share/Steam/userdata/REDACTED",
),
],
)
def test_log_redaction(log_error: str, expect: str) -> None: