@@ -0,0 +1,1361 @@
+# Script to import CVE data from NIST https://nvd.nist.gov/vuln/data-feeds#JSON_FEED%0A# https://static.nvd.nist.gov/feeds/json/cve/1.0/nvdcve-1.0-modified.json.gz%0A%0Aimport gzip%0Aimport json%0Aimport pycurl%0Afrom io import BytesIO%0A%0ANVD_CVE_ENDPOINT = 'https://static.nvd.nist.gov/feeds/json/cve/1.0/nvdcve-1.0-modified.json.gz'%0ADATA_FILE = './data.json.gz'%0A%0Awith open(DATA_FILE, 'wb') as fd:%0A%09c = pycurl.Curl()%0A%09c.setopt(c.URL, NVD_CVE_ENDPOINT)%0A%09c.setopt(c.WRITEDATA, fd)%0A%09c.perform()%0A%0Aif c.getinfo(c.RESPONSE_CODE) != 200:%0A%09print('data request failed')%0A%09exit(1)%0A%0A# Close Curl%0Ac.close()%0A%0A# Test: Ensure we received a valid gzip file%0A%0A# Extract gzip and load JSON to in-memory%0Awith gzip.open(DATA_FILE, 'rt') as fd:%0A%09data = json.load(fd)%0A%0A# Read in-memory JSON structure keys%0A#%09CVE_data_version%0A#%09CVE_data_format%0A#%09CVE_Items%0A#%09CVE_data_timestamp%0A#%09CVE_data_numberOfCVEs%0A#%09CVE_data_type%0Aprint('CVE_data_version:', data%5B'CVE_data_version'%5D)%0Aprint('CVE_data_format:', data%5B'CVE_data_format'%5D)%0Aprint('CVE_data_timestamp:', data%5B'CVE_data_timestamp'%5D)%0Aprint('CVE_data_numberOfCVEs:', data%5B'CVE_data_numberOfCVEs'%5D)%0Aprint('CVE_data_type:', data%5B'CVE_data_type'%5D)%0A%0Acount = 0%0Afor item in data%5B'CVE_Items'%5D:%0A%09if 'cve' in item:%0A%09%09if 'CVE_data_meta' in item%5B'cve'%5D:%0A%09%09%09if 'ID' in item%5B'cve'%5D%5B'CVE_data_meta'%5D:%0A%09%09%09%09#print(item%5B'cve'%5D%5B'CVE_data_meta'%5D%5B'ID'%5D)%0A%09%09%09%09count = count + 1%0A

Create get_cve_data.py