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
567bfb5e
Commit
567bfb5e
authored
Jun 28, 2019
by
Avielle Wolfe
Committed by
Avielle Wolfe
Jul 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Naive extraction of vulnerabilities actions
Next step: smooth this puppy out
parent
f16f315d
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
425 additions
and
409 deletions
+425
-409
ee/app/controllers/concerns/ee/vulnerabilities_actions.rb
ee/app/controllers/concerns/ee/vulnerabilities_actions.rb
+53
-0
ee/app/controllers/groups/security/vulnerabilities_controller.rb
...controllers/groups/security/vulnerabilities_controller.rb
+1
-45
ee/spec/controllers/groups/security/vulnerabilities_controller_spec.rb
...ollers/groups/security/vulnerabilities_controller_spec.rb
+1
-364
ee/spec/support/shared_examples/controllers/concerns/ee/vulnerabilities_actions_shared_examples.rb
...rs/concerns/ee/vulnerabilities_actions_shared_examples.rb
+370
-0
No files found.
ee/app/controllers/concerns/ee/vulnerabilities_actions.rb
0 → 100644
View file @
567bfb5e
# frozen_string_literal: true
module
EE
module
VulnerabilitiesActions
extend
ActiveSupport
::
Concern
HISTORY_RANGE
=
3
.
months
def
index
vulnerabilities
=
found_vulnerabilities
(
:with_sha
).
ordered
.
page
(
params
[
:page
])
respond_to
do
|
format
|
format
.
json
do
render
json:
Vulnerabilities
::
OccurrenceSerializer
.
new
(
current_user:
current_user
)
.
with_pagination
(
request
,
response
)
.
represent
(
vulnerabilities
,
preload:
true
)
end
end
end
def
summary
vulnerabilities_summary
=
found_vulnerabilities
.
counted_by_severity
respond_to
do
|
format
|
format
.
json
do
render
json:
VulnerabilitySummarySerializer
.
new
.
represent
(
vulnerabilities_summary
)
end
end
end
def
history
vulnerabilities_counter
=
found_vulnerabilities
(
:all
).
count_by_day_and_severity
(
HISTORY_RANGE
)
respond_to
do
|
format
|
format
.
json
do
render
json:
Vulnerabilities
::
HistorySerializer
.
new
.
represent
(
vulnerabilities_counter
)
end
end
end
private
def
filter_params
params
.
permit
(
report_type:
[],
confidence:
[],
project_id:
[],
severity:
[])
.
merge
(
hide_dismissed:
::
Gitlab
::
Utils
.
to_boolean
(
params
[
:hide_dismissed
]))
end
def
found_vulnerabilities
(
collection
=
:latest
)
::
Security
::
VulnerabilitiesFinder
.
new
(
group
,
params:
filter_params
).
execute
(
collection
)
end
end
end
ee/app/controllers/groups/security/vulnerabilities_controller.rb
View file @
567bfb5e
# frozen_string_literal: true
class
Groups::Security::VulnerabilitiesController
<
Groups
::
Security
::
ApplicationController
HISTORY_RANGE
=
3
.
months
def
index
vulnerabilities
=
found_vulnerabilities
(
:with_sha
).
ordered
.
page
(
params
[
:page
])
respond_to
do
|
format
|
format
.
json
do
render
json:
Vulnerabilities
::
OccurrenceSerializer
.
new
(
current_user:
@current_user
)
.
with_pagination
(
request
,
response
)
.
represent
(
vulnerabilities
,
preload:
true
)
end
end
end
def
summary
vulnerabilities_summary
=
found_vulnerabilities
.
counted_by_severity
respond_to
do
|
format
|
format
.
json
do
render
json:
VulnerabilitySummarySerializer
.
new
.
represent
(
vulnerabilities_summary
)
end
end
end
def
history
vulnerabilities_counter
=
found_vulnerabilities
(
:all
).
count_by_day_and_severity
(
HISTORY_RANGE
)
respond_to
do
|
format
|
format
.
json
do
render
json:
Vulnerabilities
::
HistorySerializer
.
new
.
represent
(
vulnerabilities_counter
)
end
end
end
private
def
filter_params
params
.
permit
(
report_type:
[],
confidence:
[],
project_id:
[],
severity:
[])
.
merge
(
hide_dismissed:
Gitlab
::
Utils
.
to_boolean
(
params
[
:hide_dismissed
]))
end
def
found_vulnerabilities
(
collection
=
:latest
)
::
Security
::
VulnerabilitiesFinder
.
new
(
group
,
params:
filter_params
).
execute
(
collection
)
end
include
::
EE
::
VulnerabilitiesActions
# rubocop: disable Cop/InjectEnterpriseEditionModule
end
ee/spec/controllers/groups/security/vulnerabilities_controller_spec.rb
View file @
567bfb5e
This diff is collapsed.
Click to expand it.
ee/spec/support/shared_examples/controllers/concerns/ee/vulnerabilities_actions_shared_examples.rb
0 → 100644
View file @
567bfb5e
This diff is collapsed.
Click to expand it.
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