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
a4d8d27a
Commit
a4d8d27a
authored
Nov 05, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store reports fix exception
Do not fail if feature is not available, or we cannot parse report
parent
8e03b10f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
6 deletions
+30
-6
ee/app/models/ee/ci/build.rb
ee/app/models/ee/ci/build.rb
+7
-3
ee/lib/gitlab/ci/reports/security/report.rb
ee/lib/gitlab/ci/reports/security/report.rb
+5
-0
ee/spec/models/ci/build_spec.rb
ee/spec/models/ci/build_spec.rb
+18
-3
No files found.
ee/app/models/ee/ci/build.rb
View file @
a4d8d27a
...
...
@@ -57,10 +57,14 @@ module EE
def
collect_security_reports!
(
security_reports
)
each_report
(
::
Ci
::
JobArtifact
::
SECURITY_REPORT_FILE_TYPES
)
do
|
file_type
,
blob
|
next
unless
project
.
feature_available?
(
LICENSED_PARSER_FEATURES
[
file_type
])
security_reports
.
get_report
(
file_type
).
tap
do
|
security_report
|
::
Gitlab
::
Ci
::
Parsers
::
Security
.
fabricate!
(
file_type
).
parse!
(
blob
,
security_report
)
begin
next
unless
project
.
feature_available?
(
LICENSED_PARSER_FEATURES
.
fetch
(
file_type
))
::
Gitlab
::
Ci
::
Parsers
::
Security
.
fabricate!
(
file_type
).
parse!
(
blob
,
security_report
)
rescue
=>
e
security_report
.
error
=
e
end
end
end
end
...
...
ee/lib/gitlab/ci/reports/security/report.rb
View file @
a4d8d27a
...
...
@@ -9,6 +9,7 @@ module Gitlab
attr_reader
:occurrences
attr_reader
:scanners
attr_reader
:identifiers
attr_accessor
:error
def
initialize
(
type
)
@type
=
type
...
...
@@ -17,6 +18,10 @@ module Gitlab
@identifiers
=
{}
end
def
errored?
error
.
present?
end
def
add_scanner
(
params
)
scanner_key
(
params
).
tap
do
|
key
|
scanners
[
key
]
||=
params
...
...
ee/spec/models/ci/build_spec.rb
View file @
a4d8d27a
...
...
@@ -234,7 +234,7 @@ describe Ci::Build do
end
it
'parses blobs and add the results to the report'
do
expect
{
subject
}.
not_to
raise_error
subject
expect
(
security_reports
.
get_report
(
'sast'
).
occurrences
.
size
).
to
eq
(
3
)
end
...
...
@@ -245,10 +245,25 @@ describe Ci::Build do
create
(
:ee_ci_job_artifact
,
:sast_with_corrupted_data
,
job:
job
,
project:
job
.
project
)
end
it
'raises an error'
do
expect
{
subject
}.
to
raise_error
(
::
Gitlab
::
Ci
::
Parsers
::
Security
::
Sast
::
SastParserError
)
it
'stores an error'
do
subject
expect
(
security_reports
.
get_report
(
'sast'
)).
to
be_errored
end
end
end
context
'when there is unsupported file type'
do
before
do
stub_const
(
"Ci::JobArtifact::SECURITY_REPORT_FILE_TYPES"
,
%w[codequality]
)
create
(
:ee_ci_job_artifact
,
:codequality
,
job:
job
,
project:
job
.
project
)
end
it
'stores an error'
do
subject
expect
(
security_reports
.
get_report
(
'codequality'
)).
to
be_errored
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