Skip to content

FEAT: Add RailFenceConverter (rail_fence converter) - #4442

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

Roman Lutz (romanlutz) wants to merge 3 commits into
microsoft:mainfrom
romanlutz:gap1-railfence

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:34

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 RailFenceConverter import, example, and executed output, leaving the two documentation formats out of sync.

1 open issue
What changed in this PR

Adds a configurable Rail Fence cipher converter to PyRIT and makes it available in the Garak Encoding scenario.

Changes:

  • Implements text transposition with configurable rails and exposes the converter through lazy package exports.
  • Registers rail_fence as an ALL-only encoding technique, leaving the default selection unchanged.
  • Adds converter 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_rail_fence_converter.py Tests cipher vectors, edge cases, validation, and identifiers.
pyrit/​scenario/​scenarios/​garak/​encoding.py Registers the Rail Fence technique and converter variant.
pyrit/​converter/​rail_fence_converter.py Implements the configurable text-to-text cipher.
pyrit/​converter/​__init__.py Adds public lazy and type-checking exports.
doc/​code/​converters/​1_text_to_text_converters.py Adds a Rail Fence 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("Rail fence:", await RailFenceConverter().convert_async(prompt=prompt)) # type: ignore

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.

2 participants