BUG: get_jailbreak_templates(num_templates=0) returns every template and the Jailbreak scenario accepts num_jailbreaks below 1
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 4.7k
- Fork
- 980
- Merge trung bình
- 2 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 418
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/PyRIT
-
BUG: AzureBlobStorageTarget returns a URL with // when the container URL ends with a slashCó thể đã có người làm @ShivamSharma43 đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 2 ngày
-
BUG: XXEOutputScorer misses direct external DTD references and Java netdoc: / gopher: URI schemesCó thể đã có người làm @Kaap10 đã nhận 3 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
BUG: MarkdownInjectionScorer misses shortcut-reference images with path-based exfiltration, and raw HTML <img>Có thể đã có người làm @aatif101 đã nhận 6 ngày trước. Đang mởBug: triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
microsoft/PyRIT#3343 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
BUG BrailleConverter output is ambiguous: "1a" encodes the same as "11", and "$" uses the period cellCó thể đã có người làm @barkha1research-ai đã nhận hôm nay. Đang mởBug: triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 2 ngày
-
BUG: Inferred objective is empty when tool calls come between the request and the answerCó thể đã có người làm @Shizoqua đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của microsoft/PyRIT
Issue tương tự
-
link-rot
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 67/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
developmentseed/titiler-cmr#265 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Insecure Brotli version <1.2.1Có thể đã có người làm @jamescw19 đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
stac-utils/stac-fastapi-pgstac#438 · 1 reaction ·
-
bug triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày