summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core
diff options
context:
space:
mode:
authorDhairya Nagodra <dnagodra@cisco.com>2023-12-11 02:05:00 -0800
committerSteve Sakoman <steve@sakoman.com>2024-01-09 05:50:24 -1000
commitf2e30f54e1dbb36d7527d0117eb2435f25e7e154 (patch)
tree33961bbbae3f5bfc3522c2775c7f9fd576114dc2 /meta/recipes-core
parent4f7e40652cdf647c28f7dc6052bfa5db6bc9d8fb (diff)
downloadopenembedded-core-contrib-f2e30f54e1dbb36d7527d0117eb2435f25e7e154.tar.gz
cve-update-nvd2-native: increase the delay between subsequent request failures
Sometimes NVD servers are unstable and return too many errors. There is an option to have higher fetch attempts to increase the chances of successfully fetching the CVE data. Additionally, it also makes sense to progressively increase the delay after a failed request to an already unstable or busy server. The increase in delay is reset after every successful request and the maximum delay is limited to 30 seconds. Also, the logs are improved to give more clarity. Signed-off-by: Dhairya Nagodra <dnagodra@cisco.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> (cherry picked from commit 7101d654635b707e56b0dbae8c2146b312d211ea) Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta/recipes-core')
-rw-r--r--meta/recipes-core/meta/cve-update-nvd2-native.bb13
1 files changed, 9 insertions, 4 deletions
diff --git a/meta/recipes-core/meta/cve-update-nvd2-native.bb b/meta/recipes-core/meta/cve-update-nvd2-native.bb
index 0a8b6a8a0a..69ba20a6cb 100644
--- a/meta/recipes-core/meta/cve-update-nvd2-native.bb
+++ b/meta/recipes-core/meta/cve-update-nvd2-native.bb
@@ -114,7 +114,10 @@ def cleanup_db_download(db_file, db_tmp_file):
if os.path.exists(db_tmp_file):
os.remove(db_tmp_file)
-def nvd_request_next(url, attempts, api_key, args):
+def nvd_request_wait(attempt, min_wait):
+ return min ( ( (2 * attempt) + min_wait ) , 30)
+
+def nvd_request_next(url, attempts, api_key, args, min_wait):
"""
Request next part of the NVD dabase
"""
@@ -143,8 +146,10 @@ def nvd_request_next(url, attempts, api_key, args):
r.close()
except Exception as e:
- bb.note("CVE database: received error (%s), retrying" % (e))
- time.sleep(6)
+ wait_time = nvd_request_wait(attempt, min_wait)
+ bb.note("CVE database: received error (%s)" % (e))
+ bb.note("CVE database: retrying download after %d seconds. attempted (%d/%d)" % (wait_time, attempt+1, attempts))
+ time.sleep(wait_time)
pass
else:
return raw_data
@@ -195,7 +200,7 @@ def update_db_file(db_tmp_file, d, database_time):
while True:
req_args['startIndex'] = index
- raw_data = nvd_request_next(url, attempts, api_key, req_args)
+ raw_data = nvd_request_next(url, attempts, api_key, req_args, wait_time)
if raw_data is None:
# We haven't managed to download data
return False