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

[1.0] Check for malformed credentials. #160

Merged
merged 1 commit into from
Nov 20, 2019
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 @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
- Check the vt's preference value for type 'file'. [#130](https://github.com/greenbone/ospd-openvas/pull/130).
- Add set_nvticache_str(). [#151](https://github.com/greenbone/ospd-openvas/pull/151)
- Check for malformed credentials. [#160](https://github.com/greenbone/ospd-openvas/pull/160).

### Fixed
- Improve redis clean out when stopping a scan. [#128](https://github.com/greenbone/ospd-openvas/pull/128)
Expand Down
20 changes: 16 additions & 4 deletions ospd_openvas/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -1422,13 +1422,22 @@ def exec_scan(self, scan_id, target):
'internal/%s/scanprefs' % openvas_scan_id, [port_range]
)

# If credentials or vts fail, set this variable.
do_not_launch = False

# Set credentials
credentials = self.get_scan_credentials(scan_id, target)
if credentials:
cred_prefs = self.build_credentials_as_prefs(credentials)
self.openvas_db.add_single_item(
'internal/%s/scanprefs' % openvas_scan_id, cred_prefs
)
if cred_prefs:
self.openvas_db.add_single_item(
'internal/%s/scanprefs' % openvas_scan_id, cred_prefs
)
else:
self.add_scan_error(
scan_id, name='', host=target, value='Malformed credential.'
)
do_not_launch = True

# Set plugins to run
nvts = self.get_scan_vts(scan_id)
Expand All @@ -1447,10 +1456,13 @@ def exec_scan(self, scan_id, target):
'internal/%s/scanprefs' % openvas_scan_id, [item]
)
else:
self.openvas_db.release_db(self.main_kbindex)
self.add_scan_error(
scan_id, name='', host=target, value='No VTS to run.'
)
do_not_launch = True

if do_not_launch:
self.openvas_db.release_db(self.main_kbindex)
return 2

cmd = ['openvas', '--scan-start', openvas_scan_id]
Expand Down