Merge pull request #335 from FafnerKeyZee/patch-2

Travis should not be complaining with the tests after the latest update on "test_cve"
pull/338/head
Christian Studer 2019-09-17 14:11:03 +02:00 committed by GitHub
commit 205342996a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -3,10 +3,12 @@ import requests
misperrors = {'error': 'Error'}
mispattributes = {'input': ['vulnerability'], 'output': ['text']}
moduleinfo = {'version': '0.2', 'author': 'Alexandre Dulaunoy', 'description': 'An expansion hover module to expand information about CVE id.', 'module-type': ['hover']}
moduleconfig = []
moduleinfo = {'version': '0.3', 'author': 'Alexandre Dulaunoy', 'description': 'An expansion hover module to expand information about CVE id.', 'module-type': ['hover']}
moduleconfig = ["custom_API"]
cveapi_url = 'https://cve.circl.lu/api/cve/'
def check_url(url):
return "{}/".format(url) if not url.endswith('/') else url
def handler(q=False):
if q is False:
@ -16,7 +18,8 @@ def handler(q=False):
misperrors['error'] = 'Vulnerability id missing'
return misperrors
r = requests.get(cveapi_url + request.get('vulnerability'))
api_url = check_url(request['config']['custom_API']) if request['config'].get('custom_API') else cveapi_url
r = requests.get("{}{}".format(api_url, request.get('vulnerability')))
if r.status_code == 200:
vulnerability = json.loads(r.text)
if vulnerability:
@ -25,7 +28,7 @@ def handler(q=False):
else:
summary = 'Non existing CVE'
else:
misperrors['error'] = 'cve.circl.lu API not accessible'
misperrors['error'] = 'API not accessible'
return misperrors['error']
r = {'results': [{'types': mispattributes['output'], 'values': summary}]}