BUG: InsertPunctuationConverter accepts multi-character and empty punctuation_list entries
メンテナーはふだん 2 日以内に返信
評価
調査の方向性
Start by reading InsertPunctuationConverter.convert_async and _is_valid_punctuation, which the issue identifies as the relevant entry points. Check the existing converter tests and verify that multi-character entries, empty strings, and an empty list all produce the documented ValueError.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
InsertPunctuationConverter.convert_async documents punctuation_list as single characters from string.punctuation and raises ValueError for invalid entries ("Only single characters from ... are allowed"). But _is_valid_punctuation checks each entry with char in string.punctuation, which is a substring test, so it accepts:
- multi-character runs that happen to be contiguous in
string.punctuation, such as"()","<=>","{|}"or"./". These are inserted as-is, so a "double punctuation" that the docstring calls invalid ends up in the prompt. - the empty string, which inserts nothing while the converter reports its insertions as done.
- an empty list, since
all([])isTrue. The converter then fails later withIndexError: Cannot choose from an empty sequenceinstead of the documentedValueError.
Multi-character entries that are not contiguous, such as "!?" or "~~", are already rejected, so the result depends on the order of characters in string.punctuation.
Steps/Code to Reproduce
import asyncio
from pyrit.converter import InsertPunctuationConverter
async def main():
converter = InsertPunctuationConverter(word_swap_ratio=1, seed=1)
for punctuation_list in (["<=>"], ["()"], [""], []):
try:
result = await converter.convert_async(prompt="hello big world", punctuation_list=punctuation_list)
print(punctuation_list, repr(result.output_text))
except Exception as e:
print(punctuation_list, f"{type(e).__name__}: {e}")
asyncio.run(main())
Expected Results
Each call raises ValueError: Invalid punctuations: ....
Actual Results
['<=>'] '<=>hello <=>big world<=>'
['()'] '()hello ()big world()'
[''] 'hello big world'
[] IndexError: Cannot choose from an empty sequence
Screenshots
N/A
Versions
- OS: Windows 11
- Python version: 3.11.9
- PyRIT version: installed from main (5b594e00) in editable mode
- 主要言語
- Python
- スター
- 4.6k
- フォーク
- 962
- 平均マージ
- 2日 16時間
- マージ済み PR(30日)
- 354
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/PyRIT のほかの issue
-
BUG: label queries only return the final conversation of an attack対応中かも @u7k4rs6 が 5 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
microsoft/PyRIT#3095 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
microsoft/PyRIT#3325 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 53/100
メンテナーはふだん 2 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 46/100
メンテナーはふだん 2 日以内に返信
-
BUG: Tone, Tense, Translation, Noise, ScientificTranslation and Variation converter identifiers ignore a custom prompt_template対応中かも @ShivamSharma43 が今日担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 20/100
メンテナーはふだん 2 日以内に返信
microsoft/PyRIT の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
google-ai-edge/litert-torch#1346 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
geneontology/gocam-py#272 ·
-
pushed_authorization_request sends list authorization_details as a Python repr対応中かも @RaphaelFakhri が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
auth0/auth0-python#903 ·
メンテナーはふだん 1 日以内に返信