-
Notifications
You must be signed in to change notification settings - Fork 36
Improve handling of dead hosts and improve scan progress calculation #266
Conversation
…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 Report
@@ 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
Continue to review full report at Codecov.
|
There was a problem hiding this 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/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): |
There was a problem hiding this comment.
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
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'/>