From: Niko Mauno Date: Tue, 4 Nov 2025 08:33:30 +0000 (+0000) Subject: cve-update-db-native: pycodestyle fixes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3b0d276992f234b09a7f0fd652dc26e20d00616;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git cve-update-db-native: pycodestyle fixes Fixes following pycodestyle complaints: cve-update-db-native.bb:80:39: E712 comparison to True should be 'if cond is True:' or 'if cond:' cve-update-db-native.bb:128:20: E401 multiple imports on one line cve-update-db-native.bb:130:18: E401 multiple imports on one line cve-update-db-native.bb:171:21: E741 ambiguous variable name 'l' cve-update-db-native.bb:335:26: E225 missing whitespace around operator cve-update-db-native.bb:344:12: E713 test for membership should be 'not in' cve-update-db-native.bb:347:12: E713 test for membership should be 'not in' Also leaves out a redundant 'gzip' import in update_db_file(). Signed-off-by: Niko Mauno Signed-off-by: Mathieu Dubois-Briand --- diff --git a/meta/recipes-core/meta/cve-update-db-native.bb b/meta/recipes-core/meta/cve-update-db-native.bb index 713c73e574f..3a6dc955806 100644 --- a/meta/recipes-core/meta/cve-update-db-native.bb +++ b/meta/recipes-core/meta/cve-update-db-native.bb @@ -77,7 +77,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) == True: + if update_db_file(db_tmp_file, d): # Update downloaded correctly, can swap files shutil.move(db_tmp_file, db_file) else: @@ -136,9 +136,11 @@ def update_db_file(db_tmp_file, d): """ Update the given database file """ - import bb.utils, bb.progress + import bb.progress + import bb.utils from datetime import date - import urllib, gzip, sqlite3 + import sqlite3 + import urllib YEAR_START = 2002 cve_socket_timeout = int(d.getVar("CVE_SOCKET_TIMEOUT")) @@ -167,8 +169,8 @@ def update_db_file(db_tmp_file, d): return False if response: - for l in response.read().decode("utf-8").splitlines(): - key, value = l.split(":", 1) + for line in response.read().decode("utf-8").splitlines(): + key, value = line.split(":", 1) if key == "lastModifiedDate": last_modified = value break @@ -332,7 +334,7 @@ def get_metric_entry(metric): secondaries = [c for c in metric if c['type'] == "Secondary"] if len(primaries) > 0: return primaries[0] - elif len(secondaries)>0: + elif len(secondaries) > 0: return secondaries[0] return None @@ -341,10 +343,10 @@ def update_db_fkie(conn, jsondata): root = json.loads(jsondata) for elt in root['cve_items']: - if not 'vulnStatus' in elt or elt['vulnStatus'] == 'Rejected': + if 'vulnStatus' not in elt or elt['vulnStatus'] == 'Rejected': continue - if not 'configurations' in elt: + if 'configurations' not in elt: continue accessVector = None