JPeetz/agent-skills / skills/security/vulnerability-management
vulnerability-management
VerifiedUse this skill when implementing or operating a vulnerability management program — automated vulnerability scanning, risk-based prioritization (CVSS/EPSS), patch management automation, zero-day response procedures, CVE tracking and monitoring, vulnerability metrics tracking, remediation verification, security advisory monitoring, and threat intelligence integration.
| File | Kind | Size |
|---|---|---|
| CHANGELOG.md | markdown | 1.8 KB |
| LICENSE | other | 1.0 KB |
| SKILL.md | skill md | 21.6 KB |
| evals/evals.json | config | 3.6 KB |
| references/sources.md | markdown | 7.3 KB |
| scripts/cve_lookup.pyexecutable | script | 7.7 KB |
| scripts/prioritize.pyexecutable | script | 8.7 KB |
scripts/cve_lookup.py
View on GitHub#!/usr/bin/env python3
"""Look up a CVE in NVD and enrich it with EPSS and CISA KEV status.
Usage:
python3 cve_lookup.py CVE-2024-3400
python3 cve_lookup.py CVE-2024-3400 CVE-2023-44487 --json
NVD_API_KEY=... python3 cve_lookup.py CVE-2024-3400
No third-party dependencies required (urllib). An NVD API key is optional but
raises the rate limit; set it via the NVD_API_KEY environment variable rather
than passing it on the command line.
Data sources: NVD 2.0, FIRST EPSS, CISA KEV.
"""
from __future__ import annotations
import argparse
import json
import os
import sys
import time
import urllib.error
import urllib.parse
import urllib.request
NVD_URL = "https://services.nvd.nist.gov/rest/json/cves/2.0"
EPSS_URL = "https://api.first.org/data/v1/epss"
KEV_URL = (
"https://www.cisa.gov/sites/default/files/feeds/"
"known_exploited_vulnerabilities.json"
)
TIMEOUT = 30
USER_AGENT = "vulnerability-management-skill/1.0 (+https://github.com/JPeetz/agent-skills)"
def _get(url: str, headers: dict | None = None, retries: int = 3) -> dict:
req = urllib.request.Request(url, headers={"User-Agent": USER_AGENT, **(headers or {})})
last: Exception | None = None
for attempt in range(retries):
try:
with urllib.request.urlopen(req, timeout=TIMEOUT) as resp:
return json.loads(resp.read().decode("utf-8"))
except urllib.error.HTTPError as e:
last = e
# NVD returns 403/503 when the keyless rate limit is exceeded.
if e.code in (403, 429, 503) and attempt < retries - 1:
time.sleep(6 * (attempt + 1))
continue
raise
except (urllib.error.URLError, TimeoutError) as e:
last = e
if attempt < retries - 1:
time.sleep(3 * (attempt + 1))
continue
raise
if last is not None:
raise last
raise RuntimeError("unreachable") # pragma: no cover
def fetch_nvd(cve_id: str) -> dict:
headers = {}
key = os.environ.get("NVD_API_KEY")
if key:
headers["apiKey"] = key
url = f"{NVD_URL}?{urllib.parse.urlencode({'cveId': cve_id})}"
data = _get(url, headers)
vulns = data.get("vulnerabilities") or []
if not vulns:
return {}
cve = vulns[0]["cve"]
metrics = cve.get("metrics", {})
score, vector, version = None, None, None
# Prefer newest CVSS version available, primary source first.
for key_name, label in (
("cvssMetricV40", "4.0"),
("cvssMetricV31", "3.1"),
("cvssMetricV30", "3.0"),
("cvssMetricV2", "2.0"),
):
entries = metrics.get(key_name) or []
if not entries:
continue
primary = next((e for e in entries if e.get("type") == "Primary"), entries[0])
cd = primary.get("cvssData", {})
score, vector, version = cd.get("baseScore"), cd.get("vectorString"), label
break
desc = ""
for d in cve.get("descriptions", []):
if d.get("lang") == "en":
desc = d.get("value", "")
break
return {
"cve": cve_id,
"description": desc,
"published": cve.get("published"),
"last_modified": cve.get("lastModified"),
"cvss_score": score,
"cvss_version": version,
"cvss_vector": vector,
"cwe": sorted(
{
d.get("value")
for w in cve.get("weaknesses", [])
for d in w.get("description", [])
if d.get("value", "").startswith("CWE-")
}
),
"references": [r.get("url") for r in cve.get("references", [])][:5],
}
def fetch_epss(cve_id: str) -> dict:
try:
data = _get(f"{EPSS_URL}?{urllib.parse.urlencode({'cve': cve_id})}")
except (urllib.error.URLError, TimeoutError, json.JSONDecodeError):
return {}
rows = data.get("data") or []
if not rows:
return {}
row = rows[0]
return {
"epss": float(row.get("epss", 0)),
"epss_percentile": float(row.get("percentile", 0)),
"epss_date": row.get("date"),
}
def fetch_kev() -> set[str]:
try:
data = _get(KEV_URL)
except (urllib.error.URLError, TimeoutError, json.JSONDecodeError):
return set()
return {v.get("cveID", "").upper() for v in data.get("vulnerabilities", [])}
def severity_band(score: float | None) -> str:
if score is None:
return "UNKNOWN"
if score == 0:
return "NONE"
if score < 4.0:
return "LOW"
if score < 7.0:
return "MEDIUM"
if score < 9.0:
return "HIGH"
return "CRITICAL"
def priority(cvss: float | None, epss: float | None, kev: bool) -> str:
"""Coarse triage bucket using the skill's composite model."""
if kev:
return "EMERGENCY"
if cvss is None:
return "TRIAGE"
if cvss >= 9.0 or (cvss >= 7.0 and (epss or 0) >= 0.10):
return "URGENT"
if cvss >= 7.0:
return "HIGH"
if cvss >= 4.0:
return "ROUTINE"
return "DEFERRED"
def lookup(cve_id: str, kev_set: set[str]) -> dict:
cve_id = cve_id.strip().upper()
record: dict = {"cve": cve_id}
try:
record.update(fetch_nvd(cve_id))
except urllib.error.HTTPError as e:
record["nvd_error"] = f"HTTP {e.code}"
except (urllib.error.URLError, TimeoutError, json.JSONDecodeError) as e:
record["nvd_error"] = str(e)[:120]
record.update(fetch_epss(cve_id))
record["kev"] = cve_id in kev_set
record["severity"] = severity_band(record.get("cvss_score"))
record["priority"] = priority(record.get("cvss_score"), record.get("epss"), record["kev"])
return record
def render(rec: dict) -> str:
lines = [f"{rec['cve']} [{rec.get('priority', '?')}]"]
if rec.get("nvd_error"):
lines.append(f" NVD error: {rec['nvd_error']}")
if rec.get("description"):
lines.append(f" {rec['description'][:220]}")
if rec.get("cvss_score") is not None:
lines.append(
f" CVSS {rec['cvss_score']} ({rec.get('severity')}, v{rec.get('cvss_version')})"
)
if rec.get("cvss_vector"):
lines.append(f" Vector: {rec['cvss_vector']}")
if rec.get("epss") is not None:
lines.append(
f" EPSS {rec['epss']:.4f} ({rec['epss_percentile'] * 100:.1f}th pct, "
f"{rec.get('epss_date')})"
)
else:
lines.append(" EPSS: no score (unknown, not zero)")
lines.append(f" KEV: {'YES — known exploited' if rec['kev'] else 'no'}")
if rec.get("cwe"):
lines.append(f" CWE: {', '.join(rec['cwe'])}")
if rec.get("published"):
lines.append(f" Published: {rec['published']}")
return "\n".join(lines)
def main() -> int:
ap = argparse.ArgumentParser(description="CVE lookup with CVSS, EPSS, and KEV enrichment.")
ap.add_argument("cve_ids", nargs="+", help="One or more CVE IDs, e.g. CVE-2024-3400")
ap.add_argument("--json", action="store_true", help="Emit JSON instead of text")
ap.add_argument("--kev-only", action="store_true", help="Only print KEV-listed CVEs")
args = ap.parse_args()
if any(not c.upper().startswith("CVE-") for c in args.cve_ids):
print("error: all arguments must be CVE IDs (CVE-YYYY-NNNN)", file=sys.stderr)
return 2
kev_set = fetch_kev()
if not kev_set:
print("warning: KEV feed unavailable; KEV status will read 'no'", file=sys.stderr)
results = [lookup(c, kev_set) for c in args.cve_ids]
if args.kev_only:
results = [r for r in results if r.get("kev")]
if args.json:
print(json.dumps(results, indent=2))
else:
print("\n\n".join(render(r) for r in results))
return 0
if __name__ == "__main__":
raise SystemExit(main())
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |