summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core
diff options
context:
space:
mode:
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):
114 if os.path.exists(db_tmp_file): 114 if os.path.exists(db_tmp_file):
115 os.remove(db_tmp_file) 115 os.remove(db_tmp_file)
116 116
117def nvd_request_next(url, attempts, api_key, args): 117def nvd_request_wait(attempt, min_wait):
118 return min ( ( (2 * attempt) + min_wait ) , 30)
119
120def nvd_request_next(url, attempts, api_key, args, min_wait):
118 """ 121 """
119 Request next part of the NVD dabase 122 Request next part of the NVD dabase
120 """ 123 """
@@ -143,8 +146,10 @@ def nvd_request_next(url, attempts, api_key, args):
143 r.close() 146 r.close()
144 147
145 except Exception as e: 148 except Exception as e:
146 bb.note("CVE database: received error (%s), retrying" % (e)) 149 wait_time = nvd_request_wait(attempt, min_wait)
147 time.sleep(6) 150 bb.note("CVE database: received error (%s)" % (e))
151 bb.note("CVE database: retrying download after %d seconds. attempted (%d/%d)" % (wait_time, attempt+1, attempts))
152 time.sleep(wait_time)
148 pass 153 pass
149 else: 154 else:
150 return raw_data 155 return raw_data
@@ -195,7 +200,7 @@ def update_db_file(db_tmp_file, d, database_time):
195 200
196 while True: 201 while True:
197 req_args['startIndex'] = index 202 req_args['startIndex'] = index
198 raw_data = nvd_request_next(url, attempts, api_key, req_args) 203 raw_data = nvd_request_next(url, attempts, api_key, req_args, wait_time)
199 if raw_data is None: 204 if raw_data is None:
200 # We haven't managed to download data 205 # We haven't managed to download data
201 return False 206 return False