Skip to content

MAINT: Consolidate regex-based scorers under regex/ #2065

Open
rlundeen2 wants to merge 1 commit into
microsoft:mainfrom
rlundeen2:rlundeen2-regex-scorers-consolidation
Open

MAINT: Consolidate regex-based scorers under regex/ #2065
rlundeen2 wants to merge 1 commit into
microsoft:mainfrom
rlundeen2:rlundeen2-regex-scorers-consolidation

Conversation

@rlundeen2

Copy link
Copy Markdown
Contributor

This consolidates all regex-based true/false scorers under pyrit/score/true_false/regex/. Several scorers (the Anthrax/Fentanyl/Meth/NerveAgent keyword scorers and StaticPromptInjectionScorer) already subclassed RegexScorer but lived a directory up, so they've been moved into the regex/ package alongside the existing RegexScorer, CredentialLeakScorer, and the OWASP LLM02 insecure-output scorers. The moves use git mv to preserve history, and since these files already referenced RegexScorer via absolute imports, their contents are unchanged. The corresponding test files were moved into tests/unit/score/regex/ to match. Public class names are re-exported from pyrit.score exactly as before, so no downstream imports, docs, or scenarios break.

Additionally, MarkdownInjectionScorer was migrated from a hand-rolled re.findall TrueFalseScorer into a proper RegexScorer subclass with named default patterns for inline (![alt](url)) and reference-style (![alt][ref]) markdown image syntax, tagged with the security category. No deprecations were added, per the request. The SubStringScorer and DecodingScorer were intentionally left in place since they use TextMatching rather than regex. The full tests/unit/score/ suite (1215 passed, 16 skipped) plus ruff and ty checks all pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rlundeen2 rlundeen2 changed the title Consolidate regex-based scorers under regex/ and migrate MarkdownInjectionScorer MAINT: Consolidate regex-based scorers under regex/ Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant