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
19df21e0
Commit
19df21e0
authored
Oct 22, 2020
by
Mehmet Emin INAC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark projects as vulnerable
parent
621b221c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
8 deletions
+28
-8
ee/app/services/security/store_reports_service.rb
ee/app/services/security/store_reports_service.rb
+23
-8
ee/spec/services/security/store_reports_service_spec.rb
ee/spec/services/security/store_reports_service_spec.rb
+4
-0
spec/lib/gitlab/import_export/safe_model_attributes.yml
spec/lib/gitlab/import_export/safe_model_attributes.yml
+1
-0
No files found.
ee/app/services/security/store_reports_service.rb
View file @
19df21e0
...
...
@@ -6,20 +6,35 @@ module Security
class
StoreReportsService
<
::
BaseService
def
initialize
(
pipeline
)
@pipeline
=
pipeline
@errors
=
[]
end
def
execute
errors
=
[]
@pipeline
.
security_reports
.
reports
.
each
do
|
report_type
,
report
|
result
=
StoreReportService
.
new
(
@pipeline
,
report
).
execute
store_reports
mark_project_as_vulnerable
errors
.
any?
?
error
(
full_errors
)
:
success
end
private
attr_reader
:pipeline
,
:errors
delegate
:project
,
to: :pipeline
,
private:
true
def
store_reports
pipeline
.
security_reports
.
reports
.
each
do
|
report_type
,
report
|
result
=
StoreReportService
.
new
(
pipeline
,
report
).
execute
errors
<<
result
[
:message
]
if
result
[
:status
]
==
:error
end
end
if
errors
.
any?
error
(
errors
.
join
(
", "
))
else
success
def
mark_project_as_vulnerable
project
.
project_setting
.
update
(
has_vulnerabilities:
true
)
end
def
full_errors
errors
.
join
(
", "
)
end
end
end
ee/spec/services/security/store_reports_service_spec.rb
View file @
19df21e0
...
...
@@ -33,6 +33,10 @@ RSpec.describe Security::StoreReportsService do
subject
end
it
'marks the project as vulnerable'
do
expect
{
subject
}.
to
change
{
project
.
project_setting
.
has_vulnerabilities
}.
from
(
false
).
to
(
true
)
end
context
'when StoreReportService returns an error for a report'
do
let
(
:reports
)
{
Gitlab
::
Ci
::
Reports
::
Security
::
Reports
.
new
(
pipeline
)
}
let
(
:sast_report
)
{
reports
.
get_report
(
'sast'
,
sast_artifact
)
}
...
...
spec/lib/gitlab/import_export/safe_model_attributes.yml
View file @
19df21e0
...
...
@@ -683,6 +683,7 @@ ProjectCiCdSetting:
ProjectSetting
:
-
allow_merge_on_skipped_pipeline
-
has_confluence
-
has_vulnerabilities
ProtectedEnvironment
:
-
id
-
project_id
...
...
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