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
6be08132
Commit
6be08132
authored
Oct 08, 2019
by
celdem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix nil error when comparing reports
parent
da72dc6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
8 deletions
+26
-8
ee/lib/gitlab/ci/reports/security/vulnerability_reports_comparer.rb
...lab/ci/reports/security/vulnerability_reports_comparer.rb
+3
-3
ee/spec/lib/gitlab/ci/reports/security/vulnerability_reports_comparer_spec.rb
...i/reports/security/vulnerability_reports_comparer_spec.rb
+23
-5
No files found.
ee/lib/gitlab/ci/reports/security/vulnerability_reports_comparer.rb
View file @
6be08132
...
...
@@ -9,9 +9,9 @@ module Gitlab
attr_reader
:base_report
,
:head_report
def
initialize
(
base_report
=
[],
head_report
=
[]
)
@base_report
=
base_report
@head_report
=
head_report
def
initialize
(
base_report
,
head_report
)
@base_report
=
base_report
||
[]
@head_report
=
head_report
||
[]
end
def
added
...
...
ee/spec/lib/gitlab/ci/reports/security/vulnerability_reports_comparer_spec.rb
View file @
6be08132
...
...
@@ -52,12 +52,30 @@ describe Gitlab::Ci::Reports::Security::VulnerabilityReportsComparer do
end
describe
'with empty vulnerabilities'
do
let
(
:comparer
)
{
described_class
.
new
}
it
'returns empty array when reports are not present'
do
expect
(
comparer
.
existing
).
to
be_empty
expect
(
comparer
.
fixed
).
to
be_empty
expect
(
comparer
.
added
).
to
be_empty
comparer
=
described_class
.
new
(
nil
,
nil
)
expect
(
comparer
.
existing
).
to
eq
([])
expect
(
comparer
.
fixed
).
to
eq
([])
expect
(
comparer
.
added
).
to
eq
([])
end
it
'returns added vulnerability when base is empty and head is not empty'
do
vuln
=
build
(
:vulnerabilities_occurrence
,
report_type: :sast
,
identifiers:
[
identifier
],
location_fingerprint:
'888'
)
comparer
=
described_class
.
new
(
nil
,
[
vuln
])
expect
(
comparer
.
existing
).
to
eq
([])
expect
(
comparer
.
fixed
).
to
eq
([])
expect
(
comparer
.
added
).
to
eq
([
vuln
])
end
it
'returns fixed vulnerability when head is empty and base is not empty'
do
vuln
=
build
(
:vulnerabilities_occurrence
,
report_type: :sast
,
identifiers:
[
identifier
],
location_fingerprint:
'888'
)
comparer
=
described_class
.
new
([
vuln
],
nil
)
expect
(
comparer
.
existing
).
to
eq
([])
expect
(
comparer
.
fixed
).
to
eq
([
vuln
])
expect
(
comparer
.
added
).
to
eq
([])
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