Implementation:0xSteph Pentest ai CVSS Calculator
| Knowledge Sources | |
|---|---|
| Domains | CVSS, Scoring, Vulnerability_Assessment |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
Concrete tool for computing CVSS v3.1 base scores from vector strings or CWE IDs, provided by the pentest-ai engine.
Description
The cvss module implements a CVSS v3.1 base score calculator. It maps CWE IDs to default CVSS vectors via CWE_VECTORS, parses vector strings, and computes the base score using the standard CVSS math. Scanner-provided vectors take precedence over CWE-derived defaults. Includes severity-to-score fallbacks for findings without a vector.
Usage
Import this module when you need to compute or enrich CVSS scores for findings. Used by the findings database and report generator.
Code Reference
Source Location
- Repository: 0xSteph_Pentest_ai
- File: engine/cvss.py
- Lines: 1-106
Signature
CWE_VECTORS: dict[str, str] = ...
SEVERITY_FALLBACK: dict[str, float] = ...
def _parse_vector(vector: str) -> dict[str, str]: ...
def compute_base_score(vector: str) -> float: ...
def score_finding(finding: dict[str, Any]) -> float: ...
Import
from engine.cvss import compute_base_score, score_finding, CWE_VECTORS
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| vector | str | Yes (compute) | CVSS v3.1 vector string (e.g. "AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N") |
| finding | dict | Yes (score_finding) | Finding dict with cwe_id or cvss_vector |
Outputs
| Name | Type | Description |
|---|---|---|
| base score | float | CVSS v3.1 base score (0.0-10.0) |
Usage Examples
Compute from Vector
from engine.cvss import compute_base_score
score = compute_base_score("AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N")
print(f"CVSS: {score:.1f}") # 10.0
Score a Finding
from engine.cvss import score_finding
finding = {"cwe_id": "CWE-89", "severity": "critical"}
score = score_finding(finding)
print(f"CVSS: {score:.1f}") # Uses CWE-89 default vector