BUG: regex, package-hallucination and aggregator scorer identities collide across configs

Fermée
#3,113 2 commentaires 0 réactions 1 personne assignée Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

@u7k4rs6 y travaille déjà.

Depuis le 14/10/2026.

  • #3200 par @u7k4rs6 — fusionnée

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
35/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
python
Domaine
security

Piste de recherche

Start with RegexScorer._build_identifier and the _ConfigurableRegexScorerMixin scorers (XSS, SQLi, SSRF, MarkdownInjection), then compare with CredentialLeakScorer, which already hashes its patterns. Also check PackageHallucinationScorer and the FloatScaleScorerByCategory and FloatScaleScorerAllCategories aggregators, whose __name__ values collide. Reproduce the four collision cases in the issue before changing anything. Done means distinct identifiers for differently configured scorers, default-config hashes unchanged, and a maintainer decision on the metrics registry.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Some scorer identifiers leave out the config that decides the result, so differently configured scorers share a hash and eval_hash. That means get_scorer_metrics() and the evaluator's skip-if-exists can return another config's metrics, and stored scores can't be told apart.

RegexScorer._build_identifier only records pattern_count, so any two RegexScorers with the same number of patterns collide. The same goes for the _ConfigurableRegexScorerMixin scorers (XSS, SQLi, SSRF, MarkdownInjection and the rest) when they're given custom patterns. CredentialLeakScorer already hashes its patterns, so it's only the base that's missing it.

PackageHallucinationScorer only records known_package_count, so two scorers with different package sets of the same size look identical.

FloatScaleScorerByCategory.MAX and FloatScaleScorerAllCategories.MAX are both named MAX_by_category_, and the same is true for MIN and AVERAGE. Scorers record the aggregator's name, but the two behave differently: one returns a score per category and makes FloatScaleThresholdScorer raise, while the other returns a single score.

RegexScorer A vs B (1 pattern each, different patterns): same hash True, same eval_hash True; A -> false, B -> true
Markdown default vs custom patterns: same eval_hash True
PackageHallucination {requests} vs {evilpkg}: eval_hash equal True
aggregator names: MAX_by_category_ MAX_by_category_ -> same eval_hash True

A fix would add a digest of the patterns and the package set, only when they differ from the defaults so stored default hashes stay put, and give the all-categories aggregators their own names. Since that moves some hashes, I'm filing first to check how you want the metrics registry handled.

Langage dominant
Python
Étoiles
4.7k
Forks
1k
Merge moyen
2 j 2 h
PR mergées (30 j)
439

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

  • Aucun Dockerfile ni fichier Docker Compose
  • Propose un modèle de pull request
  • Aucun guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de microsoft/PyRIT

Toutes les issues de microsoft/PyRIT

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.