Implementation:0xSteph Pentest ai Scoring Common
| Knowledge Sources | |
|---|---|
| Domains | Benchmark, Scoring, Classification |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
Concrete tool for matching findings to ground-truth entries and computing catch rate and precision metrics, provided by the pentest-ai benchmark scoring module.
Description
The scoring.common module provides shared scoring primitives for benchmark runs. It defines GroundTruthEntry and Finding dataclasses, a three-branch matches function (URL host+path, attack pattern substring, or distinguishing keyword match), and a ScoredManifest with catch_rate, precision, and fp_rate properties. The classify function splits findings into true positives and false positives. Re-exports is_informational from the engine for consistent triage classification.
Usage
Import this module when you need to score benchmark findings against ground truth. Used by score_juiceshop.py and clean_fp_sweep.py.
Code Reference
Source Location
- Repository: 0xSteph_Pentest_ai
- File: benchmarks/scoring/common.py
- Lines: 1-152
Signature
@dataclass
class GroundTruthEntry:
id: str
url: str | None = None
attack_patterns: list[str] = field(default_factory=list)
category: str = ""
notes: str = ""
@dataclass
class Finding:
url: str = ""
payload: str = ""
severity: str = ""
finding_id: str = ""
title: str = ""
description: str = ""
category: str = ""
def matches(finding: Finding, gt: GroundTruthEntry) -> MatchKind | None: ...
def classify(findings: list[Finding], in_scope: list[GroundTruthEntry]) -> tuple[dict[str, MatchKind], list[Finding]]: ...
@dataclass
class ScoredManifest:
target: str
intensity: str
profile: str
in_scope: list[GroundTruthEntry]
catches: dict[str, MatchKind]
findings: list[Finding]
false_positives: list[Finding] = field(default_factory=list)
@property
def catch_rate(self) -> float: ...
@property
def precision(self) -> float: ...
@property
def fp_rate(self) -> float: ...
Import
from benchmarks.scoring.common import GroundTruthEntry, Finding, ScoredManifest, matches, classify
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| finding | Finding | Yes | A finding with url, payload, title, description |
| gt | GroundTruthEntry | Yes | A ground-truth entry with url, attack_patterns, notes |
Outputs
| Name | Type | Description |
|---|---|---|
| None | "url", "payload", "title" or None if no match | |
| catch_rate | float | Fraction of ground-truth entries caught |
| precision | float | True positives / all reported findings |
Usage Examples
Score Findings Against Ground Truth
from benchmarks.scoring.common import Finding, GroundTruthEntry, classify, ScoredManifest
gt_entries = [
GroundTruthEntry(id="sqli_login", url="http://localhost:3000/rest/user/login",
attack_patterns=["' OR 1=1--"], notes="SQL Injection Login"),
]
findings = [
Finding(url="http://localhost:3000/rest/user/login", title="SQL injection in login",
severity="critical", description="Boolean-based SQLi"),
]
catches, fps = classify(findings, gt_entries)
print(f"Catch rate: {len(catches)}/{len(gt_entries)}")
print(f"False positives: {len(fps)}")