diff --git a/ospd/ospd.py b/ospd/ospd.py index 584c39c1..1cc8423c 100644 --- a/ospd/ospd.py +++ b/ospd/ospd.py @@ -505,25 +505,21 @@ def handle_client_stream(self, stream: Stream) -> None: stream.close() - def process_finished_hosts(self, scan_id: str, finished_hosts: str) -> None: + def process_finished_hosts(self, scan_id: str) -> None: """ Process the finished hosts before launching the scans.""" + finished_hosts = self.scan_collection.get_finished_hosts(scan_id) if not finished_hosts: return exc_finished_hosts_list = target_str_to_list(finished_hosts) self.scan_collection.set_host_finished(scan_id, exc_finished_hosts_list) - def start_scan(self, scan_id: str, target: Dict) -> None: + def start_scan(self, scan_id: str) -> None: """ Starts the scan with scan_id. """ os.setsid() - if target is None or not target: - raise OspdCommandError('Erroneous target', 'start_scan') - - logger.info("%s: Scan started.", scan_id) - - self.process_finished_hosts(scan_id, target.get('finished_hosts')) + self.process_finished_hosts(scan_id) try: self.set_scan_status(scan_id, ScanStatus.RUNNING) @@ -1188,11 +1184,12 @@ def run(self) -> None: def start_pending_scans(self): for scan_id in self.scan_collection.ids_iterator(): if self.get_scan_status(scan_id) == ScanStatus.PENDING: - scan_target = self.scan_collection.get_target(scan_id) + scan_func = self.start_scan - scan_process = create_process( - func=scan_func, args=(scan_id, scan_target) - ) + + print(scan_id) + scan_process = create_process(func=scan_func, args=(scan_id,)) + self.scan_processes[scan_id] = scan_process scan_process.start() self.set_scan_status(scan_id, ScanStatus.INIT) diff --git a/ospd/scan.py b/ospd/scan.py index 94449fc4..3d790651 100644 --- a/ospd/scan.py +++ b/ospd/scan.py @@ -378,12 +378,6 @@ def get_target_options(self, scan_id: str) -> Dict[str, str]: """ return self.scans_table[scan_id]['target'].get('options') - def get_target( - self, scan_id: str - ) -> Dict[str, Union[str, Dict[str, Union[str, Dict[str, str]]]]]: - """ Get the complete target info""" - return self.scans_table[scan_id].get('target') - def get_vts(self, scan_id: str) -> Dict[str, Union[Dict[str, str], List]]: """ Get a scan's vts. """ scan_info = self.scans_table[scan_id]