@@ -92,7 +92,7 @@ python do_fetch() {
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:
@@ -124,7 +124,7 @@ def cleanup_db_download(db_tmp_file):
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):
"""
@@ -171,7 +171,8 @@ def update_db_file(db_tmp_file, d, database_time):
"""
Update the given database file
"""
- import bb.utils, bb.progress
+ import bb.progress
+ import bb.utils
import datetime
import sqlite3
import json
@@ -180,7 +181,7 @@ def update_db_file(db_tmp_file, d, database_time):
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:
@@ -233,12 +234,12 @@ def update_db_file(db_tmp_file, d, database_time):
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)
@@ -333,7 +334,7 @@ def update_db(conn, elt):
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])
Fixes following pycodestyle complaints: cve-update-nvd2-native.bb:95:54: E712 comparison to True should be 'if cond is True:' or 'if cond:' cve-update-nvd2-native.bb:127:15: E211 whitespace before '(' cve-update-nvd2-native.bb:127:17: E201 whitespace after '(' cve-update-nvd2-native.bb:127:19: E201 whitespace after '(' cve-update-nvd2-native.bb:127:44: E202 whitespace before ')' cve-update-nvd2-native.bb:127:46: E203 whitespace before ',' cve-update-nvd2-native.bb:174:20: E401 multiple imports on one line cve-update-nvd2-native.bb:183:29: E203 whitespace before ':' cve-update-nvd2-native.bb:236:16: E111 indentation is not a multiple of 4 cve-update-nvd2-native.bb:241:16: E111 indentation is not a multiple of 4 cve-update-nvd2-native.bb:336:39: E222 multiple spaces after operator Signed-off-by: Niko Mauno <niko.mauno@vaisala.com> --- meta/recipes-core/meta/cve-update-nvd2-native.bb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)