summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-core/meta/cve-update-nvd2-native.bb10
1 files changed, 7 insertions, 3 deletions
diff --git a/meta/recipes-core/meta/cve-update-nvd2-native.bb b/meta/recipes-core/meta/cve-update-nvd2-native.bb
index 64a96a46f0..dab0b69edc 100644
--- a/meta/recipes-core/meta/cve-update-nvd2-native.bb
+++ b/meta/recipes-core/meta/cve-update-nvd2-native.bb
@@ -26,6 +26,9 @@ NVDCVE_API_KEY ?= ""
26# Use a negative value to skip the update 26# Use a negative value to skip the update
27CVE_DB_UPDATE_INTERVAL ?= "86400" 27CVE_DB_UPDATE_INTERVAL ?= "86400"
28 28
29# Number of attmepts for each http query to nvd server before giving up
30CVE_DB_UPDATE_ATTEMPTS ?= "5"
31
29CVE_DB_TEMP_FILE ?= "${CVE_CHECK_DB_DIR}/temp_nvdcve_2.db" 32CVE_DB_TEMP_FILE ?= "${CVE_CHECK_DB_DIR}/temp_nvdcve_2.db"
30 33
31CVE_CHECK_DB_FILE ?= "${CVE_CHECK_DB_DIR}/nvdcve_2.db" 34CVE_CHECK_DB_FILE ?= "${CVE_CHECK_DB_DIR}/nvdcve_2.db"
@@ -111,7 +114,7 @@ def cleanup_db_download(db_file, db_tmp_file):
111 if os.path.exists(db_tmp_file): 114 if os.path.exists(db_tmp_file):
112 os.remove(db_tmp_file) 115 os.remove(db_tmp_file)
113 116
114def nvd_request_next(url, api_key, args): 117def nvd_request_next(url, attempts, api_key, args):
115 """ 118 """
116 Request next part of the NVD dabase 119 Request next part of the NVD dabase
117 """ 120 """
@@ -127,7 +130,7 @@ def nvd_request_next(url, api_key, args):
127 request.add_header("apiKey", api_key) 130 request.add_header("apiKey", api_key)
128 bb.note("Requesting %s" % request.full_url) 131 bb.note("Requesting %s" % request.full_url)
129 132
130 for attempt in range(5): 133 for attempt in range(attempts):
131 try: 134 try:
132 r = urllib.request.urlopen(request) 135 r = urllib.request.urlopen(request)
133 136
@@ -183,10 +186,11 @@ def update_db_file(db_tmp_file, d, database_time):
183 index = 0 186 index = 0
184 url = d.getVar("NVDCVE_URL") 187 url = d.getVar("NVDCVE_URL")
185 api_key = d.getVar("NVDCVE_API_KEY") or None 188 api_key = d.getVar("NVDCVE_API_KEY") or None
189 attempts = int(d.getVar("CVE_DB_UPDATE_ATTEMPTS"))
186 190
187 while True: 191 while True:
188 req_args['startIndex'] = index 192 req_args['startIndex'] = index
189 raw_data = nvd_request_next(url, api_key, req_args) 193 raw_data = nvd_request_next(url, attempts, api_key, req_args)
190 if raw_data is None: 194 if raw_data is None:
191 # We haven't managed to download data 195 # We haven't managed to download data
192 return False 196 return False