Skip to content

Commit 538c1af

Browse files
fix: improved metadata handling for NVD mirror (fixes #5093) (#5102)
1 parent 09d6574 commit 538c1af

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cve_bin_tool/data_sources/nvd_source.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ async def fetch_cves(self):
420420
tasks = [
421421
self.cache_update(self.session, url, meta["sha256"])
422422
for url, meta in nvd_metadata.items()
423-
if meta is not None
423+
if meta is not None and meta.get("sha256") is not None
424424
]
425425

426426
total_tasks = len(tasks)
@@ -579,6 +579,9 @@ async def cache_update(
579579
# Raise for all other 4xx errors
580580
response.raise_for_status()
581581
gzip_data = await response.read()
582+
if len(gzip_data) == 0:
583+
self.LOGGER.debug(f"Missing data for {filename}")
584+
return
582585
json_data = gzip.decompress(gzip_data)
583586
gotsha = hashlib.sha256(json_data).hexdigest().upper()
584587
async with FileIO(filepath, "wb") as filepath_handle:

0 commit comments

Comments
 (0)