]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
cve-update-db-native: pycodestyle fixes
authorNiko Mauno <niko.mauno@vaisala.com>
Tue, 4 Nov 2025 08:33:30 +0000 (08:33 +0000)
committerMathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Tue, 4 Nov 2025 09:42:57 +0000 (10:42 +0100)
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 <niko.mauno@vaisala.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
meta/recipes-core/meta/cve-update-db-native.bb

index 713c73e574f5c5ab0b8ae34e8b9f3ccc1d9da7e2..3a6dc9558061732af655ce4099777407c199a054 100644 (file)
@@ -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