Repository navigation
FIX: Make the DenylistConverter pre-flight check case-insensitive - #4080
Closed
电大老baby (HhH666-ux) wants to merge 1 commit into
Closed
电大老baby (HhH666-ux) wants to merge 1 commit into
电大老baby (HhH666-ux) wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The lower()-based pre-flight check misses valid Unicode denylist matches, such as Greek sigma, returning the prompt unchanged without calling the target.
1 open issue
What changed in this PR
This PR addresses #4061 by making DenylistConverter’s pre-flight check case-insensitive, aligning it with the converter’s system prompt instructions.
Changes:
- Lowercase denylist terms and prompts before checking for matches.
- Add a regression test confirming that a case-mismatched phrase reaches the converter target.
| File | Description |
|---|---|
| tests/unit/converter/test_denylist_converter.py | Adds coverage for a case-mismatched denylisted phrase. |
| pyrit/converter/denylist_converter.py | Updates the pre-flight substring check to ignore casing. |
Review effort: Balanced
| # update the prompt replacing the denied words with synonyms | ||
| denylist = self._prompt_kwargs.get("denylist", []) | ||
| if any(word in prompt for word in denylist): | ||
| if any(word.lower() in prompt.lower() for word in denylist): |
Contributor
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.

Description
DenylistConverter.convert_asyncshort-circuited with a case-sensitive substring check, so a prompt containing a case-mismatched denylisted term (e.g.Molotov cocktailagainstmolotov cocktail) was returned unchanged without ever calling the converter target. The system prompt template documents case-insensitive matching.Fixes #4061