Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

BUG: InsertPunctuationConverter accepts multi-character and empty punctuation_list entries

クローズ
#3,292 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@ShivamSharma43 がすでに取り組んでいます。

2026年10月18日 から。

  • #3294 @ShivamSharma43 による — マージ済み

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
tooling

調査の方向性

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([]) is True. The converter then fails later with IndexError: Cannot choose from an empty sequence instead of the documented ValueError.

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

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/PyRIT のほかの issue

microsoft/PyRIT の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。