Metadata filters crash on keys containing dots or other special characters
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 25/100
Direzione di ricerca
The bug is in the metadata condition builders in pyrit/memory/sqlite_memory.py and pyrit/memory/azure_sql_memory.py, specifically _get_seed_metadata_conditions and _get_message_pieces_prompt_metadata_conditions, where the key is interpolated into the JSON path and the bind name. Read the label fix from #3063 for the pattern. PR #3180 is already open against this, so check it before starting. Done means a dotted key like a.b filters correctly in both backends.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
Filtering seeds or message pieces by a prompt_metadata key that contains a dot (or any character outside a plain SQL bind name, like a hyphen or a space) crashes the query instead of filtering.
In sqlite_memory.py and azure_sql_memory.py, _get_seed_metadata_conditions and _get_message_pieces_prompt_metadata_conditions build the SQL with the key interpolated into both the JSON path and the bind parameter name:
f"JSON_EXTRACT(prompt_metadata, '$.{key}') = :{key}"
For a key like a.b, SQLAlchemy parses :a.b as a parameter named a followed by literal text, so the later bindparams() call raises ArgumentError: This text() construct doesn't define a bound parameter named 'a.b'.
This is the same class of problem #3063 fixed for memory labels, where the accepted fix quotes the JSON path and uses indexed parameter names.
Steps/Code to Reproduce
import asyncio, tempfile
from pyrit.memory.sqlite_memory import SQLiteMemory
from pyrit.models import SeedPrompt
async def main():
memory = SQLiteMemory(db_path=tempfile.mktemp(suffix=".db"), verbose=False)
await memory.add_seeds_to_memory_async(seeds=[
SeedPrompt(value="dotted", data_type="text", dataset_name="t", metadata={"a.b": "v1"}),
], added_by="repro")
got = await memory.get_seeds_async(metadata={"a.b": "v1"}) # raises ArgumentError
print(got)
asyncio.run(main())
Expected Results
The filter matches the stored seed by the literal metadata key a.b and returns it.
Actual Results
sqlalchemy.exc.ArgumentError: This text() construct doesn't define a bound parameter named 'a.b'
Screenshots
N/A
Versions
OS: macOS
Python version: 3.14
PyRIT version: installed from main (66c41fa)
- Lingua principale
- Python
- Stelle
- 4.6k
- Fork
- 944
- Merge medio
- 2g 16h
- PR unite (30g)
- 350
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: SQLInjectionOutputScorer misses standard inline comment bypasses ('-- and ' OR 1=1--)Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
microsoft/PyRIT#3204 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
BUG: label queries only return the final conversation of an attackForse già presa @u7k4rs6 l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
microsoft/PyRIT#3095 · 4 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
BUG Configuration keeps runtime-status errors after polling recoversForse già presa @joeyvictorino l’ha presa 5 giorni fa. ApertaBug: triage GUI help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
microsoft/PyRIT#2868 · 4 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
BUG: HTTPTarget sends conflicting Content-Length and Transfer-Encoding headersForse già presa @Kaap10 l’ha presa 9 giorni fa. ApertaBug: triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
microsoft/PyRIT#3202 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Python 3.11 adoption opportunities: claim one improvement at a timeForse già presa @shivampwm2020 l’ha presa oggi. Apertahelp wanted
microsoft/PyRIT#3166 · 18 commenti · 2 assegnatari ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di microsoft/PyRIT
Issue simili
-
Workflow.schedule stops when a cron deadline passes before sleepForse già presa @HuaTNA l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug] HiveDialect shares its colspecs dict with SQLAlchemy's DefaultDialect (python/pyhive)Forse già presa @rusackas l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
apache/kyuubi#7786 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno
-
[20.0] hr_work_entry: Duration column of Export Time Entries is truncated to whole hoursForse già presa @odooaktiv l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
fix formatting of the sample database page of the docsForse già presa @Aaqibhafeezkhan l’ha presa oggi. Apertadocumentation good first issue help wanted
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
chaoss/CollectOSS#544 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno