summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Marko <peter.marko@siemens.com>2025-04-07 11:35:57 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-04-10 11:53:36 +0100
commit39cbc37918d2673d97800b138d5d3ea4585e92f7 (patch)
tree8f424fa6ee3eedf2ddfbdebf9035a34b0ded6b98
parent9f9e7bbace5f0504ea501444c6abce21f6845bd1 (diff)
downloadpoky-39cbc37918d2673d97800b138d5d3ea4585e92f7.tar.gz
cve-update-nvd2-native: add workaround for json5 style list
NVD responses changed to an invalid json between: * April 5, 2025 at 3:03:44 AM GMT+2 * April 5, 2025 at 4:19:48 AM GMT+2 The last response is since then in format { "resultsPerPage": 625, "startIndex": 288000, "totalResults": 288625, "format": "NVD_CVE", "version": "2.0", "timestamp": "2025-04-07T07:17:17.534", "vulnerabilities": [ {...}, ... {...}, ] } Json does not allow trailing , in responses, that is json5 format. So cve-update-nvd2-native do_Fetch task fails with log backtrace ending: ... File: '/builds/ccp/meta-siemens/projects/ccp/../../poky/meta/recipes-core/meta/cve-update-nvd2-native.bb', lineno: 234, function: update_db_file 0230: if raw_data is None: 0231: # We haven't managed to download data 0232: return False 0233: *** 0234: data = json.loads(raw_data) 0235: 0236: index = data["startIndex"] 0237: total = data["totalResults"] 0238: per_page = data["resultsPerPage"] ... File: '/usr/lib/python3.11/json/decoder.py', lineno: 355, function: raw_decode 0351: """ 0352: try: 0353: obj, end = self.scan_once(s, idx) 0354: except StopIteration as err: *** 0355: raise JSONDecodeError("Expecting value", s, err.value) from None 0356: return obj, end Exception: json.decoder.JSONDecodeError: Expecting value: line 1 column 1442633 (char 1442632) ... There was no announcement about json format of API v2.0 by nvd. Also this happens only if whole database is queried (database update is fine, even when multiple pages as queried). And lastly it's only the cve list, all other lists inside are fine. So this looks like a bug in NVD 2.0 introduced with some update. Patch this with simple character deletion for now and let's monitor the situation and possibly switch to json5 in the future. Note that there is no native json5 support in python, we'd have to use one of external libraries for it. (From OE-Core rev: 131d983dd19ae12bf0746f772b7d7a058e549fb1) Signed-off-by: Peter Marko <peter.marko@siemens.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-core/meta/cve-update-nvd2-native.bb5
1 files changed, 5 insertions, 0 deletions
diff --git a/meta/recipes-core/meta/cve-update-nvd2-native.bb b/meta/recipes-core/meta/cve-update-nvd2-native.bb
index b9c18bf6b6..32a14a932b 100644
--- a/meta/recipes-core/meta/cve-update-nvd2-native.bb
+++ b/meta/recipes-core/meta/cve-update-nvd2-native.bb
@@ -229,6 +229,11 @@ def update_db_file(db_tmp_file, d, database_time):
229 # We haven't managed to download data 229 # We haven't managed to download data
230 return False 230 return False
231 231
232 # hack for json5 style responses
233 if raw_data[-3:] == ',]}':
234 bb.note("Removing trailing ',' from nvd response")
235 raw_data = raw_data[:-3] + ']}'
236
232 data = json.loads(raw_data) 237 data = json.loads(raw_data)
233 238
234 index = data["startIndex"] 239 index = data["startIndex"]