pyrit.scenarios.FoundryStrategy#
- class FoundryStrategy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
ScenarioStrategyStrategies for attacks with tag-based categorization.
Each enum member is defined as (value, tags) where: - value: The strategy name (string) - tags: Set of tags for categorization (e.g., {“easy”, “converter”})
Tags can include complexity levels (easy, moderate, difficult) and other characteristics (converter, multi_turn, jailbreak, llm_assisted, etc.).
Aggregate tags (EASY, MODERATE, DIFFICULT, ALL) can be used to expand into all strategies with that tag.
Example
>>> strategy = FoundryStrategy.Base64 >>> print(strategy.value) # "base64" >>> print(strategy.tags) # {"easy", "converter"} >>> >>> # Get all easy strategies >>> easy_strategies = FoundryStrategy.get_strategies_by_tag("easy") >>> >>> # Get all converter strategies >>> converter_strategies = FoundryStrategy.get_strategies_by_tag("converter") >>> >>> # Expand EASY to all easy strategies >>> scenario = FoundryScenario(target, attack_strategies={FoundryStrategy.EASY})
- __init__(*args, **kwds)#
Methods
Get the set of tags that represent aggregate categories.
get_strategies_by_tag(tag)Get all attack strategies that have a specific tag.
get_all_strategies()Get all non-aggregate strategies for this strategy enum.
get_aggregate_strategies()Get all aggregate strategies for this strategy enum.
normalize_strategies(strategies)Normalize a set of attack strategies by expanding aggregate tags.
prepare_scenario_strategies([strategies, ...])Prepare and normalize scenario strategies for use in a scenario.
Indicate that FoundryStrategy supports composition.
validate_composition(strategies)Validate whether the given Foundry strategies can be composed together.
Attributes
tagsGet the tags for this attack strategy.
- ALL = 'all'#
- AnsiAttack = 'ansi_attack'#
- AsciiArt = 'ascii_art'#
- AsciiSmuggler = 'ascii_smuggler'#
- Atbash = 'atbash'#
- Base64 = 'base64'#
- Binary = 'binary'#
- Caesar = 'caesar'#
- CharSwap = 'char_swap'#
- CharacterSpace = 'character_space'#
- Crescendo = 'crescendo'#
- DIFFICULT = 'difficult'#
- Diacritic = 'diacritic'#
- EASY = 'easy'#
- Flip = 'flip'#
- Jailbreak = 'jailbreak'#
- Leetspeak = 'leetspeak'#
- MODERATE = 'moderate'#
- Morse = 'morse'#
- MultiTurn = 'multi_turn'#
- ROT13 = 'rot13'#
- StringJoin = 'string_join'#
- SuffixAppend = 'suffix_append'#
- Tense = 'tense'#
- UnicodeConfusable = 'unicode_confusable'#
- UnicodeSubstitution = 'unicode_substitution'#
- Url = 'url'#
- classmethod get_aggregate_tags() set[str][source]#
Get the set of tags that represent aggregate categories.
- classmethod supports_composition() bool[source]#
Indicate that FoundryStrategy supports composition.
- Returns:
True, as Foundry strategies can be composed together (with rules).
- Return type:
- classmethod validate_composition(strategies: Sequence[ScenarioStrategy]) None[source]#
Validate whether the given Foundry strategies can be composed together.
Foundry-specific composition rules: - Multiple attack strategies (e.g., Crescendo, MultiTurn) cannot be composed together - Converters can be freely composed with each other - At most one attack can be composed with any number of converters
- Parameters:
strategies (Sequence[ScenarioStrategy]) – The strategies to validate for composition.
- Raises:
ValueError – If the composition violates Foundry’s rules (e.g., multiple attack).