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

Enabled logs

parent 4e6e9fef
No related branches found
No related tags found
1 merge request!50Debug paas ci
......@@ -32,7 +32,7 @@ def create_connection():
def get_version():
gmp = create_connection()
res = gmp.get_version()
pretty_print(res)
return res
########## PORT LIST ##################################
......@@ -375,8 +375,8 @@ def process_global_severity(severities):
severities['global'] = "NOK"
return severities
def print_pretty_json(j):
print(json.dumps(j,sort_keys=True,indent=4))
def pretty_json(j):
return json.dumps(j,sort_keys=True,indent=4)
def import_dep_info(file_path, endpoints_to_scan):
with open(file_path) as f:
......@@ -424,22 +424,24 @@ if len(argv) != 4:
print("- output directory [/home/gmp/workspace]")
exit(1)
logging.info(f'Configured Scans endpoint: {local_ip}')
endpoints_to_scan = argv[1].split(',')
dep_json = argv[2]
output_dir = argv[3]
print("endpoints_to_scan", endpoints_to_scan)
print("dep_json", dep_json)
print("output_dir", output_dir)
logging.info(f"endpoints_to_scan: {endpoints_to_scan}")
logging.info(f"dep_json: {dep_json}")
logging.info(f"output_dir: {output_dir}")
endpoints = import_dep_info(dep_json, endpoints_to_scan)
#print_pretty_json(endpoints)
logging.info(f"endpoints\n{pretty_json(endpoints)}")
# test gmp connection
get_version()
logging.info(f"gvm version: {get_version()}")
severities = dict()
for host,ports in endpoints.items():
print(host,ports)
logging.info(host,ports)
target_name = f"{auth_name}_target_{host}"
task_name = f"{auth_name}_task_{host}"
......@@ -448,11 +450,14 @@ for host,ports in endpoints.items():
severity_filename = f"{output_dir}/severity.json"
port_list = get_or_create_port_list(port_list_name,ports)
print_pretty_json(port_list)
logging.info(f"Port list:\n {pretty_json(port_list)}")
target = get_or_create_target(target_name,host,port_list,ovs_ssh_credential)
print_pretty_json(target)
logging.info(f"Target:\n {pretty_json(target)}")
task = get_or_create_task(task_name, config, target,scanner)
print_pretty_json(task)
logging.info(f"Task:\n {pretty_json(task)}")
if task['status'] == 'New':
task = start_task(task)
if wait_for_task_ending(task,wait_timeout):
......@@ -460,6 +465,7 @@ for host,ports in endpoints.items():
severities[host] = get_severity(task)
else:
severities[host] = f"ERROR Task: {task['id']}"
delete_task(task)
delete_target(target)
delete_port_list(port_list)
......@@ -467,3 +473,4 @@ for host,ports in endpoints.items():
severities = process_global_severity(severities)
with open(severity_filename, "w") as f:
f.write(json.dumps(severities))
\ No newline at end of file
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