@@ -168,9 +168,14 @@ async def get_nvd_params(
168
168
await self .validate_nvd_api ()
169
169
170
170
if self .invalid_api :
171
- self .logger .warning (
172
- f'Unable to access NVD using provided API key: { self .params ["apiKey" ]} '
173
- )
171
+ if self .api_version == "1.0" :
172
+ self .logger .warning (
173
+ f'Unable to access NVD using provided API key: { self .params ["apiKey" ]} '
174
+ )
175
+ else :
176
+ self .logger .warning (
177
+ f'Unable to access NVD using provided API key: { self .header ["apiKey" ]} '
178
+ )
174
179
else :
175
180
if time_of_last_update :
176
181
# Fetch all the updated CVE entries from the modified date. Subtracting 2-minute offset for updating cve entries
@@ -228,7 +233,11 @@ async def validate_nvd_api(self):
228
233
data = await response .json ()
229
234
if data .get ("error" , False ):
230
235
self .logger .error (f"NVD API error: { data ['error' ]} " )
231
- raise NVDKeyError (self .params ["apiKey" ])
236
+ if self .api_version == "1.0" :
237
+ raise NVDKeyError (self .params ["apiKey" ])
238
+ else :
239
+ raise NVDKeyError (self .header ["apiKey" ])
240
+
232
241
except aiohttp .ClientResponseError as client_err :
233
242
self .logger .debug (f"Response { client_err } " )
234
243
self .invalid_api = True
@@ -240,6 +249,9 @@ async def validate_nvd_api(self):
240
249
if self .api_version == "1.0" :
241
250
del self .params ["apiKey" ]
242
251
self .api_key = ""
252
+ else :
253
+ del self .header ["apiKey" ]
254
+ self .api_key = ""
243
255
244
256
async def load_nvd_request (self , start_index ):
245
257
"""Get single NVD request and update year_wise_data list which contains list of all CVEs"""
0 commit comments