fix(redaction): merge overlapping spans to redact full union - #242
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #240.
Problem
Redactor.Scrubdropped any hit whoseStart < lastEnd. For partial overlap (A.Start < B.Start && A.End < B.End) this lefts[A.End:B.End]un-redacted — a silent secret leak. The accept-loop treated all overlap as "shadow and drop", which is only correct for containment.Fix
Replace drop-on-overlap with the standard interval merge: extend the previous accepted span's
Endtomax(prevEnd, h.End)instead of dropping the later hit. Every byte flagged by any pattern is now redacted. The anchor (earliest-start) kind labels the merged span (a single union redaction, as the issue suggested) — no new kind, no API change.Verification
TestScrub_MergesPartialOverlapreproduces the issue's exact repro: old code emitted«redacted:short»FGHIJKL trailing(leak); now«redacted:short» trailing. Confirmed red→green.TestScrub_OverlapPrefersLongerstill reports one container hit).make build·make test(all packages) ·internal/redaction114/114 ·make lint0 issues · 15sFuzzScrubno crashers.Note
KindCountsreports only the anchor kind for a merged multi-kind span — a deliberate, minor observability trade-off for a rare overlap edge case, not a defect.🤖 Generated with Claude Code