diff options
| author | Niko Mauno <niko.mauno@vaisala.com> | 2025-11-04 08:33:29 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-11-07 13:15:35 +0000 |
| commit | d75748e69277ba67fceb8e0522e366c126d0f43f (patch) | |
| tree | e1f01d394628f01d6c24454e852ded5284f0195f /meta | |
| parent | 73fac42feff041a38122ea9beb331cfbaf31f002 (diff) | |
| download | poky-d75748e69277ba67fceb8e0522e366c126d0f43f.tar.gz | |
cve-update-nvd2-native: pycodestyle fixes
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
(From OE-Core rev: f5d789d7e7a787c40f6b290e5c4bee152991bc1a)
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')
| -rw-r--r-- | meta/recipes-core/meta/cve-update-nvd2-native.bb | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/meta/recipes-core/meta/cve-update-nvd2-native.bb b/meta/recipes-core/meta/cve-update-nvd2-native.bb index 1411d16e20..abcbcffcc6 100644 --- a/meta/recipes-core/meta/cve-update-nvd2-native.bb +++ b/meta/recipes-core/meta/cve-update-nvd2-native.bb | |||
| @@ -92,7 +92,7 @@ python do_fetch() { | |||
| 92 | if os.path.exists(db_file): | 92 | if os.path.exists(db_file): |
| 93 | shutil.copy2(db_file, db_tmp_file) | 93 | shutil.copy2(db_file, db_tmp_file) |
| 94 | 94 | ||
| 95 | if update_db_file(db_tmp_file, d, database_time) == True: | 95 | if update_db_file(db_tmp_file, d, database_time): |
| 96 | # Update downloaded correctly, can swap files | 96 | # Update downloaded correctly, can swap files |
| 97 | shutil.move(db_tmp_file, db_file) | 97 | shutil.move(db_tmp_file, db_file) |
| 98 | else: | 98 | else: |
| @@ -124,7 +124,7 @@ def cleanup_db_download(db_tmp_file): | |||
| 124 | os.remove(db_tmp_file) | 124 | os.remove(db_tmp_file) |
| 125 | 125 | ||
| 126 | def nvd_request_wait(attempt, min_wait): | 126 | def nvd_request_wait(attempt, min_wait): |
| 127 | return min ( ( (2 * attempt) + min_wait ) , 30) | 127 | return min(((2 * attempt) + min_wait), 30) |
| 128 | 128 | ||
| 129 | def nvd_request_next(url, attempts, api_key, args, min_wait): | 129 | def nvd_request_next(url, attempts, api_key, args, min_wait): |
| 130 | """ | 130 | """ |
| @@ -171,7 +171,8 @@ def update_db_file(db_tmp_file, d, database_time): | |||
| 171 | """ | 171 | """ |
| 172 | Update the given database file | 172 | Update the given database file |
| 173 | """ | 173 | """ |
| 174 | import bb.utils, bb.progress | 174 | import bb.progress |
| 175 | import bb.utils | ||
| 175 | import datetime | 176 | import datetime |
| 176 | import sqlite3 | 177 | import sqlite3 |
| 177 | import json | 178 | import json |
| @@ -180,7 +181,7 @@ def update_db_file(db_tmp_file, d, database_time): | |||
| 180 | conn = sqlite3.connect(db_tmp_file) | 181 | conn = sqlite3.connect(db_tmp_file) |
| 181 | initialize_db(conn) | 182 | initialize_db(conn) |
| 182 | 183 | ||
| 183 | req_args = {'startIndex' : 0} | 184 | req_args = {'startIndex': 0} |
| 184 | 185 | ||
| 185 | incr_update_threshold = int(d.getVar("CVE_DB_INCR_UPDATE_AGE_THRES")) | 186 | incr_update_threshold = int(d.getVar("CVE_DB_INCR_UPDATE_AGE_THRES")) |
| 186 | if database_time != 0: | 187 | if database_time != 0: |
| @@ -233,12 +234,12 @@ def update_db_file(db_tmp_file, d, database_time): | |||
| 233 | per_page = data["resultsPerPage"] | 234 | per_page = data["resultsPerPage"] |
| 234 | bb.note("Got %d entries" % per_page) | 235 | bb.note("Got %d entries" % per_page) |
| 235 | for cve in data["vulnerabilities"]: | 236 | for cve in data["vulnerabilities"]: |
| 236 | update_db(conn, cve) | 237 | update_db(conn, cve) |
| 237 | 238 | ||
| 238 | index += per_page | 239 | index += per_page |
| 239 | ph.update((float(index) / (total+1)) * 100) | 240 | ph.update((float(index) / (total+1)) * 100) |
| 240 | if index >= total: | 241 | if index >= total: |
| 241 | break | 242 | break |
| 242 | 243 | ||
| 243 | # Recommended by NVD | 244 | # Recommended by NVD |
| 244 | time.sleep(wait_time) | 245 | time.sleep(wait_time) |
| @@ -333,7 +334,7 @@ def update_db(conn, elt): | |||
| 333 | accessVector = None | 334 | accessVector = None |
| 334 | vectorString = None | 335 | vectorString = None |
| 335 | cveId = elt['cve']['id'] | 336 | cveId = elt['cve']['id'] |
| 336 | if elt['cve'].get('vulnStatus') == "Rejected": | 337 | if elt['cve'].get('vulnStatus') == "Rejected": |
| 337 | c = conn.cursor() | 338 | c = conn.cursor() |
| 338 | c.execute("delete from PRODUCTS where ID = ?;", [cveId]) | 339 | c.execute("delete from PRODUCTS where ID = ?;", [cveId]) |
| 339 | c.execute("delete from NVD where ID = ?;", [cveId]) | 340 | c.execute("delete from NVD where ID = ?;", [cveId]) |
