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
0b817a6f
Commit
0b817a6f
authored
Dec 17, 2019
by
mo khan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix whitespace indentation
parent
7e6135e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
61 deletions
+61
-61
ee/app/controllers/projects/dependencies_controller.rb
ee/app/controllers/projects/dependencies_controller.rb
+61
-61
No files found.
ee/app/controllers/projects/dependencies_controller.rb
View file @
0b817a6f
# frozen_string_literal: true
module
Projects
class
DependenciesController
<
Projects
::
ApplicationController
before_action
:authorize_read_dependency_list!
def
index
respond_to
do
|
format
|
format
.
html
do
render
status: :ok
end
format
.
json
do
::
Gitlab
::
UsageCounters
::
DependencyList
.
increment
(
project
.
id
)
render
json:
serializer
.
represent
(
dependencies
,
build:
report_service
.
build
)
end
class
DependenciesController
<
Projects
::
ApplicationController
before_action
:authorize_read_dependency_list!
def
index
respond_to
do
|
format
|
format
.
html
do
render
status: :ok
end
format
.
json
do
::
Gitlab
::
UsageCounters
::
DependencyList
.
increment
(
project
.
id
)
render
json:
serializer
.
represent
(
dependencies
,
build:
report_service
.
build
)
end
end
end
private
private
def
can_access_vulnerable?
return
true
unless
query_params
[
:filter
]
==
'vulnerable'
def
can_access_vulnerable?
return
true
unless
query_params
[
:filter
]
==
'vulnerable'
can?
(
current_user
,
:read_vulnerability
,
project
)
end
can?
(
current_user
,
:read_vulnerability
,
project
)
end
def
can_collect_dependencies?
report_service
.
able_to_fetch?
&&
can_access_vulnerable?
end
def
can_collect_dependencies?
report_service
.
able_to_fetch?
&&
can_access_vulnerable?
end
def
collect_dependencies
found_dependencies
=
can_collect_dependencies?
?
service
.
execute
:
[]
::
Gitlab
::
ItemsCollection
.
new
(
found_dependencies
)
end
def
collect_dependencies
found_dependencies
=
can_collect_dependencies?
?
service
.
execute
:
[]
::
Gitlab
::
ItemsCollection
.
new
(
found_dependencies
)
end
def
authorize_read_dependency_list!
return
if
can?
(
current_user
,
:read_dependencies
,
project
)
def
authorize_read_dependency_list!
return
if
can?
(
current_user
,
:read_dependencies
,
project
)
respond_to
do
|
format
|
format
.
html
do
render_404
end
format
.
json
do
render_403
end
respond_to
do
|
format
|
format
.
html
do
render_404
end
format
.
json
do
render_403
end
end
end
def
dependencies
@dependencies
||=
collect_dependencies
end
def
dependencies
@dependencies
||=
collect_dependencies
end
def
match_disallowed
(
param
,
value
)
param
==
:sort_by
&&
!
value
.
in?
(
::
Security
::
DependencyListService
::
SORT_BY_VALUES
)
||
param
==
:sort
&&
!
value
.
in?
(
::
Security
::
DependencyListService
::
SORT_VALUES
)
||
param
==
:filter
&&
!
value
.
in?
(
::
Security
::
DependencyListService
::
FILTER_VALUES
)
end
def
match_disallowed
(
param
,
value
)
param
==
:sort_by
&&
!
value
.
in?
(
::
Security
::
DependencyListService
::
SORT_BY_VALUES
)
||
param
==
:sort
&&
!
value
.
in?
(
::
Security
::
DependencyListService
::
SORT_VALUES
)
||
param
==
:filter
&&
!
value
.
in?
(
::
Security
::
DependencyListService
::
FILTER_VALUES
)
end
def
pipeline
@pipeline
||=
report_service
.
pipeline
end
def
pipeline
@pipeline
||=
report_service
.
pipeline
end
def
query_params
return
@permitted_params
if
@permitted_params
def
query_params
return
@permitted_params
if
@permitted_params
@permitted_params
=
params
.
permit
(
:sort
,
:sort_by
,
:filter
).
delete_if
do
|
key
,
value
|
match_disallowed
(
key
,
value
)
end
@permitted_params
=
params
.
permit
(
:sort
,
:sort_by
,
:filter
).
delete_if
do
|
key
,
value
|
match_disallowed
(
key
,
value
)
end
end
def
report_service
@report_service
||=
::
Security
::
ReportFetchService
.
new
(
project
,
::
Ci
::
JobArtifact
.
dependency_list_reports
)
end
def
report_service
@report_service
||=
::
Security
::
ReportFetchService
.
new
(
project
,
::
Ci
::
JobArtifact
.
dependency_list_reports
)
end
def
serializer
serializer
=
::
DependencyListSerializer
.
new
(
project:
project
,
user:
current_user
)
serializer
=
serializer
.
with_pagination
(
request
,
response
)
if
params
[
:page
]
serializer
end
def
serializer
serializer
=
::
DependencyListSerializer
.
new
(
project:
project
,
user:
current_user
)
serializer
=
serializer
.
with_pagination
(
request
,
response
)
if
params
[
:page
]
serializer
end
def
service
::
Security
::
DependencyListService
.
new
(
pipeline:
pipeline
,
params:
query_params
)
end
def
service
::
Security
::
DependencyListService
.
new
(
pipeline:
pipeline
,
params:
query_params
)
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