BUG: KeywordSelectionStrategy accepts a negative context, so SelectiveTextConverter duplicates or truncates the prompt
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
Start in pyrit/converter/text_selection_strategy.py and compare KeywordSelectionStrategy with the other selection strategies that validate their bounds. Check the negative context and empty keyword cases from the issue’s reproducer, then verify they raise ValueError without changing valid selections.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
KeywordSelectionStrategy in pyrit/converter/text_selection_strategy.py stores keyword, context_before and context_after without checking them, while the other character-level strategies (PositionSelectionStrategy, ProportionSelectionStrategy, RangeSelectionStrategy) and the word-level ones validate their bounds.
select_range then computes start = max(0, index - context_before) and end = min(len(text), index + len(keyword) + context_after), so a negative context produces a range that does not cover the keyword, or one whose end is before its start. SelectiveTextConverter uses that range as prompt[:start] + convert(prompt[start:end]) + prompt[end:], which:
- with
context_after=-10on"the secret plan"returns the range(4, 0), and the converter sends"the the secret plan": the text betweenendandstartis duplicated and nothing is converted. - with
context_before=-3returns(7, 10), so only"ret"is converted and the rest of the keyword is sent in plaintext ("the seccmV0 plan"withBase64Converter).
An empty keyword is also accepted; it matches at index 0, so the strategy selects the first context_after characters of every prompt instead of a keyword.
Steps/Code to Reproduce
import asyncio
from pyrit.converter import Base64Converter, SelectiveTextConverter
from pyrit.converter.text_selection_strategy import KeywordSelectionStrategy
prompt = "the secret plan"
for strategy in (
KeywordSelectionStrategy(keyword="secret", context_after=-10),
KeywordSelectionStrategy(keyword="secret", context_before=-3),
):
converter = SelectiveTextConverter(sub_converter=Base64Converter(), selection_strategy=strategy)
print(strategy.select_range(text=prompt), repr(asyncio.run(converter.convert_async(prompt=prompt)).output_text))
Expected Results
KeywordSelectionStrategy raises a ValueError for a negative or non-integer context_before/context_after and for an empty keyword, like the other selection strategies do for out-of-range values.
Actual Results
(4, 0) 'the the secret plan'
(7, 10) 'the seccmV0 plan'
Screenshots
N/A
Versions
- OS: Windows 11
- Python version: 3.11.9
- PyRIT version: installed from main (898b3bdc) in editable mode
- Ngôn ngữ chính
- Python
- Star
- 4.6k
- Fork
- 962
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 417
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: Overlapping scorer-evaluation globs duplicate CSVs and change accuracyCó thể đã có người làm @its-amann đã 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 78/100
microsoft/PyRIT#3430 · 1 bình luận ·
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 2 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
-
Detect Azure SAS tokens, SharedAccessKey connection strings, and Databricks PATs in CredentialLeakScorerCó thể đã có người làm @nithin42 đã nhận hôm nay. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 2 ngày
-
BUG: OpenAITTSTarget accepts any speed, so an out-of-range value is only sent to the API on every requestCó thể đã có người làm @ShivamSharma43 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
microsoft/PyRIT#3445 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
BUG: LetterBijectionConverter accepts a negative fixed_size and then leaves the prompt unchangedCó thể đã có người làm @ShivamSharma43 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
microsoft/PyRIT#3434 · 1 người được giao ·
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ự
-
[Resource]: glyphcss-diagramsĐang mởresource-submission validation-passed
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
hesreallyhim/awesome-claude-code#3214 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
room-commons replace accepts an empty old string and silently prepends the new text to the pageĐ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 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
doobidoo/mcp-memory-service#1650 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ml-explore/mlx-lm#2002 ·
Maintainer thường phản hồi trong vòng 2 ngày