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
4f7281c3
Commit
4f7281c3
authored
Jul 30, 2019
by
Tetiana Chupryna
Committed by
James Lopez
Jul 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add authorization for Dependencies Controller
parent
d680fd3e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
5 deletions
+19
-5
ee/app/controllers/projects/security/dependencies_controller.rb
.../controllers/projects/security/dependencies_controller.rb
+5
-0
ee/changelogs/unreleased/12425-permissions.yml
ee/changelogs/unreleased/12425-permissions.yml
+5
-0
ee/spec/controllers/projects/security/dependencies_controller_spec.rb
...rollers/projects/security/dependencies_controller_spec.rb
+9
-5
No files found.
ee/app/controllers/projects/security/dependencies_controller.rb
View file @
4f7281c3
...
...
@@ -3,6 +3,7 @@
module
Projects
module
Security
class
DependenciesController
<
Projects
::
ApplicationController
before_action
:authorize_read_dependency_list!
before_action
:ensure_dependency_list_feature_available
def
index
...
...
@@ -31,6 +32,10 @@ module Projects
::
Gitlab
::
DependenciesCollection
.
new
(
found_dependencies
)
end
def
authorize_read_dependency_list!
return
render_403
unless
can?
(
current_user
,
:read_project_security_dashboard
,
project
)
end
def
ensure_dependency_list_feature_available
render_404
unless
project
.
feature_available?
(
:dependency_list
)
end
...
...
ee/changelogs/unreleased/12425-permissions.yml
0 → 100644
View file @
4f7281c3
---
title
:
Add authorization to the dependency list
merge_request
:
14867
author
:
type
:
added
ee/spec/controllers/projects/security/dependencies_controller_spec.rb
View file @
4f7281c3
...
...
@@ -9,17 +9,17 @@ describe Projects::Security::DependenciesController do
let
(
:params
)
{
{
namespace_id:
project
.
namespace
,
project_id:
project
}
}
before
do
project
.
add_developer
(
user
)
sign_in
(
user
)
end
context
'with authorized user'
do
before
do
sign_in
(
user
)
project
.
add_developer
(
user
)
end
context
'when feature is available'
do
before
do
stub_licensed_features
(
dependency_list:
true
)
stub_licensed_features
(
dependency_list:
true
,
security_dashboard:
true
)
end
it
'counts usage of the feature'
do
...
...
@@ -135,6 +135,8 @@ describe Projects::Security::DependenciesController do
context
'when feature is not available'
do
before
do
stub_licensed_features
(
security_dashboard:
true
)
get
:index
,
params:
params
,
format: :json
end
...
...
@@ -146,11 +148,13 @@ describe Projects::Security::DependenciesController do
context
'with unauthorized user'
do
before
do
project
.
add_guest
(
user
)
get
:index
,
params:
params
,
format: :json
end
it
'returns 40
4
'
do
expect
(
response
).
to
have_gitlab_http_status
(
40
4
)
it
'returns 40
3
'
do
expect
(
response
).
to
have_gitlab_http_status
(
40
3
)
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