Skip to content

Commit

Permalink
Check vt_aux for None before trying to access it.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola committed Jan 13, 2020
1 parent b2a106b commit b923fba
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions ospd_openvas/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,11 +934,12 @@ def get_severity_score(self, vt_aux: dict) -> Optional[float]:
The calculated cvss base value. None if there is no severity
vector or severity type is not cvss base version 2.
"""
severity_type = vt_aux['severities'].get('severity_type')
severity_vector = vt_aux['severities'].get('severity_base_vector')
if vt_aux:
severity_type = vt_aux['severities'].get('severity_type')
severity_vector = vt_aux['severities'].get('severity_base_vector')

if severity_type == "cvss_base_v2" and severity_vector:
return CVSS.cvss_base_v2_value(severity_vector)
if severity_type == "cvss_base_v2" and severity_vector:
return CVSS.cvss_base_v2_value(severity_vector)

return None

Expand All @@ -956,13 +957,14 @@ def get_openvas_result(self, scan_id: str, current_host: str):

if roid and not host_is_dead:
vt_aux = copy.deepcopy(self.vts.get(roid))
if vt_aux.get('qod_type'):
if vt_aux and vt_aux.get('qod_type'):
qod_t = vt_aux.get('qod_type')
rqod = self.nvti.QOD_TYPES[qod_t]
elif vt_aux.get('qod'):
elif vt_aux and vt_aux.get('qod'):
rqod = vt_aux.get('qod')

rname = vt_aux.get('name')
if vt_aux:
rname = vt_aux.get('name')

if msg[0] == 'ERRMSG':
self.add_scan_error(
Expand Down

0 comments on commit b923fba

Please sign in to comment.