Skip to content

Redact resolved and lexical home forms before long-token wipe - #22

Merged
10-X-eng merged 2 commits into
stevecad:mainfrom
M3NT8L-One:fix/diagnostics-private-home-redaction
Nov 6, 2026
Merged

10-X-eng merged 2 commits into
stevecad:mainfrom
M3NT8L-One:fix/diagnostics-private-home-redaction

Conversation

@M3NT8L-One

Copy link
Copy Markdown
Contributor

What doesn't work

On macOS, /tmp and /var are symlinks to /private/tmp and /private/var. Temp paths from tempfile therefore show up as /var/folders/…, while anything that calls Path.resolve() returns /private/var/folders/….

diagnostics.redact_report fails to scrub the home path in that case:

  • The long-token wipe ([A-Za-z0-9_+/=.-]{80,}) runs before home redaction and includes /, so a long absolute path is replaced with [long value omitted] and never becomes [home].
  • Even with order fixed, the helper only kept home and Path(home).resolve(), so the unresolved /var/… form (what the log actually contains when the home dir is a symlink) still leaked.

tests.test_desktop_feedback.RedactionTests.test_resolved_home_and_hyphenated_api_keys_are_removed fails only on Mac for this reason.

The change

  • src/steve_desktop/diagnostics.py: collect home forms (raw, resolve(), symlink readlink target, and the /private-stripped twin), redact email / home-folder patterns / those home forms / username before _redact (so the long-value scrub cannot eat paths first). Long secrets and bearer/api-key rules still run afterward.
  • tests/test_desktop_feedback.py: add a symlinked temp-root test that embeds both lexical and resolved forms (reproduces on Linux too) and asserts paths ≥80 chars become [home] not [long value omitted]; add a both-ways check that ordinary short text survives while long opaque values are still scrubbed.

No change to the two resolved-path test expects (those land in the companion PR). No change to windows_updates.py, updater, signing, local_git.py, workflows, or deps. Split from #18; this PR carries only the redaction half.

Tests

Studio Mac (/tmp/cadmac-smoke/venv read-only, PYTHONPATH=src:., QT_QPA_PLATFORM=offscreen, vault_hook armed under python -m unittest, pgrep SecurityAgent empty before and after; no smoke test; /tmp/cadmac-smoke left alone):

sha tests.test_desktop_feedback full unittest discover
Before (upstream main) 583e858 9 ran, 1 failed (redaction) 271 ran, 4 failed, 40 skipped
After (this branch) d7c2231 11 ran, OK 273 ran, 3 failed, 40 skipped

The remaining 3 discover failures on this branch are: the two resolved-path test expects (covered by the companion PR) plus a pre-existing test_hot_worker failure also present on upstream main on this Studio (not introduced here). Focused redaction module is green standalone.

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 stevecad#18.
@10-X-eng

10-X-eng commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Thanks for the contribution! This is driven by macOS path behaviour, which isn't a supported platform, and it reorders the redaction applied to diagnostic reports in a way that could let secrets through. A maintainer needs to decide on it. We'll follow up here.

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 <noreply@anthropic.com>
@10-X-eng
10-X-eng merged commit 4ff81bb into stevecad:main Nov 6, 2026
@10-X-eng

10-X-eng commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Thanks, merged. One change on top: report redaction now removes the app's known secrets first, before the home, email and account-name passes. Otherwise a token that contains the account name was partly rewritten before it could be matched, and the rest of it stayed in the report. There's a test for it (test_secret_holding_the_account_name_is_removed_whole). The long-value wipe still runs last, as you had it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-human Waiting for a maintainer's decision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants