Repository navigation
FEAT: Add DRAConverter (disguise-and-reconstruction from garak) - #4659
Open
Seung-wa Akpan (seung-waedet) wants to merge 2 commits into
Open
Seung-wa Akpan (seung-waedet) wants to merge 2 commits into
Seung-wa Akpan (seung-waedet) wants to merge 2 commits into
Conversation
Port garak's DRA probe as a seeded text converter. The prompt is spelled one letter per line inside harmless phrases, followed by a word guide and an answer-forcing template. Templates, letter map, tool phrases, and the 204 flagged words are packaged as YAML generated from garak f1c99df. Fixes microsoft#4639
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The template cache is not preloaded during construction, so the first async conversion synchronously reads and parses YAML on the event-loop thread.
1 open issue
What changed in this PR
Adds DRAConverter to PyRIT’s text-to-text converter library, addressing #4639 with a single-shot implementation adapted from garak.
Changes:
- Adds configurable templates, word truncation settings, seeded randomness, and lazy public exports.
- Adds packaged data, unit tests, and identifier contract samples.
- Updates documentation, research citations, and third-party attribution.
| File | Description |
|---|---|
third_party/garak-provenance.json |
Records upstream sources and revision. |
THIRD_PARTY_NOTICES.txt |
Adds LLM-DRA attribution and license. |
tests/unit/registry/converter_identifier_samples.py |
Supplies template enum samples. |
tests/unit/converter/test_dra_converter.py |
Tests conversion, settings, randomness, and identifiers. |
pyrit/datasets/converters/dra_converter.yaml |
Adds four templates. |
pyrit/datasets/converters/dra_converter_words.yaml |
Adds character phrases, tools, and flagged words. |
pyrit/converter/dra_converter.py |
Implements the converter and template enum. |
pyrit/converter/__init__.py |
Exposes both symbols through lazy exports. |
doc/references.bib |
Adds the research citation. |
doc/code/converters/1_text_to_text_converters.py |
Adds a usage example. |
doc/code/converters/1_text_to_text_converters.ipynb |
Adds the matching example and saved output. |
doc/code/converters/0_converters.ipynb |
Lists the converter’s supported modalities. |
doc/bibliography.md |
Includes the new citation key. |
Review effort: Balanced
| self._benign_keep_ratio = benign_keep_ratio | ||
| self._benign_full_word_probability = benign_full_word_probability | ||
| self._seed = seed | ||
| self._words = _load_words() |
This branch has not been deployed
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
Adds
DRAConverterandDRATemplate, ported from garak's DRA probe (Liu et al., USENIX Security 2024). The converter spells the lowercased prompt one letter per line inside harmless phrases, then adds a word guide and instructions to rebuild the request and answer it. Fixes #4639.DRATemplate, garak's three truncation settings with garak's defaults, and an optionalseed. With no template, each conversion picks one from the seeded stream, asAskToDecodeConverterdoes.pyrit/datasets/converters/dra_converter*.yaml, generated by a script from garak atf1c99df.benign_keep_ratiocan't send an empty""hint; and the stray space in tail hints is gone.garak-provenance.jsonandTHIRD_PARTY_NOTICES.txt.0_converterstable row, andliu2024drain the bibliography.converter_identifier_samples.pygets aDRAConverter.templatesample so the contract test doesn't pass it the generic string samples.Not ported: the
harmful_behaviorspayloads, the paper's retry loop,DRAAdvancedwith Detoxify, and garak's prompt cap.