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

Send messages generated by the scanner main process. #171

Merged
merged 1 commit into from
Dec 3, 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 @@ -9,6 +9,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).
- Check for malformed credentials. [#160](https://github.com/greenbone/ospd-openvas/pull/160).
- Send messages generated by the scannner main process. [#171](https://github.com/greenbone/ospd-openvas/pull/171).

### Changed
- Less strict checks for the nvti cache version.
Expand Down
7 changes: 4 additions & 3 deletions ospd_openvas/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,13 +925,13 @@ def get_openvas_result(self, scan_id, current_host):
res = self.openvas_db.get_result()
while res:
msg = res.split('|||')
roid = msg[3]
roid = msg[3].strip()
rqod = ''
rname = ''
rhostname = msg[1] if msg[1] else ''
rhostname = msg[1].strip() if msg[1] else ''
host_is_dead = "Host dead" in msg[4]

if not host_is_dead:
if roid and not host_is_dead:
if self.vts[roid].get('qod_type'):
qod_t = self.vts[roid].get('qod_type')
rqod = self.nvti.QOD_TYPES[qod_t]
Expand Down Expand Up @@ -1507,6 +1507,7 @@ def exec_scan(self, scan_id, target):

ctx = self.openvas_db.kb_connect(self.main_kbindex)
self.openvas_db.set_redisctx(ctx)
self.get_openvas_result(scan_id, "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method name is confusing. A better name would be something like collect_results_from_openvas.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will do it.

dbs = self.openvas_db.get_list_item('internal/dbindex')
for i in list(dbs):
if i == self.main_kbindex:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,11 +698,11 @@ def test_get_openvas_result(self, mock_ospd, mock_nvti, mock_db):
mock_ospd.assert_called_with(
'123-456',
host='localhost',
hostname=' ',
hostname='',
name='',
port='general/Host_Details',
qod='',
test_id=' ',
test_id='',
value='Host dead',
)

Expand Down