@@ -168,9 +168,14 @@ async def get_nvd_params(
168168 await self .validate_nvd_api ()
169169
170170 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+ )
174179 else :
175180 if time_of_last_update :
176181 # 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):
228233 data = await response .json ()
229234 if data .get ("error" , False ):
230235 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+
232241 except aiohttp .ClientResponseError as client_err :
233242 self .logger .debug (f"Response { client_err } " )
234243 self .invalid_api = True
@@ -240,6 +249,9 @@ async def validate_nvd_api(self):
240249 if self .api_version == "1.0" :
241250 del self .params ["apiKey" ]
242251 self .api_key = ""
252+ else :
253+ del self .header ["apiKey" ]
254+ self .api_key = ""
243255
244256 async def load_nvd_request (self , start_index ):
245257 """Get single NVD request and update year_wise_data list which contains list of all CVEs"""
0 commit comments