BUG: get_jailbreak_templates(num_templates=0) returns every template and the Jailbreak scenario accepts num_jailbreaks below 1
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 35/100
調査の方向性
Read TextJailBreak.get_jailbreak_templates and Jailbreak.set_params_from_args, then inspect the existing validation for num_jailbreak_attempts. Add or update focused tests for invalid num_templates values and num_jailbreaks below 1; done means both APIs reject these inputs with clear ValueErrors. Pull request #3418 is already open, so check its changes and discussion before starting.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
TextJailBreak.get_jailbreak_templates(num_templates=...) only samples when num_templates is truthy (if num_templates:), and nothing checks the value:
num_templates=0returns all templates (650 on main) instead of zero or an error. The docstring saysNoneis the way to get all of them.num_templates=-1fails insiderandom.samplewith the unrelatedSample larger than population or is negative.num_templates=Truereturns one template, and2.5fails withTypeError: can't multiply sequence by non-int of type 'float'.
The Jailbreak scenario passes its num_jailbreaks run parameter through as num_jailbreaks or _DEFAULT_NUM_JAILBREAKS, and set_params_from_args checks only num_jailbreak_attempts. So num_jailbreaks=0 (for example --num-jailbreaks 0 on the CLI) silently runs the default random sample of 2 templates, and num_jailbreaks=-1 is accepted and only fails later in initialize_async with the random.sample message.
Steps/Code to Reproduce
from pyrit.datasets import TextJailBreak
print(len(TextJailBreak.get_jailbreak_templates()))
print(len(TextJailBreak.get_jailbreak_templates(num_templates=0)))
print(len(TextJailBreak.get_jailbreak_templates(num_templates=True)))
TextJailBreak.get_jailbreak_templates(num_templates=-1)
import asyncio
from unittest.mock import MagicMock
from pyrit.scenario.scenarios.airt.jailbreak import Jailbreak
from pyrit.score import TrueFalseScorer
from pyrit.setup import IN_MEMORY, initialize_pyrit_async
asyncio.run(initialize_pyrit_async(memory_db_type=IN_MEMORY))
scenario = Jailbreak(objective_scorer=MagicMock(spec=TrueFalseScorer))
scenario.set_params_from_args(args={"num_jailbreaks": 0}) # accepted; the run uses 2 random templates
scenario.set_params_from_args(args={"num_jailbreaks": -1}) # accepted; fails later in initialize_async
Expected Results
get_jailbreak_templates raises a ValueError naming num_templates for anything other than None or an integer of at least 1, and the Jailbreak scenario rejects num_jailbreaks below 1 in set_params_from_args, the same way it already rejects num_jailbreak_attempts below 1.
Actual Results
650
650
1
ValueError: Sample larger than population or is negative
Both set_params_from_args calls return without error.
Screenshots
N/A
Versions
- OS: Windows 11
- Python version: 3.11.9
- PyRIT version: installed from main (4cb71734) in editable mode
- 主要言語
- Python
- スター
- 4.6k
- フォーク
- 962
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 423
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/PyRIT のほかの issue
-
BUG: AzureBlobStorageTarget returns a URL with // when the container URL ends with a slash対応中かも @ShivamSharma43 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
-
BUG: OpenAIImageTarget uploads edited images under a generated local path instead of their file name対応中かも @ShivamSharma43 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 2 日以内に返信
-
BUG: PathTraversalOutputScorer misses canonical Windows target windows/win.ini and IIS web.config対応中かも @Kaap10 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
-
BUG: XXEOutputScorer misses direct external DTD references and Java netdoc: / gopher: URI schemes対応中かも @Kaap10 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
BUG: StaticPromptInjectionScorer misses modern LLM chat template tokens (Meta Llama 3+, Google Gemma, Microsoft Phi-3/4)対応中かも @Kaap10 が今日担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 2 日以内に返信
microsoft/PyRIT の issue をすべて見る
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
WLAN-Pi/wlanpi-profiler#341 ·
メンテナーはふだん 1 日以内に返信
-
Memory leak: the shared `validation_aborted_error` keeps every traceback it is raised through対応中かも @Fire162 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
graphql-python/graphql-core#287 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
roman-corgi/ctc-dip#160 ·
メンテナーはふだん 1 日以内に返信
-
type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
render_findings.py reads and writes in the host's default encoding, so findings.html breaks on a cp1252 Windows host対応中かも @Aaqibhafeezkhan が今日担当しました。 オープンbug good first issue mentored python size: XS up-for-grabs
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
dheerajjha/mcp-migrate#366 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信