@@ -252,8 +252,7 @@ def fetch_vulncheck_data(cve_id):
252252 config = load_config ()
253253 vulncheck_api_key = config .get ("vulncheck_api_key" )
254254 if not vulncheck_api_key :
255- print ("❌ API key for VulnCheck is not configured correctly." )
256- return None
255+ return {"error" : "API key for VulnCheck is not configured correctly." }
257256
258257 url = VULNCHECK_API_URL
259258 headers = {
@@ -267,52 +266,52 @@ def fetch_vulncheck_data(cve_id):
267266 response .raise_for_status ()
268267 return response .json ()
269268 except requests .exceptions .RequestException as e :
270- print (f"❌ Error fetching data from VulnCheck: { e } " )
271- return None
269+ return {"error" : f"❌ Error fetching data from VulnCheck: { e } " }
272270
273271
274272def display_vulncheck_data (vulncheck_data ):
275273 print ("┌───[ " + BLUE + f"💥 VulnCheck Exploits / PoC " + ENDC + "]" )
276- if vulncheck_data and "data" in vulncheck_data :
277- entries = []
278- for item in vulncheck_data ["data" ]:
279- if "vulncheck_xdb" in item :
280- for xdb in item ["vulncheck_xdb" ]:
281- xdb_id = xdb .get ("xdb_id" , "N/A" )
282-
283- date_added = xdb .get ("date_added" , "N/A" )
284- if date_added != "N/A" :
285- try :
286- date_added = datetime .datetime .fromisoformat (
287- date_added .rstrip ("Z" )
288- ).strftime ("%Y-%m-%d" )
289- except ValueError :
290- pass
291-
292- clone_ssh_url = xdb .get ("clone_ssh_url" , "" )
293- github_url = clone_ssh_url .replace (
294- "[email protected] :" ,
"https://github.com/" 295- ).replace (".git" , "" )
296-
297- entries .append ((xdb_id , date_added , github_url ))
298-
299- if entries :
300- for index , (xdb_id , date_added , github_url ) in enumerate (
301- sorted (entries , key = lambda x : x [1 ], reverse = True )
302- ):
303- print ("|" )
304- print (f"├ ID: { xdb_id } " )
305- print (f"├ Date: { date_added } " )
306- if index == len (entries ) - 1 :
307- print (f"└ URL: { github_url } \n " )
308- else :
309- print (f"└ URL: { github_url } " )
310- else :
274+ if vulncheck_data :
275+ if "error" in vulncheck_data :
311276 print ("|" )
312- print ("└ ❌ No exploit data found.\n " )
277+ print (f"└ ❌ { vulncheck_data ['error' ]} \n " )
278+ elif "data" in vulncheck_data :
279+ entries = []
280+ for item in vulncheck_data ["data" ]:
281+ if "vulncheck_xdb" in item :
282+ for xdb in item ["vulncheck_xdb" ]:
283+ xdb_id = xdb .get ("xdb_id" , "N/A" )
284+ date_added = xdb .get ("date_added" , "N/A" )
285+ if date_added != "N/A" :
286+ try :
287+ date_added = datetime .datetime .fromisoformat (
288+ date_added .rstrip ("Z" )
289+ ).strftime ("%Y-%m-%d" )
290+ except ValueError :
291+ pass
292+ clone_ssh_url = xdb .get ("clone_ssh_url" , "" )
293+ github_url = clone_ssh_url .replace (
294+ "[email protected] :" ,
"https://github.com/" 295+ ).replace (".git" , "" )
296+ entries .append ((xdb_id , date_added , github_url ))
297+
298+ if entries :
299+ for index , (xdb_id , date_added , github_url ) in enumerate (
300+ sorted (entries , key = lambda x : x [1 ], reverse = True )
301+ ):
302+ print ("|" )
303+ print (f"├ ID: { xdb_id } " )
304+ print (f"├ Date: { date_added } " )
305+ if index == len (entries ) - 1 :
306+ print (f"└ URL: { github_url } \n " )
307+ else :
308+ print (f"└ URL: { github_url } " )
309+ else :
310+ print ("|" )
311+ print ("└ ❌ No exploit data found.\n " )
313312 else :
314313 print ("|" )
315- print ("└ ❌ No exploit data found .\n " )
314+ print ("└ ❌ No data received from VulnCheck .\n " )
316315
317316
318317def fetch_exploitdb_data (cve_id ):
0 commit comments