dn-scribe commited on
Commit
1f07bde
·
unverified ·
1 Parent(s): 2cb9b6b

add nvd-mitre fallback

Browse files
Files changed (2) hide show
  1. app/tmp.md +0 -0
  2. app/utils.py +8 -1
app/tmp.md DELETED
File without changes
app/utils.py CHANGED
@@ -85,7 +85,14 @@ async def get_cve_info(cve_id: str) -> dict | None:
85
  if resp.status_code == 200:
86
  return resp.json()
87
  elif resp.status_code == 404:
88
- logger.info(f"CVE {cve_id} not found in vulnrichment.")
 
 
 
 
 
 
 
89
  return None
90
  else:
91
  logger.error(f"Unexpected status {resp.status_code} for {url}")
 
85
  if resp.status_code == 200:
86
  return resp.json()
87
  elif resp.status_code == 404:
88
+ logger.info(f"CVE {cve_id} not found in vulnrichment, falling back to MITRE")
89
+ nvd_url = f"https://cveawg.mitre.org/api/cve/{cve_id}"
90
+ async with httpx.AsyncClient(timeout=5.0) as client:
91
+ resp = await client.get(nvd_url)
92
+ if resp.status_code == 200:
93
+ return resp.json()
94
+ else:
95
+ logger.error(f"Failed to fetch CVE from NVD: {resp.status_code} for {nvd_url}")
96
  return None
97
  else:
98
  logger.error(f"Unexpected status {resp.status_code} for {url}")