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

Add method to check if a target finished cleanly or crashed. #133

Merged
merged 1 commit into from
Sep 18, 2019
Merged
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
21 changes: 18 additions & 3 deletions ospd/ospd.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,11 @@ def stop_scan_cleanup(scan_id):
""" Should be implemented by subclass in case of a clean up before
terminating is needed. """

@staticmethod
def target_is_finished(scan_id):
""" Should be implemented by subclass in case of a check before
stopping is needed. """

def exec_scan(self, scan_id, target):
""" Asserts to False. Should be implemented by subclass. """
raise NotImplementedError
Expand Down Expand Up @@ -814,11 +819,21 @@ def check_pending_target(self, scan_id, multiscan_proc):
target_prog = self.get_scan_target_progress(
scan_id, running_target_id
)
if target_prog < 100 and (
self.get_scan_status(scan_id) != ScanStatus.STOPPED):
self.stop_scan(scan_id)

_not_finished_clean = target_prog < 100
_not_stopped = (
self.get_scan_status(scan_id) != ScanStatus.STOPPED
)

if _not_finished_clean and _not_stopped:
if not self.target_is_finished(scan_id):
self.stop_scan(scan_id)
else:
self.set_scan_status(scan_id, ScanStatus.FINISHED)

running_target = (running_target_proc, running_target_id)
multiscan_proc.remove(running_target)

return multiscan_proc

def calculate_progress(self, scan_id):
Expand Down