Skip to content
Snippets Groups Projects
Commit f46b069c authored by Gioacchino Vino's avatar Gioacchino Vino
Browse files

Improved objects' deletion

parent b7a53394
No related branches found
No related tags found
1 merge request!130Improved objects' deletion
......@@ -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))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment