diff --git a/files/scan.py b/files/scan.py index 4ad8cd2eab093c05b9901ca71b734fc73178ccc2..671eb2f275559658e1d57228236c5db12c824c6e 100644 --- a/files/scan.py +++ b/files/scan.py @@ -8,7 +8,7 @@ from utilities import import_dep_info, process_global_reports_info, read_not_rel import argparse ### GVM Options ### -WAIT_TIMEOUT = 3600 #1h +WAIT_TIMEOUT = 7200 #1h parser = argparse.ArgumentParser( description='Scan endpoints and machines') @@ -72,6 +72,10 @@ logging.info(f"gvm version: {gvm_client.get_version()}") # Retrieve issues irrelevant for INFN issues_to_drop = read_not_relevant_issues() +tasks = list() +targets = list() +port_lists = list() + reports = dict() for host,ports in endpoints.items(): logging.info(f"endpoint: {host}:{ports}") @@ -90,6 +94,10 @@ for host,ports in endpoints.items(): task = gvm_client.get_or_create_task(task_name, target) logging.info(f"Task:\n {task}") + + tasks.append(task) + targets.append(target) + port_lists.append(port_list) if task.status == 'New': task.start() @@ -101,21 +109,24 @@ for host,ports in endpoints.items(): reports[host] = task.get_report_info(issues_to_drop) else: reports[host] = {'global': {"severity": -1, "threat": f"Scan Error. task.id: {task.id}"} } - + +for task in tasks: try: del task - except Exception: - pass + except Exception as e: + logging.error(f"Error during task deletion. Msg: {e.msg}") +for target in targets: try: del target - except Exception: - pass + except Exception as e: + logging.error(f"Error during target deletion. Msg: {e.msg}") +for port_list in port_lists: try: del port_list - except Exception: - pass + except Exception as e: + logging.error(f"Error during port list deletion. Msg: {e.msg}") reports = process_global_reports_info(reports) logging.info(pretty_json(reports))