mirror of
https://github.com/aclist/dztui.git
synced 2026-08-25 17:32:36 +02:00
Merge pull request #24 from aclist/feat/redact-api-key
feat: redact API key in log table
This commit is contained in:
commit
88b85eb502
@ -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
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import logging
|
||||
import os
|
||||
import locale
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import threading
|
||||
import textwrap
|
||||
@ -46,6 +47,7 @@ from dzgui.util import localize, cooldown, strings
|
||||
from dzgui.util._json import read_json, write_json
|
||||
from dzgui.util.open_links import open_workshop_page
|
||||
from dzgui.util.format import pluralize, format_mods
|
||||
from dzgui.util.redact import redact_log
|
||||
|
||||
from dzgui.views.dialogs.filepicker import FilePicker
|
||||
from dzgui.views.dialogs.generic import GenericDialog
|
||||
@ -437,7 +439,8 @@ 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 = redact_log(record)
|
||||
store.append(clean)
|
||||
self.open_page(NotebookPage.LOG)
|
||||
|
||||
def select_colorized(self) -> None:
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user