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
e0d827ed
Commit
e0d827ed
authored
Jan 28, 2021
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Forbid git pushes to group wikis when repo is read only
parent
2c8beb6b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
4 deletions
+23
-4
ee/changelogs/unreleased/300291-fj-forbid-to-group-wikis-when-read-only.yml
...leased/300291-fj-forbid-to-group-wikis-when-read-only.yml
+5
-0
ee/lib/ee/gitlab/git_access_wiki.rb
ee/lib/ee/gitlab/git_access_wiki.rb
+8
-3
ee/spec/lib/gitlab/git_access_wiki_spec.rb
ee/spec/lib/gitlab/git_access_wiki_spec.rb
+10
-1
No files found.
ee/changelogs/unreleased/300291-fj-forbid-to-group-wikis-when-read-only.yml
0 → 100644
View file @
e0d827ed
---
title
:
Forbid git pushes to group wikis when repo is read only
merge_request
:
52801
author
:
type
:
added
ee/lib/ee/gitlab/git_access_wiki.rb
View file @
e0d827ed
...
...
@@ -9,7 +9,8 @@ module EE
ERROR_MESSAGES
=
{
write_to_group_wiki:
"You are not allowed to write to this group's wiki."
,
group_not_found:
'The group you were looking for could not be found.'
,
no_group_repo:
'A repository for this group wiki does not exist yet.'
no_group_repo:
'A repository for this group wiki does not exist yet.'
,
repo_read_only:
'The repository is temporarily read-only. Please try again later.'
}.
freeze
override
:group
...
...
@@ -26,9 +27,13 @@ module EE
override
:check_push_access!
def
check_push_access!
return
check_change_access!
if
group?
return
super
unless
group?
super
if
group
.
repository_read_only?
raise
::
Gitlab
::
GitAccess
::
ForbiddenError
,
ERROR_MESSAGES
[
:repo_read_only
]
end
check_change_access!
end
override
:write_to_wiki_message
...
...
ee/spec/lib/gitlab/git_access_wiki_spec.rb
View file @
e0d827ed
...
...
@@ -42,7 +42,16 @@ RSpec.describe Gitlab::GitAccessWiki do
end
it
'does not give access to upload wiki code'
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
GitAccess
::
ForbiddenError
,
"You can't push code to a read-only GitLab instance."
)
expect
{
subject
}.
to
raise_forbidden
(
"You can't push code to a read-only GitLab instance."
)
end
end
context
'when group is read-only'
do
it
'does not allow push and allows pull access'
do
allow
(
group
).
to
receive
(
:repository_read_only?
).
and_return
(
true
)
expect
{
push_changes
(
changes
)
}.
to
raise_forbidden
(
'The repository is temporarily read-only. Please try again later.'
)
expect
{
pull_changes
(
changes
)
}.
not_to
raise_error
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