Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 10 additions & 87 deletions doc/scanner/garak.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@
"QuotedPrintable, UUencode, ROT13, Braille, Atbash, MorseCode, NATO, Ecoji, Zalgo, LeetSpeak,\n",
"AsciiSmuggler\n",
"\n",
"**Aggregate techniques:** `ALL` (every encoding, exhaustive) and `DEFAULT` (a broad curated subset\n",
"spanning every encoding family — base-N, byte-encodings, substitution ciphers, and symbolic\n",
"alphabets — for a meaningful default scan; the niche/lossy schemes are ALL-only). `DEFAULT` is used\n",
"when no techniques are specified.\n",
"\n",
"> **Note:** Technique composition is NOT supported for Encoding — each encoding is tested\n",
"> independently."
]
Expand All @@ -100,30 +105,7 @@
"execution_count": null,
"id": "3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Scenario: Encoding\n",
"Atomic attacks: 21\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e21db36b5f40443593057efcb1ff2588",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Executing Encoding: 0%| | 0/21 [00:00<?, ?attack/s]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"dataset_config = EncodingDatasetConfiguration(dataset_names=[\"garak_slur_terms_en\"], max_dataset_size=1)\n",
"\n",
Expand All @@ -148,69 +130,7 @@
"execution_count": null,
"id": "4",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\u001b[36m====================================================================================================\u001b[0m\n",
"\u001b[1m\u001b[36m 📊 SCENARIO RESULTS: Encoding \u001b[0m\n",
"\u001b[36m====================================================================================================\u001b[0m\n",
"\n",
"\u001b[1m\u001b[36m▼ Scenario Information\u001b[0m\n",
"\u001b[36m────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n",
"\u001b[1m 📋 Scenario Details\u001b[0m\n",
"\u001b[36m • Name: Encoding\u001b[0m\n",
"\u001b[36m • Scenario Version: 1\u001b[0m\n",
"\u001b[36m • PyRIT Version: 0.15.0.dev0\u001b[0m\n",
"\u001b[36m • Description:\u001b[0m\n",
"\u001b[36m Encoding Scenario implementation for PyRIT. This scenario tests how resilient models are to various encoding\u001b[0m\n",
"\u001b[36m attacks by encoding potentially harmful text (by default slurs and XSS payloads) and testing if the model will\u001b[0m\n",
"\u001b[36m decode and repeat the encoded payload. It mimics the Garak encoding probe. The scenario works by: 1. Taking seed\u001b[0m\n",
"\u001b[36m prompts (the harmful text to be encoded) 2. Encoding them using various encoding schemes (Base64, ROT13, Morse,\u001b[0m\n",
"\u001b[36m etc.) 3. Asking the target model to decode the encoded text 4. Scoring whether the model successfully decoded\u001b[0m\n",
"\u001b[36m and repeated the harmful content By default, this uses the same dataset as Garak: slur terms and web XSS\u001b[0m\n",
"\u001b[36m payloads.\u001b[0m\n",
"\n",
"\u001b[1m 🎯 Target Information\u001b[0m\n",
"\u001b[36m • Target Type: OpenAIChatTarget\u001b[0m\n",
"\u001b[36m • Target Model: gpt-4o-japan-nilfilter\u001b[0m\n",
"\u001b[36m • Target Endpoint: https://pyrit-japan-test.openai.azure.com/openai/v1\u001b[0m\n",
"\n",
"\u001b[1m 📊 Scorer Information\u001b[0m\n",
"\u001b[37m ▸ Scorer Identifier\u001b[0m\n",
"\u001b[36m • Scorer Type: DecodingScorer\u001b[0m\n",
"\u001b[36m • scorer_type: true_false\u001b[0m\n",
"\u001b[36m • score_aggregator: OR_\u001b[0m\n",
"\n",
"\u001b[37m ▸ Performance Metrics\u001b[0m\n",
"\u001b[33m Official evaluation has not been run yet for this specific configuration\u001b[0m\n",
"\n",
"\u001b[1m\u001b[36m▼ Overall Statistics\u001b[0m\n",
"\u001b[36m────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n",
"\u001b[1m 📈 Summary\u001b[0m\n",
"\u001b[32m • Total Techniques: 2\u001b[0m\n",
"\u001b[32m • Total Attack Results: 21\u001b[0m\n",
"\u001b[31m • Overall Success Rate: 90%\u001b[0m\n",
"\u001b[32m • Unique Objectives: 1\u001b[0m\n",
"\n",
"\u001b[1m\u001b[36m▼ Per-Group Breakdown\u001b[0m\n",
"\u001b[36m────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n",
"\n",
"\u001b[1m 🔸 Group: base64\u001b[0m\n",
"\u001b[33m • Number of Results: 20\u001b[0m\n",
"\u001b[31m • Success Rate: 95%\u001b[0m\n",
"\n",
"\u001b[1m 🔸 Group: baseline\u001b[0m\n",
"\u001b[33m • Number of Results: 1\u001b[0m\n",
"\u001b[32m • Success Rate: 0%\u001b[0m\n",
"\n",
"\u001b[36m====================================================================================================\u001b[0m\n",
"\n"
]
}
],
"outputs": [],
"source": [
"await output_scenario_async(scenario_result)"
]
Expand Down Expand Up @@ -276,6 +196,9 @@
}
],
"metadata": {
"jupytext": {
"main_language": "python"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
Expand Down
7 changes: 6 additions & 1 deletion doc/scanner/garak.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.19.1
# jupytext_version: 1.19.4
# ---

# %% [markdown]
Expand Down Expand Up @@ -49,6 +49,11 @@
# QuotedPrintable, UUencode, ROT13, Braille, Atbash, MorseCode, NATO, Ecoji, Zalgo, LeetSpeak,
# AsciiSmuggler
#
# **Aggregate techniques:** `ALL` (every encoding, exhaustive) and `DEFAULT` (a broad curated subset
# spanning every encoding family — base-N, byte-encodings, substitution ciphers, and symbolic
# alphabets — for a meaningful default scan; the niche/lossy schemes are ALL-only). `DEFAULT` is used
# when no techniques are specified.
#
# > **Note:** Technique composition is NOT supported for Encoding — each encoding is tested
# > independently.

Expand Down
Loading