feat(feed): add CISA KEV feed connector (known exploited vulnerabilities)

This commit is contained in:
Guillaume BOURGEOIS
2026-07-13 12:12:34 +02:00
parent 9cffefbb36
commit 4206b44e78
3 changed files with 165 additions and 0 deletions
@@ -0,0 +1,80 @@
import json, os, sys, ssl, urllib.request, urllib.error
URL = "https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _ctx(cfg):
if cfg.get("insecure"):
c = ssl.create_default_context()
c.check_hostname = False
c.verify_mode = ssl.CERT_NONE
return c
return None
def _get(url, cfg):
req = urllib.request.Request(
url, headers={"User-Agent": "Riposte-SOAR", "Accept": "application/json"}
)
with urllib.request.urlopen(req, timeout=120, context=_ctx(cfg)) as r:
return r.read()
def _run(fn):
try:
print(json.dumps(fn(_cfg(), _inputs())))
except urllib.error.HTTPError as e:
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
sys.exit(1)
except Exception as e:
print(json.dumps({"error": str(e)}))
sys.exit(1)
def main(cfg, inputs):
ransomware_only = bool(inputs.get("ransomware_only"))
raw = _get(URL, cfg)
data = json.loads(raw) if raw else {}
maxn = int(inputs.get("max_indicators") or 0)
out = []
for v in data.get("vulnerabilities", []):
if not isinstance(v, dict):
continue
cid = v.get("cveID")
if not cid:
continue
ransom = v.get("knownRansomwareCampaignUse")
if ransomware_only and str(ransom).lower() != "known":
continue
out.append({
"value": cid,
"type": "cve",
"vendor": v.get("vendorProject"),
"product": v.get("product"),
"name": v.get("vulnerabilityName"),
"date_added": v.get("dateAdded"),
"due_date": v.get("dueDate"),
"ransomware": ransom,
"tags": ["cisa-kev", "exploited"],
})
if maxn and len(out) >= maxn:
break
return {
"source": "cisa:kev",
"count": len(out),
"indicators": out,
"catalog_version": data.get("catalogVersion"),
}
_run(main)