Files
craft-ai-integrations/tools/mutation/scrub.py
MexandJeremy 3441cacd12 fix(mutation): redact Unix profile paths from verification logs (#62)
* fix(mutation): scrub Unix profile paths from verification logs

Redact /home and /Users account folders while preserving the path suffix and existing Windows/MSYS behavior.

* test(mutation): cover Unix and Windows log profile redaction

* fix(mutation): redact JSON-escaped Unix profile paths

* test(mutation): cover escaped Unix profile paths

Add test for JSON escaped Unix profiles to ensure suffix is preserved.

* ci: run mutation tooling Python regression tests

Add Python unit tests for mutation testing in CI workflow.

* test(mutation): document conservative profile redaction

Keep the collaborator-reviewed Fedora, WSL and URI redaction policy. Add explicit controls and document the privacy rationale without changing the production regex. All six Python tests and compileall pass.

---------

Co-authored-by: Jeremy <jeremy8776@googlemail.com>
2026-10-21 14:02:24 +01:00

16 lines
558 B
Python

"""Replace a Windows or Unix profile folder in captured output with %USERPROFILE%.
The verification scripts pass everything they save through `scrub`, so logs and summaries
committed to a public repository never carry the person's account name.
Privacy takes priority over preserving nested profile paths and URLs unchanged.
"""
import re
_PROFILE = re.compile(
r"(?:(?:[A-Za-z]:(?:\\\\|\\|/)+|/[a-z]/)Users(?:\\\\|\\|/)+|\\?/(?:Users|home)\\?/)"
r"[^\\/\s\"'<>|:*?]+"
)
def scrub(text: str) -> str:
return _PROFILE.sub("%USERPROFILE%", text)