Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Paas CI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
INFN Cloud
Paas CI
Commits
2dfc7b54
Commit
2dfc7b54
authored
1 year ago
by
Gioacchino Vino
Browse files
Options
Downloads
Patches
Plain Diff
Excluding not relevant issues
parent
5bb6235b
No related branches found
Branches containing commit
No related tags found
1 merge request
!118
Debug paas ci
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
files/read_report.py
+108
-0
108 additions, 0 deletions
files/read_report.py
with
108 additions
and
0 deletions
files/read_report.py
0 → 100644
+
108
−
0
View file @
2dfc7b54
#!/usr/bin/env python3
import
logging
import
json
import
os
from
gvm_library
import
GVMClient
,
ReportFormats
,
pretty_json
from
utilities
import
import_dep_info
,
process_global_reports_info
,
read_not_relevant_issues
import
argparse
### GVM Options ###
WAIT_TIMEOUT
=
3600
#1h
parser
=
argparse
.
ArgumentParser
(
description
=
'
Scan endpoints and machines
'
)
parser
.
add_argument
(
"
--endpoint-keys
"
,
help
=
"
Orchestrator output endpoints to scan (endpoints1,endpoints2)
"
,
default
=
"
None
"
)
parser
.
add_argument
(
"
--dep-json
"
,
default
=
"
./dep.json
"
)
parser
.
add_argument
(
"
--output-dir
"
,
default
=
"
.
"
)
args
=
parser
.
parse_args
()
logging
.
basicConfig
(
filename
=
'
scan.log
'
,
level
=
logging
.
INFO
,
format
=
'
%(asctime)s %(levelname)-8s %(message)s
'
,
datefmt
=
'
%Y-%m-%d %H:%M:%S
'
,
filemode
=
'
w
'
)
logging
.
info
(
"
\n\n
Start scan application
"
)
if
os
.
environ
.
get
(
'
GMP_USER
'
)
is
not
None
and
\
os
.
environ
.
get
(
'
GMP_USER
'
)
!=
''
:
auth_name
=
os
.
getenv
(
'
GMP_USER
'
)
else
:
logging
.
error
(
"
GMP_USER env var is not defined
\n
exit
"
)
raise
Exception
(
"
GMP_USER env var is not defined
"
)
if
os
.
environ
.
get
(
'
GMP_PASSWORD
'
)
is
not
None
and
\
os
.
environ
.
get
(
'
GMP_PASSWORD
'
)
!=
''
:
auth_passwd
=
os
.
getenv
(
'
GMP_PASSWORD
'
)
else
:
logging
.
error
(
"
GMP_PASSWORD env var is not defined
\n
exit
"
)
raise
Exception
(
"
GMP_PASSWORD env var is not defined
"
)
dep_json
=
args
.
dep_json
output_dir
=
args
.
output_dir
logging
.
info
(
f
"
endpoint_keys:
{
args
.
endpoint_keys
}
"
)
logging
.
info
(
f
"
dep_json:
{
dep_json
}
"
)
logging
.
info
(
f
"
output_dir:
{
output_dir
}
"
)
endpoints
=
import_dep_info
(
dep_json
,
args
.
endpoint_keys
)
logging
.
info
(
f
"
endpoints:
{
endpoints
}
"
)
# Create GVM client
gvm_client
=
GVMClient
(
auth_n
=
auth_name
,
auth_p
=
auth_passwd
)
# Print GVM library version
logging
.
info
(
f
"
gvm version:
{
gvm_client
.
get_version
()
}
"
)
reports
=
dict
()
for
host
,
ports
in
endpoints
.
items
():
logging
.
info
(
f
"
endpoint:
{
host
}
:
{
ports
}
"
)
target_name
=
f
"
{
auth_name
}
_target_
{
host
}
"
task_name
=
f
"
{
auth_name
}
_task_
{
host
}
"
port_list_name
=
f
"
{
auth_name
}
_pl_
{
host
}
"
report_filename
=
f
"
{
output_dir
}
/
{
host
}
-report
"
summary_filename
=
f
"
{
output_dir
}
/summary-report.json
"
port_list
=
gvm_client
.
get_or_create_port_list
(
port_list_name
,
ports
)
logging
.
info
(
f
"
Port list:
\n
{
port_list
}
"
)
target
=
gvm_client
.
get_or_create_target
(
target_name
,
host
,
port_list
)
logging
.
info
(
f
"
Target:
\n
{
target
}
"
)
task
=
gvm_client
.
get_or_create_task
(
task_name
,
target
)
logging
.
info
(
f
"
Task:
\n
{
task
}
"
)
issues
=
read_not_relevant_issues
()
print
(
issues
)
if
task
.
status
==
'
New
'
:
task
.
start
()
if
task
.
wait
(
WAIT_TIMEOUT
):
task
.
get_report_info2
()
#del task
#del target
#del port_list
reports
=
process_global_reports_info
(
reports
)
logging
.
info
(
pretty_json
(
reports
))
# Write global reports on file
with
open
(
summary_filename
,
"
w
"
)
as
f
:
f
.
write
(
json
.
dumps
(
reports
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment