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
cf3594f4
Commit
cf3594f4
authored
10 months ago
by
Gioacchino Vino
Browse files
Options
Downloads
Patches
Plain Diff
Added logic accepted/know issues during oid validation
parent
bf93a9b1
No related branches found
No related tags found
1 merge request
!144
Debug paas ci
Pipeline
#169107
passed
10 months ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
files/gvm_library.py
+4
-2
4 additions, 2 deletions
files/gvm_library.py
files/scan.py
+3
-3
3 additions, 3 deletions
files/scan.py
files/utilities.py
+25
-1
25 additions, 1 deletion
files/utilities.py
with
32 additions
and
6 deletions
files/gvm_library.py
+
4
−
2
View file @
cf3594f4
...
@@ -447,7 +447,9 @@ class Task:
...
@@ -447,7 +447,9 @@ class Task:
with
open
(
filename
,
"
wb
"
)
as
fh
:
with
open
(
filename
,
"
wb
"
)
as
fh
:
fh
.
write
(
base64
.
b64decode
(
code
))
fh
.
write
(
base64
.
b64decode
(
code
))
def
get_report_info
(
self
,
issues_to_drop
:
List
[
str
])
->
Dict
:
def
get_report_info
(
self
,
accepted_issues
:
List
[
str
],
known_issues
:
List
[
str
])
->
Dict
:
report
=
dict
()
report
=
dict
()
res
=
self
.
client
.
get_report
(
self
.
report_id
,
res
=
self
.
client
.
get_report
(
self
.
report_id
,
report_format_id
=
ReportFormats
.
anonymous_xml
,
report_format_id
=
ReportFormats
.
anonymous_xml
,
...
@@ -462,7 +464,7 @@ class Task:
...
@@ -462,7 +464,7 @@ class Task:
glob_threat
=
'
None
'
glob_threat
=
'
None
'
for
o
,
s
,
t
,
p
in
zip
(
o_ids
,
severities
,
treats
,
ports
):
for
o
,
s
,
t
,
p
in
zip
(
o_ids
,
severities
,
treats
,
ports
):
logging
.
debug
(
f
"
Detected oid:
{
o
}
, severity:
{
s
}
, threat:
{
t
}
and port:
{
p
}
"
)
logging
.
debug
(
f
"
Detected oid:
{
o
}
, severity:
{
s
}
, threat:
{
t
}
and port:
{
p
}
"
)
if
o
in
issues_to_drop
:
if
(
o
not
in
accepted_issues
)
and
(
o
in
known_issues
):
logging
.
debug
(
f
"
Dropped issue
{
o
}
"
)
logging
.
debug
(
f
"
Dropped issue
{
o
}
"
)
continue
continue
if
p
in
report
:
if
p
in
report
:
...
...
This diff is collapsed.
Click to expand it.
files/scan.py
+
3
−
3
View file @
cf3594f4
...
@@ -5,7 +5,7 @@ import json
...
@@ -5,7 +5,7 @@ import json
import
os
import
os
from
gvm_library
import
GVMClient
,
ReportFormats
,
GvmException
,
pretty_json
from
gvm_library
import
GVMClient
,
ReportFormats
,
GvmException
,
pretty_json
from
gvm_library
import
PortList
,
Task
,
Target
from
gvm_library
import
PortList
,
Task
,
Target
from
utilities
import
import_dep_info
,
process_global_reports_info
,
read_
not_relevant_
issues
from
utilities
import
import_dep_info
,
process_global_reports_info
,
read_issues
import
argparse
import
argparse
### GVM Options ###
### GVM Options ###
...
@@ -79,7 +79,7 @@ gvm = GVMClient(auth_n = auth_name, auth_p = auth_passwd)
...
@@ -79,7 +79,7 @@ gvm = GVMClient(auth_n = auth_name, auth_p = auth_passwd)
logging
.
info
(
f
"
gvm version:
{
gvm
.
get_version
()
}
"
)
logging
.
info
(
f
"
gvm version:
{
gvm
.
get_version
()
}
"
)
# Retrieve issues irrelevant for INFN
# Retrieve issues irrelevant for INFN
issues_to_drop
=
read_not_relevant
_issues
()
accepted_issues
,
known_issues
=
read
_issues
()
tasks
=
list
()
tasks
=
list
()
targets
=
list
()
targets
=
list
()
...
@@ -124,7 +124,7 @@ for host,ports in endpoints.items():
...
@@ -124,7 +124,7 @@ for host,ports in endpoints.items():
filename
=
f
"
{
report_filename
}
.pdf
"
)
filename
=
f
"
{
report_filename
}
.pdf
"
)
task
.
save_report
(
format
=
ReportFormats
.
txt
,
task
.
save_report
(
format
=
ReportFormats
.
txt
,
filename
=
f
"
{
report_filename
}
.txt
"
)
filename
=
f
"
{
report_filename
}
.txt
"
)
reports
[
host
]
=
task
.
get_report_info
(
issues_to_drop
)
reports
[
host
]
=
task
.
get_report_info
(
accepted_issues
,
known_issues
)
else
:
else
:
reports
[
host
]
=
{
'
global
'
:
{
"
severity
"
:
-
1
,
"
threat
"
:
f
"
Scan Error. task.id:
{
task
.
id
}
"
}
}
reports
[
host
]
=
{
'
global
'
:
{
"
severity
"
:
-
1
,
"
threat
"
:
f
"
Scan Error. task.id:
{
task
.
id
}
"
}
}
...
...
This diff is collapsed.
Click to expand it.
files/utilities.py
+
25
−
1
View file @
cf3594f4
import
json
import
json
import
logging
import
logging
from
typing
import
Dict
,
List
from
typing
import
Dict
,
List
,
Tuple
import
git
import
git
import
os
import
os
...
@@ -74,4 +74,28 @@ def read_not_relevant_issues() -> List[str]:
...
@@ -74,4 +74,28 @@ def read_not_relevant_issues() -> List[str]:
with
open
(
file_path
,
'
r
'
)
as
file
:
with
open
(
file_path
,
'
r
'
)
as
file
:
return
[
line
.
strip
()
for
line
in
file
.
readlines
()
if
not
line
.
startswith
(
'
#
'
)]
return
[
line
.
strip
()
for
line
in
file
.
readlines
()
if
not
line
.
startswith
(
'
#
'
)]
def
read_issues
()
->
Tuple
[
List
[
str
],
List
[
str
]]:
git_sec_user
=
os
.
environ
.
get
(
"
GIT_SEC_USER
"
)
git_sec_token
=
os
.
environ
.
get
(
"
GIT_SEC_TOKEN
"
)
git_repo
=
"
baltig.infn.it/infn-cloud/security-scans.git
"
repo_url
=
f
"
https://
{
git_sec_user
}
:
{
git_sec_token
}
@
{
git_repo
}
"
destination_folder
=
'
repo
'
git
.
Repo
.
clone_from
(
repo_url
,
destination_folder
)
accepted_file_paths
=
[
'
repo/queues/accepted.txt
'
]
known_file_path
=
[
'
repo/queues/held.txt
'
,
'
repo/queues/new.txt
'
,
'
repo/queues/overridden.txt
'
]
accepted_issues
=
[]
known_issues
=
[]
for
f
in
accepted_file_paths
:
with
open
(
f
,
'
r
'
)
as
file
:
accepted_issues
+=
[
line
.
strip
()
for
line
in
file
.
readlines
()
if
not
line
.
startswith
(
'
#
'
)]
for
f
in
known_file_path
:
with
open
(
f
,
'
r
'
)
as
file
:
known_issues
+=
[
line
.
strip
()
for
line
in
file
.
readlines
()
if
not
line
.
startswith
(
'
#
'
)]
return
accepted_issues
,
known_issues
\ No newline at end of file
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