feat: redact API key in log table

This commit is contained in:
aclist 2025-12-13 23:00:41 +09:00
parent 190face11d
commit 5483717e0c
4 changed files with 24 additions and 2 deletions

View File

@ -13,6 +13,7 @@
- Documentation ships with source
- Open filepicker when generating system log
- Developers page (and -d flag)
- Redact API key in log table
## Changed
- Reduce padding on keys button

View File

@ -1,6 +1,7 @@
import logging
import os
import locale
import os
import re
import shutil
import threading
import textwrap
@ -437,9 +438,25 @@ class Controller:
with open(log, "r") as f:
lines = [line.split(strings.delimiter) for line in f.read().splitlines()]
for record in lines:
store.append(record)
clean = self.redact_log(record)
store.append(clean)
self.open_page(NotebookPage.LOG)
def redact_log(self, 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
def select_colorized(self) -> None:
model = self.model_manager.get_mod_store()
sel = self.mediator.modtreeview.get_selection()

View File

@ -13,6 +13,7 @@
- Documentation ships with source
- Open filepicker when generating system log
- Developers page (and -d flag)
- Redact API key in log table
## Changed
- Reduce padding on keys button

View File

@ -487,8 +487,11 @@ class Options(Gtk.Box):
active_combo = 1 if config["branch"] == BETA_REPO else 0
self.controller.suppress_signal(self, self.branch_combo, "_on_branch_changed", True)
self.branch_combo.set_active(active_combo)
self.branch_combo.set_sensitive(prefs.allow_updates)
self.controller.suppress_signal(self, self.branch_combo, "_on_branch_changed", False)
if prefs.allow_updates is True:
msg = strings.options.self_update