Merge pull request #24 from aclist/feat/redact-api-key

feat: redact API key in log table
This commit is contained in:
aclist authored and GitHub committed 2025-12-17 15:02:19 +09:00
commit 88b85eb502
5 files changed
+24 -2

No files matched your search

+14
View File
@@ -4,3 +4,17 @@ def redact(text: str) -> str:
r = r"(/home/)([^/])*"
cleaned = re.sub(r, r"/home/REDACTED", text)
return cleaned
def redact_log(record: list) -> list[str]:
"""
requests library includes Steam API key in URL params
"""
clean = []
for item in record:
if "&key=" in item:
pat = r"(.*&key=)(\S+)(.*)"
scrubbed = re.sub(pat, r"\1REDACTED\3", item)
clean.append(scrubbed)
else:
clean.append(item)
return clean