Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Improve handling of dead hosts and improve scan progress calculation #266

Merged
merged 15 commits into from
May 11, 2020

Conversation

jjnicola
Copy link
Member

@jjnicola jjnicola commented May 8, 2020

Dead host can be set directly as dead, or can be recognized as dead if the scan progress is -1

The list of finished hosts is not kept anymore, and therefore support for resume task is removed.

Only the amount of finished hosts (alive or dead) are stored and the scan progress calculation has been changed. The dead host are not taken in account for calculation.

A new attribute "progress" is added for <get_scans> to get more information about the scan progress. Per default is disabled.
Usage example:

<get_scans details='0' progress='1'/>

…progress.

This reduce the amount of data stored, since only are stored the current scanned hosts,
and the finished hosts are just count as dead or alive.
Add/modify the methods to handle the finished hosts.
Remove the method to get finish/unfinished hosts, since they are not stored as single host anymore.
As the finished hosts are not stored anymore, the resume task depends
on the client.
The amount of finished hosts received in the target element are taken in account
in the progress calculation.
A host can be added as dead directly to the dead host count in the scan table
or can be set as dead because the scan progress of the host is -1

A scanner, like openvas, can scan a host and set the host as dead at the end.
In this case in which a host is alive until it is recognize as dead, this options
are useful.
To get more details use the progress attribute. It is false per default.
Resume scan by ospd is not supported and must be handle in the client side.
Stopped scans can not be restarted anymore.
@codecov
Copy link

codecov bot commented May 11, 2020

Codecov Report

Merging #266 into master will increase coverage by 0.58%.
The diff coverage is 94.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #266      +/-   ##
==========================================
+ Coverage   73.92%   74.51%   +0.58%     
==========================================
  Files          21       21              
  Lines        2309     2315       +6     
==========================================
+ Hits         1707     1725      +18     
+ Misses        602      590      -12     
Impacted Files Coverage Δ
ospd/scan.py 90.90% <93.10%> (+1.71%) ⬆️
ospd/ospd.py 76.76% <93.75%> (+1.13%) ⬆️
ospd/command/command.py 86.62% <100.00%> (+0.87%) ⬆️
ospd/xml.py 91.73% <100.00%> (+1.08%) ⬆️
ospd/protocol.py 94.56% <0.00%> (-1.09%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2a0c91a...79c6388. Read the comment docs.

@jjnicola jjnicola marked this pull request as ready for review May 11, 2020 10:26
Copy link
Contributor

@bjoernricks bjoernricks left a comment

Choose a reason for hiding this comment

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

Looks good. Just some small things

ospd/command/command.py Outdated Show resolved Hide resolved
ospd/ospd.py Show resolved Hide resolved
ospd/ospd.py Outdated
@@ -711,6 +700,32 @@ def get_scan_results_xml(
logger.debug('Returning %d results', len(results))
return results

def get_scan_progress_xml(self, scan_id: str):
Copy link
Contributor

Choose a reason for hiding this comment

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

Personally I don't think this method should be in the daemon class but currently i can't find a better place at the moment. XML creation should not be part of the daemon class at all. Maybe just mark it as private for now by changing the name to _get_scan_progress_xml

@bjoernricks bjoernricks merged commit 6786774 into greenbone:master May 11, 2020
@jjnicola jjnicola deleted the dead-host branch May 11, 2020 12:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants