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

Test alive hosts only #204

Merged
merged 3 commits into from
Mar 3, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Check if the amount of vts in redis is coherent.
[#195](https://github.com/greenbone/ospd-openvas/pull/195)
[#197](https://github.com/greenbone/ospd-openvas/pull/197)
- Add support for test_alive_hosts_only feature of openvas. [#204](https://github.com/greenbone/ospd-openvas/pull/204)

### Changed
- Less strict checks for the nvti cache version
Expand Down
28 changes: 28 additions & 0 deletions ospd_openvas/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,34 @@ def exec_scan(self, scan_id: str):
# Set alive test option. Overwrite the scan config settings.
target_options = self.get_scan_target_options(scan_id)
if target_options:
# Check if test_alive_hosts_only feature of openvas is active.
# If active, put ALIVE_TEST enum in preferences.
settings = Openvas.get_settings()
if settings:
test_alive_hosts_only = settings.get(
'test_alive_hosts_only'
)
if test_alive_hosts_only:
if target_options and target_options.get('alive_test'):
try:
alive_test = int(
target_options.get('alive_test')
)
except ValueError:
logger.debug(
'Alive test settings not applied. '
'Invalid alive test value %s',
target_options.get('alive_test'),
)
# Put ALIVE_TEST enum in db, this is then taken
# by openvas to determine the method to use
# for the alive test.
if alive_test >= 1 and alive_test <= 31:
item = 'ALIVE_TEST|||%s' % str(alive_test)
kbdb.add_scan_preferences(
openvas_scan_id, [item]
)

alive_test_opt = self.build_alive_test_opt_as_prefs(
target_options
)
Expand Down