5
5
6
6
import asyncio
7
7
import datetime
8
- import glob
8
+
9
+ # import glob
9
10
import gzip
10
11
import hashlib
11
12
import json
@@ -583,17 +584,20 @@ async def cache_update(
583
584
if len (gzip_data ) == 0 :
584
585
self .LOGGER .debug (f"Missing data for { filename } " )
585
586
return
586
- json_data = gzip .decompress (gzip_data )
587
- gotsha = hashlib .sha256 (json_data ).hexdigest ().upper ()
588
- async with FileIO (filepath , "wb" ) as filepath_handle :
589
- await filepath_handle .write (gzip_data )
590
- # Raise error if there was an issue with the sha
591
- if gotsha != sha :
592
- # Remove the file if there was an issue
593
- # exit(100)
594
- filepath .unlink ()
595
- with ErrorHandler (mode = self .error_mode , logger = self .LOGGER ):
596
- raise SHAMismatch (f"{ url } (have: { gotsha } , want: { sha } )" )
587
+ try :
588
+ json_data = gzip .decompress (gzip_data )
589
+ gotsha = hashlib .sha256 (json_data ).hexdigest ().upper ()
590
+ async with FileIO (filepath , "wb" ) as filepath_handle :
591
+ await filepath_handle .write (gzip_data )
592
+ # Raise error if there was an issue with the sha
593
+ if gotsha != sha :
594
+ # Remove the file if there was an issue
595
+ # exit(100)
596
+ filepath .unlink ()
597
+ with ErrorHandler (mode = self .error_mode , logger = self .LOGGER ):
598
+ raise SHAMismatch (f"{ url } (have: { gotsha } , want: { sha } )" )
599
+ except Exception :
600
+ self .LOGGER .warning (f"Invalid data in { filename } , skipping" )
597
601
598
602
def load_nvd_year (self , year : int ) -> dict [str , str | object ]:
599
603
"""
@@ -617,7 +621,9 @@ def nvd_years(self) -> list[int]:
617
621
"""
618
622
Return the years we have NVD data for.
619
623
"""
620
- return sorted (
621
- int (filename .split ("." )[- 3 ].split ("-" )[- 1 ])
622
- for filename in glob .glob (str (Path (self .cachedir ) / "nvdcve-1.1-*.json.gz" ))
623
- )
624
+ # return sorted(
625
+ # int(filename.split(".")[-3].split("-")[-1])
626
+ # for filename in glob.glob(str(Path(self.cachedir) / "nvdcve-1.1-*.json.gz"))
627
+ # )
628
+ # FIXME: temporary workaround so we don't try to load bad year data
629
+ return list (range (2020 , 2025 ))
0 commit comments