Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

BUG: InsertPunctuationConverter accepts multi-character and empty punctuation_list entries

Chiusa
#3,292 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@ShivamSharma43 ci sta già lavorando.

Dal 18/10/2026.

  • #3294 di @ShivamSharma43 — integrata

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
tooling

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
Python
Stelle
4.6k
Fork
962
Merge medio
2g 16h
PR unite (30g)
354

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/PyRIT

Tutte le issue di microsoft/PyRIT

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.