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

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

オープン
#3,438 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

2026年10月21日 から。

  • #3439 @nniiovoo による — オープン

評価

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

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
4.6k
フォーク
962
平均マージ
2日 15時間
マージ済み PR(30日)
398

環境構築

Codespaces で開く

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

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

はじめの一歩

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

microsoft/PyRIT のほかの issue

microsoft/PyRIT の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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