Cover prompt-injection-redact findContainer escalation paths#145
Merged
Conversation
Brings src/rules/prompt-injection-redact.ts from 81.25% to 90.62% statements and 44.44% to 77.77% branches. The gap was in findContainer's escalation guard — when the only ancestor is <body>/<html> the rule must *not* redact (that would black out the whole page), and when the only ancestor is a non-block element the rule should fall back to the direct parent rather than escalate further. Both branches now have direct tests. The remaining uncovered locations (the `!parent`, `!element.isConnected`, and inner `isInsidePlaceholder` checks at lines 41/78/81) are defense-in-depth fallbacks that the upstream `walkTextNodes` and `filterToOutermost` invariants already prevent — leaving them in the source documents intent but they can't be exercised from a normal DOM. Ratchet src/rules thresholds 90/77/95/90 → 91/78/96/91. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Brings `src/rules/prompt-injection-redact.ts` from 81.25% → 90.62% statements and 44.44% → 77.77% branches. The gap was in `findContainer`'s escalation guard.
What the new tests cover
Remaining gap
The three still-uncovered checks (`!parent`, `!element.isConnected`, inner `isInsidePlaceholder` at lines 41/78/81) are defense-in-depth fallbacks. `walkTextNodes` and `filterToOutermost` invariants upstream prevent the conditions from being reachable in normal flow. Leaving them as-is documents intent without forcing synthetic coverage.
Ratchet
`./src/rules/` thresholds 90/77/95/90 → 91/78/96/91.
Test plan
🤖 Generated with Claude Code