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
52f93e73
Commit
52f93e73
authored
Dec 20, 2019
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port security fix from dev
https://dev.gitlab.org/gitlab/gitlab-ee/merge_requests/1502
parent
d31dff94
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
7 deletions
+42
-7
app/models/user.rb
app/models/user.rb
+1
-1
changelogs/unreleased/security-master-mc-api-runner-owner-permissions.yml
...eased/security-master-mc-api-runner-owner-permissions.yml
+5
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+20
-6
spec/requests/api/runners_spec.rb
spec/requests/api/runners_spec.rb
+16
-0
No files found.
app/models/user.rb
View file @
52f93e73
...
...
@@ -1327,7 +1327,7 @@ class User < ApplicationRecord
.
select
(
'ci_runners.*'
)
group_runners
=
Ci
::
RunnerNamespace
.
where
(
namespace_id:
owned_
or_maintainers_
groups
.
select
(
:id
))
.
where
(
namespace_id:
owned_groups
.
select
(
:id
))
.
joins
(
:runner
)
.
select
(
'ci_runners.*'
)
...
...
changelogs/unreleased/security-master-mc-api-runner-owner-permissions.yml
0 → 100644
View file @
52f93e73
---
title
:
Return only runners from groups where user is owner for user CI owned runners.
merge_request
:
author
:
type
:
security
spec/models/user_spec.rb
View file @
52f93e73
...
...
@@ -2638,8 +2638,8 @@ describe User, :do_not_mock_admin_mode do
add_user
(
:maintainer
)
end
it
'
loads
'
do
expect
(
user
.
ci_owned_runners
).
to
contain_exactly
(
runner
)
it
'
does not load
'
do
expect
(
user
.
ci_owned_runners
).
to
be_empty
end
end
...
...
@@ -2654,6 +2654,20 @@ describe User, :do_not_mock_admin_mode do
end
end
shared_examples
:group_member
do
context
'when the user is owner'
do
before
do
add_user
(
:owner
)
end
it
'loads'
do
expect
(
user
.
ci_owned_runners
).
to
contain_exactly
(
runner
)
end
end
it_behaves_like
:member
end
context
'with groups projects runners'
do
let
(
:group
)
{
create
(
:group
)
}
let!
(
:project
)
{
create
(
:project
,
group:
group
)
}
...
...
@@ -2662,7 +2676,7 @@ describe User, :do_not_mock_admin_mode do
group
.
add_user
(
user
,
access
)
end
it_behaves_like
:member
it_behaves_like
:
group_
member
end
context
'with groups runners'
do
...
...
@@ -2673,14 +2687,14 @@ describe User, :do_not_mock_admin_mode do
group
.
add_user
(
user
,
access
)
end
it_behaves_like
:member
it_behaves_like
:
group_
member
end
context
'with other projects runners'
do
let!
(
:project
)
{
create
(
:project
)
}
def
add_user
(
access
)
project
.
add_
role
(
user
,
access
)
project
.
add_
user
(
user
,
access
)
end
it_behaves_like
:member
...
...
@@ -2698,7 +2712,7 @@ describe User, :do_not_mock_admin_mode do
subgroup
.
add_user
(
another_user
,
:owner
)
end
it_behaves_like
:member
it_behaves_like
:
group_
member
end
end
...
...
spec/requests/api/runners_spec.rb
View file @
52f93e73
...
...
@@ -6,6 +6,7 @@ describe API::Runners do
let
(
:admin
)
{
create
(
:user
,
:admin
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let
(
:group_maintainer
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
)
}
let
(
:project2
)
{
create
(
:project
,
creator_id:
user
.
id
)
}
...
...
@@ -20,6 +21,7 @@ describe API::Runners do
before
do
# Set project access for users
create
(
:group_member
,
:maintainer
,
user:
group_maintainer
,
group:
group
)
create
(
:project_member
,
:maintainer
,
user:
user
,
project:
project
)
create
(
:project_member
,
:maintainer
,
user:
user
,
project:
project2
)
create
(
:project_member
,
:reporter
,
user:
user2
,
project:
project
)
...
...
@@ -525,6 +527,20 @@ describe API::Runners do
end
.
to
change
{
Ci
::
Runner
.
project_type
.
count
}.
by
(
-
1
)
end
it
'does not delete group runner with maintainer access'
do
delete
api
(
"/runners/
#{
group_runner
.
id
}
"
,
group_maintainer
)
expect
(
response
).
to
have_http_status
(
403
)
end
it
'deletes group runner with owner access'
do
expect
do
delete
api
(
"/runners/
#{
group_runner
.
id
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
204
)
end
.
to
change
{
Ci
::
Runner
.
group_type
.
count
}.
by
(
-
1
)
end
it_behaves_like
'412 response'
do
let
(
:request
)
{
api
(
"/runners/
#{
project_runner
.
id
}
"
,
user
)
}
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