fix: Fixed config parsing + results parsing

- Avoiding errors with config field when it is
  empty or the apikey is not set
- Parsing all the results instead of only the
  first one
pull/603/head
chrisr3d 2019-10-31 11:48:59 +01:00
parent c3c6f1a6ea
commit 4f70011edf
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 6 additions and 3 deletions

View File

@ -21,7 +21,10 @@ def handler(q=False):
exploit_summary = ''
vuln_summary = ''
key = request['config'].get('apikey')
if not request.get('config') or not request['config'].get('apikey'):
return {'error': "A Vulners api key is required for this module."}
key = request['config']['apikey']
vulners_api = vulners.Vulners(api_key=key)
vulnerability = request.get('vulnerability')
vulners_document = vulners_api.document(vulnerability)
@ -44,8 +47,8 @@ def handler(q=False):
ai_summary += 'Vulners AI Score is ' + str(vulners_ai_score[0]) + " "
if vulners_exploits:
exploit_summary += " || " + str(len(vulners_exploits[0])) + " Public exploits available:\n "
for exploit in vulners_exploits[0]:
exploit_summary += " || " + str(len(vulners_exploits)) + " Public exploits available:\n "
for exploit in vulners_exploits:
exploit_summary += exploit['title'] + " " + exploit['href'] + "\n "
exploit_summary += "|| Vulnerability Description: " + vuln_summary