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

BUG: PackageHallucinationScorer flags Rust std paths, type names and hyphenated crates as hallucinated

Aperta
#3,438 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@nniiovoo ci sta già lavorando.

Dal 21/10/2026.

  • #3439 di @nniiovoo — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python, rust
Ambito
security, testing

Direzione di ricerca

Start by locating PackageHallucinationScorer and the Rust ecosystem handling described in the issue; compare its known package entries with garak's rust_std_entries. Reproduce the provided example, then check that standard paths and type names are ignored, hyphenated registry names match Rust underscores, and ghost_db remains flagged. A linked pull request (#3439) is already open.

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

Descrizione

Describe the bug

For Rust, the scorer counts every name:: in the answer as a crate. So std modules (collections from std::collections, thread from thread::spawn), type names (HashMap::new, String::from) and crate:: / super:: are all reported as hallucinated packages. Crates that have a - in the registry, like actix-web, never match either, because Rust code can only write them as actix_web.

Rust is the default language of the PackageHallucination scenario, so ordinary Rust answers are often scored True. With the crates.io list the scenario loads (crates-20250307), 347 of 368 examples/*.rs files from 100 published crates score True, although they only use real crates.

garak also adds its rust_std_entries list to the known set. The PyRIT port only adds alloc, core, proc_macro, std and test.

Steps/Code to Reproduce
import asyncio

from pyrit.models import Message
from pyrit.score import PackageEcosystem, PackageHallucinationScorer
from pyrit.setup import IN_MEMORY, initialize_pyrit_async

answer = """use std::collections::HashMap;
use std::thread;
use actix_web::{web, App, HttpServer};

fn main() {
    let mut counts = HashMap::new();
    counts.insert(String::from("a"), 1);
    thread::spawn(|| println!("done")).join().unwrap();
}
"""


async def main():
    await initialize_pyrit_async(memory_db_type=IN_MEMORY)
    # the crates.io registry lists the crate as "actix-web"
    scorer = PackageHallucinationScorer(known_packages={"actix-web"}, ecosystem=PackageEcosystem.RUST)
    message = Message.from_prompt(prompt=answer, role="assistant")
    message.set_response_not_in_memory()
    score = (await scorer.score_message_async(message=message))[0]
    print(score.get_value(), score.score_metadata["hallucinated_packages"])


asyncio.run(main())
Expected Results
False
Actual Results
True HashMap, String, actix_web, collections, thread
Versions
  • OS: macOS 26.4.1 (arm64)
  • Python 3.13.16
  • PyRIT 1.2.0.dev0, editable install at f44327ab; scorer identical to current main (ac196e57)

The fix is to count only the root of a path, skip bare UpperCamelCase roots (types), add garak's std entries, and match registry names with - as _. A made-up crate like use ghost_db::Client; is still flagged.

Lingua principale
Python
Stelle
4.6k
Fork
962
Merge medio
2g 15h
PR unite (30g)
398

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.