Fix xml parser when host is up but not ports are open (#46). Also fix error when getting description from the cache. The entire vuln description object should be saved in the cache not just the string of the description. Also added all __pycache__ files to gitignore

This commit is contained in:
Nadin El-Yabroudi
2020-03-10 10:15:09 -07:00
parent 0240604f99
commit b73f07b9fb
3 changed files with 5 additions and 3 deletions
+1
View File
@@ -0,0 +1 @@
__pycache__
+3 -2
View File
@@ -29,8 +29,9 @@ class CveProjectProvider(VulnDescriptionProvider):
response.raise_for_status()
cve_json = response.json()
description = cve_json['description']['description_data'][0]['value']
self.cache[vuln] = description
return VulnDescription(description, self.nist_uri_template.format(vuln))
vuln_description = VulnDescription(description, self.nist_uri_template.format(vuln))
self.cache[vuln] = vuln_description
return vuln_description
except HTTPError as he:
return VulnDescription('', 'Description fetching error: ' + str(he))
+1 -1
View File
@@ -113,7 +113,7 @@ class FlanXmlParser:
if not ip_addr:
return
if host['status']['@state'] == 'up' and 'port' in host['ports']:
if host['status']['@state'] == 'up' and 'ports' in host.keys() and 'port' in host['ports']:
ports = host['ports']['port']
if isinstance(ports, list):
for p in ports: