|
31 | 31 | " [--list-initializers] [--database DATABASE]\n", |
32 | 32 | " [--initializers INITIALIZERS [INITIALIZERS ...]]\n", |
33 | 33 | " [--initialization-scripts INITIALIZATION_SCRIPTS [INITIALIZATION_SCRIPTS ...]]\n", |
| 34 | + " [--env-files ENV_FILES [ENV_FILES ...]]\n", |
34 | 35 | " [--strategies SCENARIO_STRATEGIES [SCENARIO_STRATEGIES ...]]\n", |
35 | 36 | " [--max-concurrency MAX_CONCURRENCY]\n", |
36 | 37 | " [--max-retries MAX_RETRIES] [--memory-labels MEMORY_LABELS]\n", |
| 38 | + " [--dataset-names DATASET_NAMES [DATASET_NAMES ...]]\n", |
| 39 | + " [--max-dataset-size MAX_DATASET_SIZE]\n", |
37 | 40 | " [scenario_name]\n", |
38 | 41 | "\n", |
39 | 42 | "PyRIT Scanner - Run security scenarios against AI systems\n", |
|
44 | 47 | " pyrit_scan --list-initializers\n", |
45 | 48 | "\n", |
46 | 49 | " # Run a scenario with built-in initializers\n", |
47 | | - " pyrit_scan foundry_scenario --initializers openai_objective_target load_default_datasets\n", |
| 50 | + " pyrit_scan foundry --initializers openai_objective_target load_default_datasets\n", |
48 | 51 | "\n", |
49 | 52 | " # Run with custom initialization scripts\n", |
50 | | - " pyrit_scan garak.encoding_scenario --initialization-scripts ./my_config.py\n", |
| 53 | + " pyrit_scan garak.encoding --initialization-scripts ./my_config.py\n", |
51 | 54 | "\n", |
52 | 55 | " # Run specific strategies or options\n", |
53 | | - " pyrit scan foundry_scenario --strategies base64 rot13 --initializers openai_objective_target\n", |
54 | | - " pyrit_scan foundry_scenario --initializers openai_objective_target --max-concurrency 10 --max-retries 3\n", |
55 | | - " pyrit_scan garak.encoding_scenario --initializers openai_objective_target --memory-labels '{\"run_id\":\"test123\"}'\n", |
| 56 | + " pyrit scan foundry --strategies base64 rot13 --initializers openai_objective_target\n", |
| 57 | + " pyrit_scan foundry --initializers openai_objective_target --max-concurrency 10 --max-retries 3\n", |
| 58 | + " pyrit_scan garak.encoding --initializers openai_objective_target --memory-labels '{\"run_id\":\"test123\"}'\n", |
56 | 59 | "\n", |
57 | 60 | "positional arguments:\n", |
58 | 61 | " scenario_name Name of the scenario to run\n", |
|
72 | 75 | " --initialization-scripts INITIALIZATION_SCRIPTS [INITIALIZATION_SCRIPTS ...]\n", |
73 | 76 | " Paths to custom Python initialization scripts to run\n", |
74 | 77 | " before the scenario\n", |
75 | | - " --strategies SCENARIO_STRATEGIES [SCENARIO_STRATEGIES ...], -s SCENARIO_STRATEGIES [SCENARIO_STRATEGIES ...]\n", |
| 78 | + " --env-files ENV_FILES [ENV_FILES ...]\n", |
| 79 | + " Paths to environment files to load in order (e.g.,\n", |
| 80 | + " .env.production .env.local). Later files override\n", |
| 81 | + " earlier ones.\n", |
| 82 | + " --strategies, -s SCENARIO_STRATEGIES [SCENARIO_STRATEGIES ...]\n", |
76 | 83 | " List of strategy names to run (e.g., base64 rot13)\n", |
77 | 84 | " --max-concurrency MAX_CONCURRENCY\n", |
78 | 85 | " Maximum number of concurrent attack executions (must\n", |
|
82 | 89 | " be >= 0)\n", |
83 | 90 | " --memory-labels MEMORY_LABELS\n", |
84 | 91 | " Additional labels as JSON string (e.g.,\n", |
85 | | - " '{\"experiment\": \"test1\"}')\n" |
| 92 | + " '{\"experiment\": \"test1\"}')\n", |
| 93 | + " --dataset-names DATASET_NAMES [DATASET_NAMES ...]\n", |
| 94 | + " List of dataset names to use instead of scenario\n", |
| 95 | + " defaults (e.g., harmbench advbench). Creates a new\n", |
| 96 | + " dataset config; fetches all items unless --max-\n", |
| 97 | + " dataset-size is also specified\n", |
| 98 | + " --max-dataset-size MAX_DATASET_SIZE\n", |
| 99 | + " Maximum number of items to use from the dataset (must\n", |
| 100 | + " be >= 1). Limits new datasets if --dataset-names\n", |
| 101 | + " provided, otherwise overrides scenario's default limit\n" |
86 | 102 | ] |
87 | 103 | } |
88 | 104 | ], |
|
111 | 127 | "output_type": "stream", |
112 | 128 | "text": [ |
113 | 129 | "Starting PyRIT...\n", |
| 130 | + "Found default environment files: ['C:\\\\Users\\\\rlundeen\\\\.pyrit\\\\.env', 'C:\\\\Users\\\\rlundeen\\\\.pyrit\\\\.env.local']\n", |
| 131 | + "Loaded environment file: C:\\Users\\rlundeen\\.pyrit\\.env\n", |
| 132 | + "Loaded environment file: C:\\Users\\rlundeen\\.pyrit\\.env.local\n", |
114 | 133 | "\n", |
115 | 134 | "Available Scenarios:\n", |
116 | 135 | "================================================================================\n", |
117 | 136 | "\u001b[1m\u001b[36m\n", |
118 | | - " airt.content_harms_scenario\u001b[0m\n", |
119 | | - " Class: ContentHarmsScenario\n", |
| 137 | + " airt.content_harms\u001b[0m\n", |
| 138 | + " Class: ContentHarms\n", |
120 | 139 | " Description:\n", |
121 | 140 | " Content Harms Scenario implementation for PyRIT. This scenario contains\n", |
122 | 141 | " various harm-based checks that you can run to get a quick idea about\n", |
|
126 | 145 | " Available Strategies (7):\n", |
127 | 146 | " hate, fairness, violence, sexual, harassment, misinformation, leakage\n", |
128 | 147 | " Default Strategy: all\n", |
129 | | - " Required Datasets (7):\n", |
| 148 | + " Default Datasets (7, max 4 per dataset):\n", |
130 | 149 | " airt_hate, airt_fairness, airt_violence, airt_sexual, airt_harassment,\n", |
131 | 150 | " airt_misinformation, airt_leakage\n", |
132 | 151 | "\u001b[1m\u001b[36m\n", |
133 | | - " airt.cyber_scenario\u001b[0m\n", |
134 | | - " Class: CyberScenario\n", |
| 152 | + " airt.cyber\u001b[0m\n", |
| 153 | + " Class: Cyber\n", |
135 | 154 | " Description:\n", |
136 | 155 | " Cyber scenario implementation for PyRIT. This scenario tests how willing\n", |
137 | 156 | " models are to exploit cybersecurity harms by generating malware. The\n", |
138 | | - " CyberScenario class contains different variations of the malware\n", |
139 | | - " generation techniques.\n", |
| 157 | + " Cyber class contains different variations of the malware generation\n", |
| 158 | + " techniques.\n", |
140 | 159 | " Aggregate Strategies:\n", |
141 | 160 | " - all\n", |
142 | 161 | " Available Strategies (2):\n", |
143 | 162 | " single_turn, multi_turn\n", |
144 | 163 | " Default Strategy: all\n", |
145 | | - " Required Datasets (1):\n", |
| 164 | + " Default Datasets (1, max 4 per dataset):\n", |
146 | 165 | " airt_malware\n", |
147 | 166 | "\u001b[1m\u001b[36m\n", |
148 | | - " foundry_scenario\u001b[0m\n", |
| 167 | + " foundry\u001b[0m\n", |
149 | 168 | " Class: FoundryScenario\n", |
150 | 169 | " Description:\n", |
151 | | - " FoundryScenario is a preconfigured scenario that automatically generates\n", |
152 | | - " multiple AtomicAttack instances based on the specified attack\n", |
153 | | - " strategies. It supports both single-turn attacks (with various\n", |
154 | | - " converters) and multi-turn attacks (Crescendo, RedTeaming), making it\n", |
155 | | - " easy to quickly test a target against multiple attack vectors. The\n", |
156 | | - " scenario can expand difficulty levels (EASY, MODERATE, DIFFICULT) into\n", |
157 | | - " their constituent attack strategies, or you can specify individual\n", |
158 | | - " strategies directly. Note this is not the same as the Foundry AI Red\n", |
159 | | - " Teaming Agent. This is a PyRIT contract so their library can make use of\n", |
160 | | - " PyRIT in a consistent way.\n", |
| 170 | + " Deprecated alias for Foundry. This class is deprecated and will be\n", |
| 171 | + " removed in version 0.13.0. Use `Foundry` instead.\n", |
161 | 172 | " Aggregate Strategies:\n", |
162 | 173 | " - all, easy, moderate, difficult\n", |
163 | | - " Available Strategies (23):\n", |
| 174 | + " Available Strategies (25):\n", |
164 | 175 | " ansi_attack, ascii_art, ascii_smuggler, atbash, base64, binary, caesar,\n", |
165 | 176 | " character_space, char_swap, diacritic, flip, leetspeak, morse, rot13,\n", |
166 | 177 | " suffix_append, string_join, unicode_confusable, unicode_substitution,\n", |
167 | | - " url, jailbreak, tense, multi_turn, crescendo\n", |
| 178 | + " url, jailbreak, tense, multi_turn, crescendo, pair, tap\n", |
168 | 179 | " Default Strategy: easy\n", |
169 | | - " Required Datasets (1):\n", |
| 180 | + " Default Datasets (1, max 4 per dataset):\n", |
170 | 181 | " harmbench\n", |
171 | 182 | "\u001b[1m\u001b[36m\n", |
172 | | - " garak.encoding_scenario\u001b[0m\n", |
173 | | - " Class: EncodingScenario\n", |
| 183 | + " garak.encoding\u001b[0m\n", |
| 184 | + " Class: Encoding\n", |
174 | 185 | " Description:\n", |
175 | 186 | " Encoding Scenario implementation for PyRIT. This scenario tests how\n", |
176 | 187 | " resilient models are to various encoding attacks by encoding potentially\n", |
|
189 | 200 | " uuencode, rot13, braille, atbash, morse_code, nato, ecoji, zalgo,\n", |
190 | 201 | " leet_speak, ascii_smuggler\n", |
191 | 202 | " Default Strategy: all\n", |
192 | | - " Required Datasets (2):\n", |
| 203 | + " Default Datasets (2, max 3 per dataset):\n", |
193 | 204 | " garak_slur_terms_en, garak_web_html_js\n", |
194 | 205 | "\n", |
195 | 206 | "================================================================================\n", |
|
309 | 320 | "Or concretely:\n", |
310 | 321 | "\n", |
311 | 322 | "```shell\n", |
312 | | - "!pyrit_scan foundry_scenario --initializers simple openai_objective_target --scenario-strategies base64\n", |
| 323 | + "!pyrit_scan foundry --initializers simple openai_objective_target --scenario-strategies base64\n", |
313 | 324 | "```\n", |
314 | 325 | "\n", |
315 | 326 | "Example with a basic configuration that runs the Foundry scenario against the objective target defined in `openai_objective_target` (which just is an OpenAIChatTarget with `DEFAULT_OPENAI_FRONTEND_ENDPOINT` and `DEFAULT_OPENAI_FRONTEND_KEY`)." |
|
326 | 337 | "output_type": "stream", |
327 | 338 | "text": [ |
328 | 339 | "Starting PyRIT...\n", |
| 340 | + "Found default environment files: ['C:\\\\Users\\\\rlundeen\\\\.pyrit\\\\.env', 'C:\\\\Users\\\\rlundeen\\\\.pyrit\\\\.env.local']\n", |
| 341 | + "Loaded environment file: C:\\Users\\rlundeen\\.pyrit\\.env\n", |
| 342 | + "Loaded environment file: C:\\Users\\rlundeen\\.pyrit\\.env.local\n", |
329 | 343 | "Running 1 initializer(s)...\n", |
| 344 | + "Found default environment files: ['C:\\\\Users\\\\rlundeen\\\\.pyrit\\\\.env', 'C:\\\\Users\\\\rlundeen\\\\.pyrit\\\\.env.local']\n", |
| 345 | + "Loaded environment file: C:\\Users\\rlundeen\\.pyrit\\.env\n", |
| 346 | + "Loaded environment file: C:\\Users\\rlundeen\\.pyrit\\.env.local\n", |
330 | 347 | "\n", |
331 | | - "Running scenario: foundry_scenario\n", |
| 348 | + "Running scenario: foundry\n", |
332 | 349 | "\n", |
333 | | - "\u001b[36m====================================================================================================\u001b[0m\n", |
334 | | - "\n", |
335 | | - "Error: 'charmap' codec can't encode character '\\U0001f4ca' in position 41: character maps to <undefined>\n" |
336 | | - ] |
337 | | - }, |
338 | | - { |
339 | | - "name": "stderr", |
340 | | - "output_type": "stream", |
341 | | - "text": [ |
342 | | - "\n", |
343 | | - "Executing Foundry Scenario: 0%| | 0/2 [00:00<?, ?attack/s]\n", |
344 | | - "Executing Foundry Scenario: 50%|##### | 1/2 [00:39<00:39, 39.30s/attack]\n", |
345 | | - "Executing Foundry Scenario: 100%|##########| 2/2 [01:12<00:00, 35.76s/attack]\n", |
346 | | - "Executing Foundry Scenario: 100%|##########| 2/2 [01:12<00:00, 36.29s/attack]\n" |
| 350 | + "Error: SeedGroup at index 0 is missing an objective. Use seed_group.set_objective(value) to set one.\n" |
347 | 351 | ] |
348 | 352 | } |
349 | 353 | ], |
350 | 354 | "source": [ |
351 | | - "!pyrit_scan foundry_scenario --initializers openai_objective_target --strategies base64" |
| 355 | + "!pyrit_scan foundry --initializers openai_objective_target --strategies base64" |
352 | 356 | ] |
353 | 357 | }, |
354 | 358 | { |
|
359 | 363 | "Or with all options and multiple initializers and multiple strategies:\n", |
360 | 364 | "\n", |
361 | 365 | "```shell\n", |
362 | | - "pyrit_scan foundry_scenario --database InMemory --initializers simple objective_target objective_list --scenario-strategies easy crescendo\n", |
| 366 | + "pyrit_scan foundry --database InMemory --initializers simple objective_target objective_list --scenario-strategies easy crescendo\n", |
363 | 367 | "```\n", |
364 | 368 | "\n", |
365 | 369 | "You can also override scenario execution parameters:\n", |
366 | 370 | "\n", |
367 | 371 | "```shell\n", |
368 | 372 | "# Override concurrency and retry settings\n", |
369 | | - "pyrit_scan foundry_scenario --initializers simple objective_target --max-concurrency 10 --max-retries 3\n", |
| 373 | + "pyrit_scan foundry --initializers simple objective_target --max-concurrency 10 --max-retries 3\n", |
370 | 374 | "\n", |
371 | 375 | "# Add custom memory labels for tracking (must be valid JSON)\n", |
372 | | - "pyrit_scan foundry_scenario --initializers simple objective_target --memory-labels '{\"experiment\": \"test1\", \"version\": \"v2\", \"researcher\": \"alice\"}'\n", |
| 376 | + "pyrit_scan foundry --initializers simple objective_target --memory-labels '{\"experiment\": \"test1\", \"version\": \"v2\", \"researcher\": \"alice\"}'\n", |
373 | 377 | "```\n", |
374 | 378 | "\n", |
375 | 379 | "Available CLI parameter overrides:\n", |
|
401 | 405 | "metadata": { |
402 | 406 | "lines_to_next_cell": 2 |
403 | 407 | }, |
404 | | - "outputs": [], |
| 408 | + "outputs": [ |
| 409 | + { |
| 410 | + "name": "stdout", |
| 411 | + "output_type": "stream", |
| 412 | + "text": [ |
| 413 | + "Found default environment files: ['C:\\\\Users\\\\rlundeen\\\\.pyrit\\\\.env', 'C:\\\\Users\\\\rlundeen\\\\.pyrit\\\\.env.local']\n", |
| 414 | + "Loaded environment file: C:\\Users\\rlundeen\\.pyrit\\.env\n", |
| 415 | + "Loaded environment file: C:\\Users\\rlundeen\\.pyrit\\.env.local\n" |
| 416 | + ] |
| 417 | + }, |
| 418 | + { |
| 419 | + "data": { |
| 420 | + "text/plain": [ |
| 421 | + "<__main__.MyCustomScenario at 0x19e7c2a70e0>" |
| 422 | + ] |
| 423 | + }, |
| 424 | + "execution_count": null, |
| 425 | + "metadata": {}, |
| 426 | + "output_type": "execute_result" |
| 427 | + } |
| 428 | + ], |
405 | 429 | "source": [ |
406 | 430 | "# my_custom_scenarios.py\n", |
407 | | - "from pyrit.common.apply_defaults import apply_defaults\n", |
408 | | - "from pyrit.scenario import Scenario\n", |
| 431 | + "from pyrit.common import apply_defaults\n", |
| 432 | + "from pyrit.scenario import DatasetConfiguration, Scenario\n", |
409 | 433 | "from pyrit.scenario.core.scenario_strategy import ScenarioStrategy\n", |
| 434 | + "from pyrit.setup import initialize_pyrit_async\n", |
410 | 435 | "\n", |
411 | 436 | "\n", |
412 | 437 | "class MyCustomStrategy(ScenarioStrategy):\n", |
|
417 | 442 | " Strategy2 = (\"strategy2\", set[str]())\n", |
418 | 443 | "\n", |
419 | 444 | "\n", |
420 | | - "@apply_defaults\n", |
421 | 445 | "class MyCustomScenario(Scenario):\n", |
422 | 446 | " \"\"\"My custom scenario that does XYZ.\"\"\"\n", |
423 | 447 | "\n", |
|
429 | 453 | " def get_default_strategy(cls):\n", |
430 | 454 | " return MyCustomStrategy.ALL\n", |
431 | 455 | "\n", |
| 456 | + " @classmethod\n", |
| 457 | + " def default_dataset_config(cls) -> DatasetConfiguration:\n", |
| 458 | + " # Return default dataset configuration for this scenario\n", |
| 459 | + " return DatasetConfiguration(dataset_names=[\"harmbench\"])\n", |
| 460 | + "\n", |
| 461 | + " @apply_defaults\n", |
432 | 462 | " def __init__(self, *, scenario_result_id=None, **kwargs):\n", |
433 | 463 | " # Scenario-specific configuration only - no runtime parameters\n", |
434 | 464 | " super().__init__(\n", |
|
440 | 470 | " # ... your scenario-specific initialization code\n", |
441 | 471 | "\n", |
442 | 472 | " async def _get_atomic_attacks_async(self):\n", |
443 | | - " # Build and return your atomic attacks\n", |
444 | | - " return []" |
| 473 | + " # Build and return your atomic attacks based on self._scenario_composites\n", |
| 474 | + " # Example: create attacks for each strategy composite\n", |
| 475 | + " return []\n", |
| 476 | + "\n", |
| 477 | + "\n", |
| 478 | + "await initialize_pyrit_async(memory_db_type=\"InMemory\") # type: ignore\n", |
| 479 | + "MyCustomScenario()" |
445 | 480 | ] |
446 | 481 | }, |
447 | 482 | { |
|
474 | 509 | "name": "python", |
475 | 510 | "nbconvert_exporter": "python", |
476 | 511 | "pygments_lexer": "ipython3", |
477 | | - "version": "3.12.11" |
| 512 | + "version": "3.13.5" |
478 | 513 | } |
479 | 514 | }, |
480 | 515 | "nbformat": 4, |
|
0 commit comments