Revision: 1 Last modified: 2026-12-04T19:00:00Z
redact.py is the redaction gate for outgoing payloads (anchor §11.4.300(D)).
It scans a payload before any write and reports findings that carry a field name and a kind only — never the matched text.
That restraint is the whole design. A redactor that logged the secret it found, or echoed it into a
finding, would leak the exact thing it exists to protect — into a log, a test fixture, a report, or a
review comment. So the finding says "field title matched kind github-token", and never
"field title contained ghp_…".
It also provides normalise, which strips zero-width and bidirectional control characters before scanning.
That matters because a token split by an invisible character still reads as a token to a human and to
GitHub, but not to a naive regex.
python3(standard library only:hashlib,re,unicodedata).- No network, no files.
from issue_sync import redact
# normalise first: strip zero-width / bidi controls that can split a token
clean = redact.normalise(raw_text)
# scan a payload; findings name the field and kind, never the matched text
findings = redact.scan(payload) # UNCONFIRMED: exact scanner name
if findings:
# refuse the write
...UNCONFIRMED: the precise scanner entry-point name was not read while writing this guide. Inspect the
module before depending on one:
python3 -c "import issue_sync.redact as r; print([n for n in dir(r) if not n.startswith('_')])".
| Name | Kind | Contract |
|---|---|---|
normalise(text) |
function | Strips zero-width and bidirectional control characters (U+00AD, U+200B–U+200F, U+202A–U+202E, U+2060–U+2064, U+FEFF) so a split token is scanned as one token. |
_ZERO_WIDTH |
regex | The compiled character class normalise removes. |
Scanner functions return findings containing field and kind only.
A library, so no exit codes. A finding causes the caller (payload.py's pre-write gate) to refuse the
write, which surfaces to the CLI as the package's 1 (refused) or 2 (cannot determine).
- A token split by a zero-width space.
normaliserejoins it, so the scan sees one token. - Bidirectional override characters. Removed — they are a classic way to make a string display differently from its byte content.
- A finding is reported. It carries field + kind only. The matched text never appears in the finding, the log or an error message.
- A secret in a field that is not mirrored. The allowlist in
payload.pyalready prevents it from being sent; redaction is a second, independent layer. - A near-miss (partial token). The conservative direction is to report; an unnecessary redaction is recoverable, an unnecessary publication is not.
- Unicode normalisation forms.
unicodedatais imported for that reason — a visually identical character sequence should not evade the scan.
normalise(text)removes zero-width and bidi control characters.- The scanner walks the payload's fields, applying the secret patterns to normalised text.
- For each match it records
(field, kind)— never the matched substring. - Returns the findings; the caller decides to refuse.
Imported by config.py, payload.py and (transitively) engine.py, cli.py, pipeline.py.
Companion guard for inbound text: inbound.py (secret-scan with whole-text withholding) — a different
policy for a different direction, both built on the same principle that untrusted text must not travel
unexamined.
See also docs/scripts/payload.md, docs/scripts/inbound.md and docs/scripts/config.md.
2026-12-04 — python3 -c "import ast;ast.parse(open('scripts/issue_sync/redact.py').read())" → exit 0.
python3 -c "import issue_sync.redact as r; print(r.normalise('a\u200bb'))" prints ab (the zero-width
space is removed).