|
| 1 | +# Patchrank |
| 2 | + |
| 3 | +Patchrank is a small security CLI that turns vulnerability scanner output into a |
| 4 | +patch priority report. It accepts Trivy JSON, Grype JSON, generic CVE JSON, or a |
| 5 | +plain text list of CVEs, then ranks findings with CVSS, severity, CISA KEV, |
| 6 | +FIRST EPSS, fix availability, internet exposure, and asset criticality signals. |
| 7 | + |
| 8 | +It is built for security teams and maintainers who need a practical answer to: |
| 9 | + |
| 10 | +> What should we patch first? |
| 11 | +
|
| 12 | +## Features |
| 13 | + |
| 14 | +- Parse Trivy JSON, Grype JSON, generic JSON, and plain CVE lists. |
| 15 | +- Load CISA Known Exploited Vulnerabilities data from a local JSON file. |
| 16 | +- Load FIRST EPSS data from a local JSON/CSV-style export. |
| 17 | +- Optionally fetch current CISA KEV and FIRST EPSS data. |
| 18 | +- Score findings with explainable reason strings. |
| 19 | +- Output table, Markdown, or JSON. |
| 20 | +- Run with only the Python standard library. |
| 21 | + |
| 22 | +## Install |
| 23 | + |
| 24 | +From a clone: |
| 25 | + |
| 26 | +```bash |
| 27 | +python -m pip install . |
| 28 | +``` |
| 29 | + |
| 30 | +For development without installing: |
| 31 | + |
| 32 | +```bash |
| 33 | +python -m patchrank --help |
| 34 | +``` |
| 35 | + |
| 36 | +When running directly from the repository, set `PYTHONPATH=src` if your shell |
| 37 | +does not automatically see the package: |
| 38 | + |
| 39 | +```bash |
| 40 | +PYTHONPATH=src python -m patchrank --help |
| 41 | +``` |
| 42 | + |
| 43 | +PowerShell: |
| 44 | + |
| 45 | +```powershell |
| 46 | +$env:PYTHONPATH = "src" |
| 47 | +python -m patchrank --help |
| 48 | +``` |
| 49 | + |
| 50 | +## Quick Start |
| 51 | + |
| 52 | +Rank a Trivy report with local KEV and EPSS fixtures: |
| 53 | + |
| 54 | +```bash |
| 55 | +patchrank rank examples/trivy.json --kev examples/kev.json --epss examples/epss.json --format markdown |
| 56 | +``` |
| 57 | + |
| 58 | +Rank a plain CVE list and mark the asset as internet-facing: |
| 59 | + |
| 60 | +```bash |
| 61 | +patchrank rank examples/cves.txt --internet-facing --asset-criticality 8 |
| 62 | +``` |
| 63 | + |
| 64 | +Fetch live KEV and EPSS data: |
| 65 | + |
| 66 | +```bash |
| 67 | +patchrank rank examples/cves.txt --fetch-kev --fetch-epss --format json |
| 68 | +``` |
| 69 | + |
| 70 | +## Scoring Model |
| 71 | + |
| 72 | +Patchrank uses a transparent additive score capped at 100: |
| 73 | + |
| 74 | +- CISA KEV match: high weight because exploitation is known. |
| 75 | +- EPSS probability: higher probability raises priority. |
| 76 | +- CVSS/severity: impact and vendor severity still matter. |
| 77 | +- Fix availability: patched packages are easier to act on. |
| 78 | +- Internet-facing asset: exposure raises priority. |
| 79 | +- Asset criticality: user-supplied business context. |
| 80 | + |
| 81 | +Priority bands: |
| 82 | + |
| 83 | +| Score | Priority | |
| 84 | +|---:|---| |
| 85 | +| 80-100 | patch-now | |
| 86 | +| 60-79 | urgent | |
| 87 | +| 40-59 | soon | |
| 88 | +| 0-39 | monitor | |
| 89 | + |
| 90 | +This is an operational heuristic, not a replacement for human risk analysis. |
| 91 | + |
| 92 | +## Supported Inputs |
| 93 | + |
| 94 | +### Trivy |
| 95 | + |
| 96 | +```bash |
| 97 | +trivy image --format json --output trivy.json nginx:latest |
| 98 | +patchrank rank trivy.json |
| 99 | +``` |
| 100 | + |
| 101 | +### Grype |
| 102 | + |
| 103 | +```bash |
| 104 | +grype dir:. -o json > grype.json |
| 105 | +patchrank rank grype.json |
| 106 | +``` |
| 107 | + |
| 108 | +### Plain Text |
| 109 | + |
| 110 | +Any line containing a CVE ID is accepted: |
| 111 | + |
| 112 | +```text |
| 113 | +CVE-2024-3094 |
| 114 | +CVE-2023-34362 |
| 115 | +``` |
| 116 | + |
| 117 | +## Data Sources |
| 118 | + |
| 119 | +- CISA Known Exploited Vulnerabilities catalog: |
| 120 | + https://www.cisa.gov/known-exploited-vulnerabilities-catalog |
| 121 | +- FIRST EPSS API: |
| 122 | + https://www.first.org/epss/api |
| 123 | + |
| 124 | +Patchrank can run fully offline when you provide local KEV and EPSS files. |
| 125 | + |
| 126 | +## Development |
| 127 | + |
| 128 | +Run tests: |
| 129 | + |
| 130 | +```bash |
| 131 | +python -m unittest discover -s tests |
| 132 | +``` |
| 133 | + |
| 134 | +Run a smoke check from a clone: |
| 135 | + |
| 136 | +```bash |
| 137 | +PYTHONPATH=src python -m patchrank rank examples/trivy.json --kev examples/kev.json --epss examples/epss.json --format markdown |
| 138 | +``` |
| 139 | + |
| 140 | +PowerShell: |
| 141 | + |
| 142 | +```powershell |
| 143 | +$env:PYTHONPATH = "src" |
| 144 | +python -m patchrank rank examples/trivy.json --kev examples/kev.json --epss examples/epss.json --format markdown |
| 145 | +``` |
| 146 | + |
| 147 | +## Security |
| 148 | + |
| 149 | +Patchrank reads local reports and optionally fetches public vulnerability |
| 150 | +intelligence. It does not need credentials. Do not upload private scanner |
| 151 | +reports to third-party systems unless you understand their contents. |
| 152 | + |
| 153 | +See [SECURITY.md](SECURITY.md). |
| 154 | + |
| 155 | +## License |
| 156 | + |
| 157 | +MIT. See [LICENSE](LICENSE). |
0 commit comments