Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for empty vts preferences list #340

Merged
merged 1 commit into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ospd_openvas/preferencehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ def prepare_nvt_preferences(self):
items_list = []
for key, val in self._nvts_params.items():
items_list.append('%s|||%s' % (key, val))
self.kbdb.add_scan_preferences(self._openvas_scan_id, items_list)

if items_list:
self.kbdb.add_scan_preferences(self._openvas_scan_id, items_list)

@staticmethod
def build_alive_test_opt_as_prefs(
Expand Down
12 changes: 12 additions & 0 deletions tests/test_preferencehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,3 +583,15 @@ def test_prepare_nvt_prefs(self, mock_kb):
p._openvas_scan_id,
alive_test_out,
)

@patch('ospd_openvas.db.KbDB')
def test_prepare_nvt_prefs_no_prefs(self, mock_kb):
w = DummyDaemon()

p = PreferenceHandler('456-789', mock_kb, w.scan_collection, None)
p._nvts_params = {}
p._openvas_scan_id = '456-789'
p.kbdb.add_scan_preferences = MagicMock()
p.prepare_nvt_preferences()

p.kbdb.add_scan_preferences.assert_not_called()