diff options
| author | Niko Mauno <niko.mauno@vaisala.com> | 2025-11-04 08:33:30 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-11-07 13:15:35 +0000 |
| commit | 35f915165ac023333cb5cae46dc48c8d47f75923 (patch) | |
| tree | a5d2d2ca34ffaf7553413b6d0e28a899bdab895c /meta/recipes-core | |
| parent | d75748e69277ba67fceb8e0522e366c126d0f43f (diff) | |
| download | poky-35f915165ac023333cb5cae46dc48c8d47f75923.tar.gz | |
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().
(From OE-Core rev: 3099b266e41f2918add3a880233ae3908328e4cb)
Signed-off-by: Niko Mauno <niko.mauno@vaisala.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core')
| -rw-r--r-- | meta/recipes-core/meta/cve-update-db-native.bb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/meta/recipes-core/meta/cve-update-db-native.bb b/meta/recipes-core/meta/cve-update-db-native.bb index 713c73e574..3a6dc95580 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() { | |||
| 77 | if os.path.exists(db_file): | 77 | if os.path.exists(db_file): |
| 78 | shutil.copy2(db_file, db_tmp_file) | 78 | shutil.copy2(db_file, db_tmp_file) |
| 79 | 79 | ||
| 80 | if update_db_file(db_tmp_file, d) == True: | 80 | if update_db_file(db_tmp_file, d): |
| 81 | # Update downloaded correctly, can swap files | 81 | # Update downloaded correctly, can swap files |
| 82 | shutil.move(db_tmp_file, db_file) | 82 | shutil.move(db_tmp_file, db_file) |
| 83 | else: | 83 | else: |
| @@ -136,9 +136,11 @@ def update_db_file(db_tmp_file, d): | |||
| 136 | """ | 136 | """ |
| 137 | Update the given database file | 137 | Update the given database file |
| 138 | """ | 138 | """ |
| 139 | import bb.utils, bb.progress | 139 | import bb.progress |
| 140 | import bb.utils | ||
| 140 | from datetime import date | 141 | from datetime import date |
| 141 | import urllib, gzip, sqlite3 | 142 | import sqlite3 |
| 143 | import urllib | ||
| 142 | 144 | ||
| 143 | YEAR_START = 2002 | 145 | YEAR_START = 2002 |
| 144 | cve_socket_timeout = int(d.getVar("CVE_SOCKET_TIMEOUT")) | 146 | cve_socket_timeout = int(d.getVar("CVE_SOCKET_TIMEOUT")) |
| @@ -167,8 +169,8 @@ def update_db_file(db_tmp_file, d): | |||
| 167 | return False | 169 | return False |
| 168 | 170 | ||
| 169 | if response: | 171 | if response: |
| 170 | for l in response.read().decode("utf-8").splitlines(): | 172 | for line in response.read().decode("utf-8").splitlines(): |
| 171 | key, value = l.split(":", 1) | 173 | key, value = line.split(":", 1) |
| 172 | if key == "lastModifiedDate": | 174 | if key == "lastModifiedDate": |
| 173 | last_modified = value | 175 | last_modified = value |
| 174 | break | 176 | break |
| @@ -332,7 +334,7 @@ def get_metric_entry(metric): | |||
| 332 | secondaries = [c for c in metric if c['type'] == "Secondary"] | 334 | secondaries = [c for c in metric if c['type'] == "Secondary"] |
| 333 | if len(primaries) > 0: | 335 | if len(primaries) > 0: |
| 334 | return primaries[0] | 336 | return primaries[0] |
| 335 | elif len(secondaries)>0: | 337 | elif len(secondaries) > 0: |
| 336 | return secondaries[0] | 338 | return secondaries[0] |
| 337 | return None | 339 | return None |
| 338 | 340 | ||
| @@ -341,10 +343,10 @@ def update_db_fkie(conn, jsondata): | |||
| 341 | root = json.loads(jsondata) | 343 | root = json.loads(jsondata) |
| 342 | 344 | ||
| 343 | for elt in root['cve_items']: | 345 | for elt in root['cve_items']: |
| 344 | if not 'vulnStatus' in elt or elt['vulnStatus'] == 'Rejected': | 346 | if 'vulnStatus' not in elt or elt['vulnStatus'] == 'Rejected': |
| 345 | continue | 347 | continue |
| 346 | 348 | ||
| 347 | if not 'configurations' in elt: | 349 | if 'configurations' not in elt: |
| 348 | continue | 350 | continue |
| 349 | 351 | ||
| 350 | accessVector = None | 352 | accessVector = None |
