Skip to content

FEAT: Add RegionalIndicatorConverter (regional_indicator converter) - #4450

Open
Roman Lutz (romanlutz) wants to merge 7 commits into
microsoft:mainfrom
romanlutz:gap1-regional
Open

Roman Lutz (romanlutz) wants to merge 7 commits into
microsoft:mainfrom
romanlutz:gap1-regional

Conversation

@romanlutz

@romanlutz Roman Lutz (romanlutz) commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Adds this converter as part of the gap-1 converter series (splitting the esoteric cipher / encoder set into per-converter and per-base PRs). Includes a unit test and garak Encoding-scenario registration; CI-validated locally.

Sibling PRs will be cross-linked once the series is open.

🤖 Generated with Claude Code

gap-1 converter series — splitting the esoteric cipher / encoder set into reviewable PRs (open each independently; they touch the same four registration files, so later ones rebase as earlier ones merge):

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 23:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The paired notebook is missing the new import and example, leaving the documentation representations out of sync with repository requirements.

1 open issue
What changed in this PR

Adds RegionalIndicatorConverter to PyRIT’s text transformations and makes it available in the garak Encoding scenario.

Changes:

  • Converts ASCII letters to regional indicator symbols, separating adjacent tiles to prevent flag formation.
  • Exports the converter and registers an ALL-only encoding technique.
  • Adds conversion tests, updates scenario expectations, and adds a Python documentation example.
File Description
tests/​unit/​scenario/​garak/​test_encoding.py Updates technique counts and ALL-only expectations.
tests/​unit/​converter/​test_regional_indicator_converter.py Tests conversion, separators, passthrough, and supported types.
pyrit/​scenario/​scenarios/​garak/​encoding.py Registers the regional indicator technique and converter variant.
pyrit/​converter/​regional_indicator_converter.py Implements regional indicator text conversion.
pyrit/​converter/​__init__.py Adds lazy export and typing support.
doc/​code/​converters/​1_text_to_text_converters.py Adds a converter usage example.

Review effort: Balanced

print("ROT13:", await ROT13Converter().convert_async(prompt=prompt)) # type: ignore
print("Base64:", await Base64Converter().convert_async(prompt=prompt)) # type: ignore
print("Base2048:", await Base2048Converter().convert_async(prompt=prompt)) # type: ignore
print("Regional indicator:", await RegionalIndicatorConverter().convert_async(prompt=prompt)) # type: ignore

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still applies at the current head: the paired notebook has neither the import nor the example. Also update the saved modality table in 0_converters.ipynb, which omits RegionalIndicatorConverter; the converter instructions require that reference update. Its source already discovers converters dynamically, so no hard-coded row is needed.

Verified on commit 085f5aa95f50f863e6dd2935f666c6013b5aa575.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code defects on this PR (the flag-boundary separation and the scenario-selection test) are fixed in the latest push. The paired-notebook sync is not included: 1_text_to_text_converters.ipynb and the 0_converters.ipynb modality table need a docs build that executes the notebooks (later cells call live LLM targets and need credentials), which I can't produce correct saved output for here. Leaving this open so it is tracked.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two P2 issues remain in the new conversion and scenario-selection paths; details are inline. The existing notebook synchronization concern also remains open.

Addresses review feedback on microsoft#4450: the existing assertions only check the
EncodingTechnique enum, so removing or misnaming the regional_indicator row in
_converter_variants() would still pass while selecting the technique builds no
attacks. Add a selection-path test that asserts the technique produces raw and
decode variants and actually applies RegionalIndicatorConverter.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…lIndicator)

The Encoding scenario's ALL aggregate now has 20 techniques; the scanner guide
still said 18 and ended at Bifid, omitting ColumnarTransposition (already on main)
and this PR's RegionalIndicator. Update both the paired .py and .ipynb.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…tors

Addresses the P2 on microsoft#4450: the converter only tracked whether the previous
*converted* letter was an indicator, so a newly converted letter adjacent to a
regional indicator already present in the input formed an unintended flag --
'<RI-U>S' and 'U<RI-S>' both collapsed to the US flag. Track whether the previous
emitted character was an indicator at all, and insert the U+200C separator when
two adjacent indicators include at least one this converter produced. Two
pre-existing indicators (an existing flag) are left joined. Adds tests for both
boundary directions and for preserving an existing flag.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# Conflicts:
#	doc/scanner/garak.ipynb
#	doc/scanner/garak.py
#	pyrit/scenario/scenarios/garak/encoding.py
#	tests/unit/scenario/garak/test_encoding.py

This branch has not been deployed

No deployments
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.

3 participants