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
bedd5200
Commit
bedd5200
authored
Sep 24, 2019
by
Can Eldem
Committed by
Rémy Coutable
Sep 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor error handling for report comparison
Update test for failure case Add protection for nil pipeline
parent
be156e6f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
9 deletions
+28
-9
ee/app/finders/security/pipeline_vulnerabilities_finder.rb
ee/app/finders/security/pipeline_vulnerabilities_finder.rb
+4
-6
ee/spec/services/ci/compare_container_scanning_reports_service_spec.rb
...ces/ci/compare_container_scanning_reports_service_spec.rb
+8
-1
ee/spec/services/ci/compare_dependency_scanning_reports_service_spec.rb
...es/ci/compare_dependency_scanning_reports_service_spec.rb
+8
-1
ee/spec/services/ci/compare_license_management_reports_service_spec.rb
...ces/ci/compare_license_management_reports_service_spec.rb
+8
-1
No files found.
ee/app/finders/security/pipeline_vulnerabilities_finder.rb
View file @
bedd5200
...
@@ -24,24 +24,22 @@ module Security
...
@@ -24,24 +24,22 @@ module Security
end
end
def
execute
def
execute
pipeline_reports
.
each_with_object
([])
do
|
(
type
,
report
),
occurrences
|
pipeline_reports
&
.
each_with_object
([])
do
|
(
type
,
report
),
occurrences
|
next
unless
requested_type?
(
type
)
next
unless
requested_type?
(
type
)
raise
ParseError
,
'JSON parsing failed'
if
report
.
error
.
is_a?
(
Gitlab
::
Ci
::
Parsers
::
Security
::
Common
::
SecurityReportParserError
)
normalized_occurrences
=
normalize_report_occurrences
(
report
.
occurrences
)
normalized_occurrences
=
normalize_report_occurrences
(
report
.
occurrences
)
filtered_occurrences
=
filter
(
normalized_occurrences
)
filtered_occurrences
=
filter
(
normalized_occurrences
)
occurrences
.
concat
(
filtered_occurrences
)
occurrences
.
concat
(
filtered_occurrences
)
end
end
# Created follow-up issue to better handle exception case - https://gitlab.com/gitlab-org/gitlab/issues/14007
rescue
NoMethodError
=>
_
# propagate error for CompareReportsBaseService
raise
ParseError
,
'JSON parsing failed'
end
end
private
private
def
pipeline_reports
def
pipeline_reports
pipeline
.
security_reports
.
reports
pipeline
&
.
security_reports
&
.
reports
end
end
def
normalize_report_occurrences
(
report_occurrences
)
def
normalize_report_occurrences
(
report_occurrences
)
...
...
ee/spec/services/ci/compare_container_scanning_reports_service_spec.rb
View file @
bedd5200
...
@@ -59,13 +59,20 @@ describe Ci::CompareContainerScanningReportsService do
...
@@ -59,13 +59,20 @@ describe Ci::CompareContainerScanningReportsService do
end
end
context
'when head pipeline has corrupted container scanning vulnerability reports'
do
context
'when head pipeline has corrupted container scanning vulnerability reports'
do
let!
(
:base_pipeline
)
{
nil
}
let!
(
:base_pipeline
)
{
create
(
:ee_ci_pipeline
,
:with_corrupted_container_scanning_report
,
project:
project
)
}
let!
(
:head_pipeline
)
{
create
(
:ee_ci_pipeline
,
:with_corrupted_container_scanning_report
,
project:
project
)
}
let!
(
:head_pipeline
)
{
create
(
:ee_ci_pipeline
,
:with_corrupted_container_scanning_report
,
project:
project
)
}
it
'returns status and error message'
do
it
'returns status and error message'
do
expect
(
subject
[
:status
]).
to
eq
(
:error
)
expect
(
subject
[
:status
]).
to
eq
(
:error
)
expect
(
subject
[
:status_reason
]).
to
include
(
'JSON parsing failed'
)
expect
(
subject
[
:status_reason
]).
to
include
(
'JSON parsing failed'
)
end
end
it
'returns status and error message when pipeline is nil'
do
result
=
service
.
execute
(
nil
,
head_pipeline
)
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:status_reason
]).
to
include
(
'JSON parsing failed'
)
end
end
end
end
end
end
end
ee/spec/services/ci/compare_dependency_scanning_reports_service_spec.rb
View file @
bedd5200
...
@@ -61,13 +61,20 @@ describe Ci::CompareDependencyScanningReportsService do
...
@@ -61,13 +61,20 @@ describe Ci::CompareDependencyScanningReportsService do
end
end
context
'when head pipeline has corrupted dependency scanning vulnerability reports'
do
context
'when head pipeline has corrupted dependency scanning vulnerability reports'
do
let!
(
:base_pipeline
)
{
nil
}
let!
(
:base_pipeline
)
{
create
(
:ee_ci_pipeline
,
:with_corrupted_dependency_scanning_report
,
project:
project
)
}
let!
(
:head_pipeline
)
{
create
(
:ee_ci_pipeline
,
:with_corrupted_dependency_scanning_report
,
project:
project
)
}
let!
(
:head_pipeline
)
{
create
(
:ee_ci_pipeline
,
:with_corrupted_dependency_scanning_report
,
project:
project
)
}
it
'returns status and error message'
do
it
'returns status and error message'
do
expect
(
subject
[
:status
]).
to
eq
(
:error
)
expect
(
subject
[
:status
]).
to
eq
(
:error
)
expect
(
subject
[
:status_reason
]).
to
include
(
'JSON parsing failed'
)
expect
(
subject
[
:status_reason
]).
to
include
(
'JSON parsing failed'
)
end
end
it
'returns status and error message when pipeline is nil'
do
result
=
service
.
execute
(
nil
,
head_pipeline
)
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:status_reason
]).
to
include
(
'JSON parsing failed'
)
end
end
end
end
end
end
end
ee/spec/services/ci/compare_license_management_reports_service_spec.rb
View file @
bedd5200
...
@@ -50,13 +50,20 @@ describe Ci::CompareLicenseManagementReportsService do
...
@@ -50,13 +50,20 @@ describe Ci::CompareLicenseManagementReportsService do
end
end
context
'when head pipeline has corrupted license management reports'
do
context
'when head pipeline has corrupted license management reports'
do
let!
(
:base_pipeline
)
{
nil
}
let!
(
:base_pipeline
)
{
create
(
:ee_ci_pipeline
,
:with_corrupted_license_management_report
,
project:
project
)
}
let!
(
:head_pipeline
)
{
create
(
:ee_ci_pipeline
,
:with_corrupted_license_management_report
,
project:
project
)
}
let!
(
:head_pipeline
)
{
create
(
:ee_ci_pipeline
,
:with_corrupted_license_management_report
,
project:
project
)
}
it
'returns status and error message'
do
it
'returns status and error message'
do
expect
(
subject
[
:status
]).
to
eq
(
:error
)
expect
(
subject
[
:status
]).
to
eq
(
:error
)
expect
(
subject
[
:status_reason
]).
to
include
(
'JSON parsing failed'
)
expect
(
subject
[
:status_reason
]).
to
include
(
'JSON parsing failed'
)
end
end
it
'returns status and error message when pipeline is nil'
do
result
=
service
.
execute
(
nil
,
head_pipeline
)
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:status_reason
]).
to
include
(
'JSON parsing failed'
)
end
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