Skip to content

Commit f278aca

Browse files
authored
Merge pull request #72 from jjnicola/create_vts_sel
Raise an error if create_vt_selection receives an invalid argument.
2 parents b63135f + 93a3e9e commit f278aca

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

gvm/protocols/ospv1.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,20 @@ def create_credentials_element(_xmlcredentials, credentials):
5454
def create_vt_selection_element(_xmlvtselection, vt_selection):
5555
"""Generates an xml element with a selection of Vulnerability tests."""
5656
for vt_id, vt_values in vt_selection.items():
57-
if vt_id != 'vt_groups':
57+
if vt_id != 'vt_groups' and isinstance(vt_values, dict):
5858
_xmlvt = _xmlvtselection.add_element('vt_single',
5959
attrs={'id': vt_id})
6060
if vt_values:
6161
for key, value in vt_values.items():
6262
_xmlvt.add_element('vt_value', value, attrs={'id': key})
63-
else:
63+
elif vt_id == 'vt_groups' and isinstance(vt_values, list):
6464
for group in vt_values:
6565
_xmlvt = _xmlvtselection.add_element(
6666
'vt_group', attrs={'filter': group})
67+
else:
68+
raise InvalidArgument(
69+
'It was not possible to add {} to the VTs '
70+
'selection.'.format(vt_id))
6771

6872
return _xmlvtselection
6973

0 commit comments

Comments
 (0)