if os.path.exists(db_file):
shutil.copy2(db_file, db_tmp_file)
- if update_db_file(db_tmp_file, d, database_time) == True:
+ if update_db_file(db_tmp_file, d, database_time):
# Update downloaded correctly, can swap files
shutil.move(db_tmp_file, db_file)
else:
os.remove(db_tmp_file)
def nvd_request_wait(attempt, min_wait):
- return min ( ( (2 * attempt) + min_wait ) , 30)
+ return min(((2 * attempt) + min_wait), 30)
def nvd_request_next(url, attempts, api_key, args, min_wait):
"""
"""
Update the given database file
"""
- import bb.utils, bb.progress
+ import bb.progress
+ import bb.utils
import datetime
import sqlite3
import json
conn = sqlite3.connect(db_tmp_file)
initialize_db(conn)
- req_args = {'startIndex' : 0}
+ req_args = {'startIndex': 0}
incr_update_threshold = int(d.getVar("CVE_DB_INCR_UPDATE_AGE_THRES"))
if database_time != 0:
per_page = data["resultsPerPage"]
bb.note("Got %d entries" % per_page)
for cve in data["vulnerabilities"]:
- update_db(conn, cve)
+ update_db(conn, cve)
index += per_page
ph.update((float(index) / (total+1)) * 100)
if index >= total:
- break
+ break
# Recommended by NVD
time.sleep(wait_time)
accessVector = None
vectorString = None
cveId = elt['cve']['id']
- if elt['cve'].get('vulnStatus') == "Rejected":
+ if elt['cve'].get('vulnStatus') == "Rejected":
c = conn.cursor()
c.execute("delete from PRODUCTS where ID = ?;", [cveId])
c.execute("delete from NVD where ID = ?;", [cveId])