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
6ed730f1
Commit
6ed730f1
authored
Feb 24, 2020
by
Francisco Javier López
Committed by
Peter Leitzen
Feb 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug with internal project snippets and project maintainer
parent
1c9ba0c5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
15 deletions
+42
-15
app/policies/project_snippet_policy.rb
app/policies/project_snippet_policy.rb
+2
-2
changelogs/unreleased/fj-207803-fix-project-snippet-policy-bug.yml
...s/unreleased/fj-207803-fix-project-snippet-policy-bug.yml
+5
-0
spec/policies/project_snippet_policy_spec.rb
spec/policies/project_snippet_policy_spec.rb
+35
-13
No files found.
app/policies/project_snippet_policy.rb
View file @
6ed730f1
...
...
@@ -31,7 +31,7 @@ class ProjectSnippetPolicy < BasePolicy
~
can?
(
:read_all_resources
))
end
.
prevent
:read_snippet
rule
{
internal_snippet
&
~
is_author
&
~
admin
}.
policy
do
rule
{
internal_snippet
&
~
is_author
&
~
admin
&
~
project
.
maintainer
}.
policy
do
prevent
:update_snippet
prevent
:admin_snippet
end
...
...
@@ -42,7 +42,7 @@ class ProjectSnippetPolicy < BasePolicy
prevent
:admin_snippet
end
rule
{
is_author
|
admin
}.
policy
do
rule
{
is_author
|
admin
|
project
.
maintainer
}.
policy
do
enable
:read_snippet
enable
:update_snippet
enable
:admin_snippet
...
...
changelogs/unreleased/fj-207803-fix-project-snippet-policy-bug.yml
0 → 100644
View file @
6ed730f1
---
title
:
Fix bug deleting internal project snippets by project maintainer
merge_request
:
25792
author
:
type
:
fixed
spec/policies/project_snippet_policy_spec.rb
View file @
6ed730f1
...
...
@@ -20,6 +20,7 @@ describe ProjectSnippetPolicy do
subject
{
described_class
.
new
(
current_user
,
snippet
)
}
shared_examples
'regular user access rights'
do
context
'not snippet author'
do
context
'project team member (non guest)'
do
before
do
project
.
add_developer
(
current_user
)
...
...
@@ -36,12 +37,22 @@ describe ProjectSnippetPolicy do
project
.
add_guest
(
current_user
)
end
context
'not snippet author'
do
it
do
expect_allowed
(
:read_snippet
,
:create_note
)
expect_disallowed
(
:admin_snippet
)
end
end
context
'project team member (maintainer)'
do
before
do
project
.
add_maintainer
(
current_user
)
end
it
do
expect_allowed
(
:read_snippet
,
:create_note
)
expect_allowed
(
*
author_permissions
)
end
end
end
context
'snippet author'
do
...
...
@@ -69,6 +80,17 @@ describe ProjectSnippetPolicy do
end
end
context
'project team member (maintainer)'
do
before
do
project
.
add_maintainer
(
current_user
)
end
it
do
expect_allowed
(
:read_snippet
,
:create_note
)
expect_allowed
(
*
author_permissions
)
end
end
context
'not a project member'
do
it
do
expect_allowed
(
:read_snippet
,
:create_note
)
...
...
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