Metadata-Version: 2.4
Name: cvss-estimator
Version: 0.1.0
Summary: Compute CVSS v3.1 base scores and estimate a full vector from source-to-sink evidence flags — with no runtime dependencies.
Project-URL: Homepage, https://github.com/krc7169/cvss-estimator
Project-URL: Issues, https://github.com/krc7169/cvss-estimator/issues
Author-email: krc7169 <krc7169@gmail.com>
License: MIT License
        
        Copyright (c) 2026 krc7169
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: cvss,cvss3.1,cwe,scoring,security,severity,vulnerability
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Description-Content-Type: text/markdown

# cvss-estimator

Two things in one small, **dependency-free** package:

1. **A correct CVSS v3.1 base-score calculator** — build, parse, and score
   vectors per the official specification arithmetic.
2. **An evidence-driven estimator** — turn source-to-sink evidence flags (is the
   attacker path complete? is there a sanitizer? a public entrypoint?) plus a
   CWE/summary into a plausible, explainable CVSS vector and score. Useful for
   generating a stable machine baseline before a human refines it.

## Install

```bash
pip install cvss-estimator
```

## Scoring an existing vector

```python
from cvss_estimator import cvss_base_score, parse_vector, severity

metrics = parse_vector("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H")
score = cvss_base_score(metrics)   # 9.8
print(severity(score))             # "Critical"
```

```bash
cvss-estimator score "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
```

## Estimating a vector from evidence

```python
from cvss_estimator import estimate

result = estimate(
    cwe="CWE-502",  # unsafe deserialization -> RCE category
    evidence={
        "attacker_path_complete": True,   # full source-to-sink -> AC:L, AV:N
        "entrypoint_found": True,
        "sanitizer_or_allowlist_present": False,
    },
)
print(result["vector"])    # CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
print(result["score"])     # 9.8
print(result["severity"])  # Critical
```

```bash
cvss-estimator estimate --cwe CWE-502 --complete-path --entrypoint http_route
```

### Evidence flags

| Flag | Effect |
| --- | --- |
| `attacker_path_complete` | `AC:L` (and `AV:N` for RCE) |
| `entrypoint` / `entrypoint_found` | network attack vector for RCE |
| `auth_guard_present` | `PR:L` |
| `consumer_opt_in_required` | `UI:R` |
| `sanitizer_or_allowlist_present` | downgrades C/I/A, raises `AC:H` |
| `safe_containment_present` | downgrades C/I/A, raises `AC:H` |

Categories are inferred from CWE/summary via `impact_profile()`:
`remote_code_execution`, `sql_injection`, `ssrf`, `xxe`, `path_traversal`,
`secret_exposure`, `denial_of_service`, `security_weakness`.

## Notes

- No runtime dependencies.
- The estimator is a **heuristic baseline**, not an authoritative score — always
  have a human confirm the vector before publishing a CVE.

## License

MIT
