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
805e9886
Commit
805e9886
authored
Nov 16, 2020
by
Aakriti Gupta
Committed by
Michael Kozono
Nov 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Block git push over HTTP when database is in read-only mode
parent
3461e1cc
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
4 deletions
+25
-4
ee/changelogs/unreleased/ag-block-git-push-when-read-only.yml
...hangelogs/unreleased/ag-block-git-push-when-read-only.yml
+5
-0
ee/lib/ee/gitlab/middleware/read_only/controller.rb
ee/lib/ee/gitlab/middleware/read_only/controller.rb
+11
-1
ee/spec/support/shared_examples/lib/gitlab/middleware/read_only_gitlab_ee_instance_shared_examples.rb
...iddleware/read_only_gitlab_ee_instance_shared_examples.rb
+7
-0
lib/gitlab/middleware/read_only/controller.rb
lib/gitlab/middleware/read_only/controller.rb
+2
-2
spec/support/shared_examples/lib/gitlab/middleware/read_only_gitlab_instance_shared_examples.rb
...b/middleware/read_only_gitlab_instance_shared_examples.rb
+0
-1
No files found.
ee/changelogs/unreleased/ag-block-git-push-when-read-only.yml
0 → 100644
View file @
805e9886
---
title
:
Block git push over HTTP when database is read-only
merge_request
:
47673
author
:
type
:
changed
ee/lib/ee/gitlab/middleware/read_only/controller.rb
View file @
805e9886
...
...
@@ -16,11 +16,15 @@ module EE
'admin/geo/uploads'
=>
%w{destroy}
}.
freeze
ALLOWLISTED_GIT_WRITE_ROUTES
=
{
'repositories/git_http'
=>
%w{git_receive_pack}
}.
freeze
private
override
:allowlisted_routes
def
allowlisted_routes
super
||
geo_node_update_route?
||
geo_proxy_git_ssh_route?
||
geo_api_route?
super
||
geo_node_update_route?
||
geo_proxy_git_ssh_route?
||
geo_api_route?
||
geo_proxy_git_http_route?
end
def
geo_node_update_route?
...
...
@@ -43,6 +47,12 @@ module EE
end
end
def
geo_proxy_git_http_route?
return
unless
request
.
path
.
end_with?
(
'.git/git-receive-pack'
)
ALLOWLISTED_GIT_WRITE_ROUTES
[
route_hash
[
:controller
]]
&
.
include?
(
route_hash
[
:action
])
end
def
geo_api_route?
::
Gitlab
::
Middleware
::
ReadOnly
::
API_VERSIONS
.
any?
do
|
version
|
request
.
path
.
include?
(
"/api/v
#{
version
}
/geo_replication"
)
...
...
ee/spec/support/shared_examples/lib/gitlab/middleware/read_only_gitlab_ee_instance_shared_examples.rb
View file @
805e9886
...
...
@@ -43,5 +43,12 @@ RSpec.shared_examples 'write access for a read-only GitLab (EE) instance' do
expect
(
response
).
not_to
be_redirect
expect
(
subject
).
not_to
disallow_request
end
it
'expects a POST request to git-receive-pack URL to be allowed'
do
response
=
request
.
post
(
'/root/rouge.git/git-receive-pack'
)
expect
(
response
).
not_to
be_redirect
expect
(
subject
).
not_to
disallow_request
end
end
end
lib/gitlab/middleware/read_only/controller.rb
View file @
805e9886
...
...
@@ -10,7 +10,7 @@ module Gitlab
ERROR_MESSAGE
=
'You cannot perform write operations on a read-only instance'
ALLOWLISTED_GIT_ROUTES
=
{
'repositories/git_http'
=>
%w{git_upload_pack
git_receive_pack
}
'repositories/git_http'
=>
%w{git_upload_pack}
}.
freeze
ALLOWLISTED_GIT_LFS_ROUTES
=
{
...
...
@@ -96,7 +96,7 @@ module Gitlab
def
workhorse_passthrough_route?
# Calling route_hash may be expensive. Only do it if we think there's a possible match
return
false
unless
request
.
post?
&&
request
.
path
.
end_with?
(
'.git/git-upload-pack'
,
'.git/git-receive-pack'
)
request
.
path
.
end_with?
(
'.git/git-upload-pack'
)
ALLOWLISTED_GIT_ROUTES
[
route_hash
[
:controller
]]
&
.
include?
(
route_hash
[
:action
])
end
...
...
spec/support/shared_examples/lib/gitlab/middleware/read_only_gitlab_instance_shared_examples.rb
View file @
805e9886
...
...
@@ -128,7 +128,6 @@ RSpec.shared_examples 'write access for a read-only GitLab instance' do
'LFS request to locks create'
|
'/root/rouge.git/info/lfs/locks'
'LFS request to locks unlock'
|
'/root/rouge.git/info/lfs/locks/1/unlock'
'request to git-upload-pack'
|
'/root/rouge.git/git-upload-pack'
'request to git-receive-pack'
|
'/root/rouge.git/git-receive-pack'
end
with_them
do
...
...
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