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

Merge branch 'debug_paas_ci' into 'main'

Debug paas ci

See merge request !50
parents cd002595 7c8291b4
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
......@@ -12,7 +12,7 @@
vars:
paas_ci_test:
template_url: https://baltig.infn.it/infn-cloud/tosca-templates/-/raw/master/jupyter/jupyter_vm.yaml
n_timeout_ticks: 18
n_timeout_ticks: 15
inputs: |
'{ "enable_monitoring": "true", "users": [{"os_user_add_to_sudoers": true, "os_user_name": "scans", "os_user_ssh_public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCmQvE3sXtg4D/KYzhCdP6cICvy5foeSkHenKTisxdGJK8L0cDmV+4k7fIah1GIXrldjQBGWHSTbIj1qRTXG2OPWFxeDoXIN1FyKxwdOgwIfzIRtVq18VZEqt9eOiNUXN8jGoEAgcU7obqXuPqKAndk4tyOnSDuVnfnZWAiesVvWK16GEq0PAxBhJoX3eq501ilsNnJZDMEnvQEgtFuIbADEanrhRV3yaEca+9vFyOQRkyxDF8Gn6P/wZ4oe35bdgXxi/hg8JVKYbDCLlT+Fdi+OC3trRhwCcBSvDFD0ZQ8oLemzUk+732TqR+I8gVjPE9fiNF+/mrj5OX55SDr8Qgf scans"}]}'
endpoints_to_scan: |
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment