mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 22:52:42 +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
@@ -13,6 +13,7 @@
|
|||||||
- Documentation ships with source
|
- Documentation ships with source
|
||||||
- Open filepicker when generating system log
|
- Open filepicker when generating system log
|
||||||
- Developers page (and -d flag)
|
- Developers page (and -d flag)
|
||||||
|
- Redact API key in log table
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
- Reduce padding on keys button
|
- Reduce padding on keys button
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
import locale
|
import locale
|
||||||
|
import os
|
||||||
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import threading
|
import threading
|
||||||
import textwrap
|
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._json import read_json, write_json
|
||||||
from dzgui.util.open_links import open_workshop_page
|
from dzgui.util.open_links import open_workshop_page
|
||||||
from dzgui.util.format import pluralize, format_mods
|
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.filepicker import FilePicker
|
||||||
from dzgui.views.dialogs.generic import GenericDialog
|
from dzgui.views.dialogs.generic import GenericDialog
|
||||||
@@ -437,7 +439,8 @@ class Controller:
|
|||||||
with open(log, "r") as f:
|
with open(log, "r") as f:
|
||||||
lines = [line.split(strings.delimiter) for line in f.read().splitlines()]
|
lines = [line.split(strings.delimiter) for line in f.read().splitlines()]
|
||||||
for record in lines:
|
for record in lines:
|
||||||
store.append(record)
|
clean = redact_log(record)
|
||||||
|
store.append(clean)
|
||||||
self.open_page(NotebookPage.LOG)
|
self.open_page(NotebookPage.LOG)
|
||||||
|
|
||||||
def select_colorized(self) -> None:
|
def select_colorized(self) -> None:
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
- Documentation ships with source
|
- Documentation ships with source
|
||||||
- Open filepicker when generating system log
|
- Open filepicker when generating system log
|
||||||
- Developers page (and -d flag)
|
- Developers page (and -d flag)
|
||||||
|
- Redact API key in log table
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
- Reduce padding on keys button
|
- Reduce padding on keys button
|
||||||
|
|||||||
@@ -4,3 +4,17 @@ def redact(text: str) -> str:
|
|||||||
r = r"(/home/)([^/])*"
|
r = r"(/home/)([^/])*"
|
||||||
cleaned = re.sub(r, r"/home/REDACTED", text)
|
cleaned = re.sub(r, r"/home/REDACTED", text)
|
||||||
return cleaned
|
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
|
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_active(active_combo)
|
||||||
self.branch_combo.set_sensitive(prefs.allow_updates)
|
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:
|
if prefs.allow_updates is True:
|
||||||
msg = strings.options.self_update
|
msg = strings.options.self_update
|
||||||
|
|||||||
Reference in new issue
Block a user