Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
06b98532
Commit
06b98532
authored
Aug 09, 2019
by
Tetiana Chupryna
Committed by
Bob Van Landuyt
Aug 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Symbolize keys for vulnerability
Use only symbols everywhere to avoid confusion
parent
b58b8099
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
14 deletions
+19
-14
ee/app/services/security/dependency_list_service.rb
ee/app/services/security/dependency_list_service.rb
+2
-4
ee/lib/gitlab/ci/parsers/security/formatters/dependency_list.rb
.../gitlab/ci/parsers/security/formatters/dependency_list.rb
+11
-4
ee/spec/lib/gitlab/ci/parsers/security/dependency_list_spec.rb
...ec/lib/gitlab/ci/parsers/security/dependency_list_spec.rb
+3
-3
ee/spec/lib/gitlab/ci/parsers/security/formatters/dependency_list_spec.rb
...ab/ci/parsers/security/formatters/dependency_list_spec.rb
+3
-3
No files found.
ee/app/services/security/dependency_list_service.rb
View file @
06b98532
...
@@ -72,10 +72,8 @@ module Security
...
@@ -72,10 +72,8 @@ module Security
# will have highest severity
# will have highest severity
def
sort_by_severity
(
collection
)
def
sort_by_severity
(
collection
)
collection
.
sort
do
|
dep_i
,
dep_j
|
collection
.
sort
do
|
dep_i
,
dep_j
|
vuln_i
=
dep_i
[
:vulnerabilities
]
level_i
=
dep_i
.
dig
(
:vulnerabilities
,
0
,
:severity
)
||
:undefined
vuln_j
=
dep_j
[
:vulnerabilities
]
level_j
=
dep_j
.
dig
(
:vulnerabilities
,
0
,
:severity
)
||
:undefined
level_i
=
vuln_i
.
any?
?
vuln_i
.
first
[
'severity'
].
downcase
:
:undefined
level_j
=
vuln_j
.
any?
?
vuln_j
.
first
[
'severity'
].
downcase
:
:undefined
::
Vulnerabilities
::
Occurrence
::
SEVERITY_LEVELS
[
level_j
]
<=>
::
Vulnerabilities
::
Occurrence
::
SEVERITY_LEVELS
[
level_i
]
::
Vulnerabilities
::
Occurrence
::
SEVERITY_LEVELS
[
level_j
]
<=>
::
Vulnerabilities
::
Occurrence
::
SEVERITY_LEVELS
[
level_i
]
end
end
...
...
ee/lib/gitlab/ci/parsers/security/formatters/dependency_list.rb
View file @
06b98532
...
@@ -37,7 +37,7 @@ module Gitlab
...
@@ -37,7 +37,7 @@ module Gitlab
# https://gitlab.com/gitlab-org/security-products/analyzers/common/blob/a0a5074c49f34332aa3948cd9d6dc2c054cdf3a7/issue/issue.go#L169
# https://gitlab.com/gitlab-org/security-products/analyzers/common/blob/a0a5074c49f34332aa3948cd9d6dc2c054cdf3a7/issue/issue.go#L169
def
location
(
dependency
,
file_path
)
def
location
(
dependency
,
file_path
)
{
{
"file"
=>
file_path
,
'file'
=>
file_path
,
'dependency'
=>
{
'dependency'
=>
{
'package'
=>
{
'package'
=>
{
'name'
=>
dependency
[
'package'
][
'name'
]
'name'
=>
dependency
[
'package'
][
'name'
]
...
@@ -69,9 +69,16 @@ module Gitlab
...
@@ -69,9 +69,16 @@ module Gitlab
def
collect_vulnerabilities
(
vulnerabilities
,
dependency
,
file_path
)
def
collect_vulnerabilities
(
vulnerabilities
,
dependency
,
file_path
)
dependency_location
=
location
(
dependency
,
file_path
)
dependency_location
=
location
(
dependency
,
file_path
)
vulnerabilities
.
select
do
|
vulnerability
|
vulnerabilities
vulnerability
[
'location'
]
==
dependency_location
.
select
{
|
vulnerability
|
vulnerability
[
'location'
]
==
dependency_location
}
.
map
{
|
vulnerability
|
formatted_vulnerability
(
vulnerability
)
}
end
end
def
formatted_vulnerability
(
vulnerability
)
{
name:
vulnerability
[
'name'
],
severity:
vulnerability
[
'severity'
].
downcase
}
end
end
end
end
end
end
...
...
ee/spec/lib/gitlab/ci/parsers/security/dependency_list_spec.rb
View file @
06b98532
...
@@ -37,10 +37,10 @@ describe Gitlab::Ci::Parsers::Security::DependencyList do
...
@@ -37,10 +37,10 @@ describe Gitlab::Ci::Parsers::Security::DependencyList do
vuln_async
=
report
.
dependencies
[
3
][
:vulnerabilities
]
vuln_async
=
report
.
dependencies
[
3
][
:vulnerabilities
]
expect
(
vuln_nokogiri
.
size
).
to
eq
(
4
)
expect
(
vuln_nokogiri
.
size
).
to
eq
(
4
)
expect
(
vuln_nokogiri
[
0
][
'name'
]).
to
eq
(
'Vulnerabilities in libxml2'
)
expect
(
vuln_nokogiri
[
0
][
:name
]).
to
eq
(
'Vulnerabilities in libxml2'
)
expect
(
vuln_nokogiri
[
0
][
'severity'
]).
to
eq
(
'H
igh'
)
expect
(
vuln_nokogiri
[
0
][
:severity
]).
to
eq
(
'h
igh'
)
expect
(
vuln_debug
.
size
).
to
eq
(
1
)
expect
(
vuln_debug
.
size
).
to
eq
(
1
)
expect
(
vuln_debug
[
0
][
'name'
]).
to
eq
(
'Regular Expression Denial of Service'
)
expect
(
vuln_debug
[
0
][
:name
]).
to
eq
(
'Regular Expression Denial of Service'
)
expect
(
vuln_async
.
size
).
to
eq
(
0
)
expect
(
vuln_async
.
size
).
to
eq
(
0
)
end
end
end
end
...
...
ee/spec/lib/gitlab/ci/parsers/security/formatters/dependency_list_spec.rb
View file @
06b98532
...
@@ -43,9 +43,9 @@ describe Gitlab::Ci::Parsers::Security::Formatters::DependencyList do
...
@@ -43,9 +43,9 @@ describe Gitlab::Ci::Parsers::Security::Formatters::DependencyList do
vulnerabilities
=
data
[
:vulnerabilities
]
vulnerabilities
=
data
[
:vulnerabilities
]
expect
(
vulnerabilities
.
size
).
to
eq
(
4
)
expect
(
vulnerabilities
.
size
).
to
eq
(
4
)
expect
(
vulnerabilities
[
0
][
'name'
]).
to
eq
(
'Vulnerabilities in libxml2'
)
expect
(
vulnerabilities
[
0
][
:name
]).
to
eq
(
'Vulnerabilities in libxml2'
)
expect
(
vulnerabilities
[
3
][
'name'
]).
to
eq
(
'Bypass of a protection mechanism in libxslt'
)
expect
(
vulnerabilities
[
3
][
:name
]).
to
eq
(
'Bypass of a protection mechanism in libxslt'
)
expect
(
vulnerabilities
[
0
][
'severity'
]).
to
eq
(
'H
igh'
)
expect
(
vulnerabilities
[
0
][
:severity
]).
to
eq
(
'h
igh'
)
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment