From d7c2231c88ce87536e8210f29952928e8da9bc9c Mon Sep 17 00:00:00 2001 From: M3NT8L-One <78830965+M3NT8L-One@users.noreply.github.com> Date: Wed, 4 Nov 2026 15:06:05 +0000 Subject: [PATCH 1/2] Redact home paths before long-value scrub (macOS /private) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apply email/home/username redaction before the ≥80-char wipe, and keep both lexical and resolved (/var vs /private/var) home forms so long temp paths become [home] instead of [long value omitted]. Split from #18. --- src/steve_desktop/diagnostics.py | 23 ++++++++++++---- tests/test_desktop_feedback.py | 47 ++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/src/steve_desktop/diagnostics.py b/src/steve_desktop/diagnostics.py index b46541c..bb107a3 100644 --- a/src/steve_desktop/diagnostics.py +++ b/src/steve_desktop/diagnostics.py @@ -47,21 +47,35 @@ def redact_report(text, secrets=(), home=None, user=None): user = getpass.getuser() except Exception: user = '' - text = _redact(text, secrets) + # Apply home / email / username before the long-token wipe so absolute paths that + # are ≥80 characters (common under macOS /var/folders/…) become [home] instead of + # [long value omitted]. Keep both the lexical and resolved forms: on Darwin, + # /var is a symlink to /private/var, so tempfile paths and Path.resolve() disagree. text = EMAIL.sub('[email]', text) for pattern, replacement in HOME_FOLDERS: text = pattern.sub(replacement, text) homes = [] if home and len(home) > 3: # A home folder outside the usual locations. homes.append(home) + home_path = Path(home) try: # Tracebacks often contain the resolved path when the home directory # itself is a symlink (another disk, or a bind mount). - resolved = str(Path(home).resolve()) + resolved = str(home_path.resolve()) except OSError: resolved = '' - if resolved and len(resolved) > 3 and resolved not in homes: + if resolved and len(resolved) > 3: homes.append(resolved) + # /private/var/… ↔ /var/… (and the same for /tmp). + if resolved.startswith('/private/'): + homes.append(resolved[len('/private'):]) + try: + if home_path.is_symlink(): + link = home_path.readlink() + target = link if link.is_absolute() else home_path.parent / link + homes.append(str(target)) + except OSError: + pass forms = [] for item in homes: forms.extend((item, item.replace('\\', '/'), item.replace('\\', '\\\\'))) @@ -70,8 +84,7 @@ def redact_report(text, secrets=(), home=None, user=None): text = re.sub(re.escape(form) + r'(?![A-Za-z0-9._-])', '[home]', text, flags=re.I) if user and len(user) >= 3: text = re.sub(r'(? Date: Fri, 6 Nov 2026 01:40:25 +0000 Subject: [PATCH 2/2] Redact known secrets before home, email and account-name passes Changing part of a secret first (an account name inside a token) left the rest of it in the report. Secrets now go first; the long-value wipe still runs last. Co-Authored-By: Claude Opus 5.5 --- src/steve_desktop/diagnostics.py | 14 ++++++++++++-- tests/test_desktop_feedback.py | 10 ++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/steve_desktop/diagnostics.py b/src/steve_desktop/diagnostics.py index bb107a3..8456b15 100644 --- a/src/steve_desktop/diagnostics.py +++ b/src/steve_desktop/diagnostics.py @@ -10,10 +10,16 @@ _lock = threading.RLock() -def _redact(text, secrets=()): +def _redact_secrets(text, secrets=()): + """The exact secrets this app holds, longest first.""" text = str(text) for secret in sorted((str(s) for s in secrets if s and len(str(s)) >= 4), key=len, reverse=True): text = text.replace(secret, '[redacted]') + return text + + +def _redact(text, secrets=()): + text = _redact_secrets(text, secrets) text = re.sub(r'https?://[^\s<>\"\']+', '[URL omitted]', text) text = re.sub(r'data:image/[^\s\"\']+', '[image omitted]', text) text = re.sub(r'(?i)(bearer\s+)[^\s,;\"\']+', r'\1[redacted]', text) @@ -47,6 +53,9 @@ def redact_report(text, secrets=(), home=None, user=None): user = getpass.getuser() except Exception: user = '' + # Known secrets first, while they're still exactly as held: the home, email and + # account-name passes below could change part of one so it no longer matches. + text = _redact_secrets(text, secrets) # Apply home / email / username before the long-token wipe so absolute paths that # are ≥80 characters (common under macOS /var/folders/…) become [home] instead of # [long value omitted]. Keep both the lexical and resolved forms: on Darwin, @@ -84,7 +93,8 @@ def redact_report(text, secrets=(), home=None, user=None): text = re.sub(re.escape(form) + r'(?![A-Za-z0-9._-])', '[home]', text, flags=re.I) if user and len(user) >= 3: text = re.sub(r'(?