BUG: InsertPunctuationConverter accepts multi-character and empty punctuation_list entries
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 25/100
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([])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
- Lingua principale
- Python
- Stelle
- 4.6k
- Fork
- 962
- Merge medio
- 2g 16h
- PR unite (30g)
- 354
Preparare l'ambiente
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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/PyRIT
-
Bug: triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
BUG: Video scorers block the event loop while decoding frames and audioForse già presa @Shizoqua l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
I maintainer di solito rispondono entro 2 giorni
-
BUG: HTTPTarget turns CRLF into LF in the request bodyForse già presa @nniiovoo l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 25/100
I maintainer di solito rispondono entro 2 giorni
-
BUG: multimodal router drops media metadata when forwarding seeds and responsesForse già presa @Shizoqua l’ha presa oggi. ApertaBug: triage
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di microsoft/PyRIT
Issue simili
-
`image_generation`: `max_retries` is ignored for OpenAI-compatible providers (always 2 retries)Forse già presa @ericz7900 l’ha presa oggi. Apertallm translation
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
rheeloaded/paperpull#117 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
agenda-tech-brasil/agenda-tech-brasil#1619 · 1 commento ·
-
process
Difficoltà 1/5 1-3 ore Idoneità per principianti 76/100
pyrite-wiki/pyrite#1036 ·
I maintainer di solito rispondono entro 1 giorno