fix(security): sanitize logs, redact secrets, harden XML parsing

Address actionable CodeQL security-extended findings and extend the same redaction to the debug JSONL logger
This commit is contained in:
imSp4rky
2026-06-09 19:08:41 -06:00
parent 2d43c2601e
commit 7064d261c2
11 changed files with 123 additions and 46 deletions
+12 -4
View File
@@ -30,6 +30,7 @@ from unidecode import unidecode
from unshackle.core.config import config
from unshackle.core.constants import LANGUAGE_EXACT_DISTANCE, LANGUAGE_MAX_DISTANCE
from unshackle.core.utils.redact import redact_text
"""
Utility functions for the unshackle media archival tool.
@@ -836,7 +837,7 @@ class DebugLogger:
if operation:
entry["operation"] = operation
if message:
entry["message"] = message
entry["message"] = redact_text(message)
if service:
entry["service"] = service
if context:
@@ -853,8 +854,10 @@ class DebugLogger:
if error:
entry["error"] = {
"type": type(error).__name__,
"message": str(error),
"traceback": traceback.format_exception(type(error), error, error.__traceback__),
"message": redact_text(str(error)),
"traceback": [
redact_text(line) for line in traceback.format_exception(type(error), error, error.__traceback__)
],
}
for key, value in kwargs.items():
@@ -875,7 +878,12 @@ class DebugLogger:
if data is None:
return None
if isinstance(data, (str, int, float, bool)):
if isinstance(data, str):
# mask URL userinfo and secret-bearing query params that key-based
# redaction can't catch (e.g. a proxy URL inside a non-sensitive field)
return redact_text(data)
if isinstance(data, (int, float, bool)):
return data
if isinstance(data, (list, tuple)):