Skip to content

fix(scrub): redact a secret after an escaped newline or a terminal code - #12

Merged
kashyap-techsuite merged 1 commit into
mainfrom
fix/scrub-escape-boundary
Oct 14, 2026
Merged

kashyap-techsuite merged 1 commit into
mainfrom
fix/scrub-escape-boundary

Conversation

@kashyap-techsuite

Copy link
Copy Markdown
Contributor

Secret shapes now also match right after an escaped \n/\r/\t/\f/\b, a \uXXXX escape, an ANSI CSI code (raw or escaped) or a charset switch. Adds those cases to the scrub corpus.

Every secret and PII shape that opened with \b needed a non-word character before the
secret. In JSON-escaped text (line one\nghp_...) and in coloured terminal output
(ESC[32m..., \u001b[32m...) the character before the secret is a letter or a hex digit, so
\b did not hold and the scan report kept the secret, or masked it only through the generic
fallback without its own label.

Each shape now starts at LEAD: \b, or right after an escaped \n \r \t \f \b, a \uXXXX
escape, an ANSI CSI sequence (any final byte, raw or escaped as \u001b[, \x1b[ or \033[),
or a character-set switch. The lookbehinds are bounded, a secret glued to a word is still
not matched, and placeholders stay at the secret's own offset.

The scrub corpus gains a GitHub token, an AWS key and a JWT in sixteen such positions,
checked by scrubText and by the scan report's redaction. Regenerates both plugin bundles.

Co-Authored-By: Claude <noreply@anthropic.com>

@samc621 samc621 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kashyap-techsuite nice solution, LGTM!

@kashyap-techsuite
kashyap-techsuite merged commit 709251c into main Oct 14, 2026
3 checks passed
@agenttrail-public-release

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.4.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants