mirror of
https://github.com/aclist/dztui.git
synced 2026-10-29 22:22:52 +01:00
Merge pull request #24 from aclist/feat/redact-api-key
feat: redact API key in log table
This commit is contained in:
5 files changed
+24
-2
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user