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
2fd5cc2b
Commit
2fd5cc2b
authored
Nov 02, 2017
by
Brett Walker
Committed by
Nick Thomas
Nov 02, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Geo route whitelisting is too optimistic
parent
506a4e75
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
2 deletions
+34
-2
changelogs/unreleased/3274-geo-route-whitelisting.yml
changelogs/unreleased/3274-geo-route-whitelisting.yml
+5
-0
lib/gitlab/middleware/read_only.rb
lib/gitlab/middleware/read_only.rb
+3
-2
spec/lib/gitlab/middleware/read_only_spec.rb
spec/lib/gitlab/middleware/read_only_spec.rb
+26
-0
No files found.
changelogs/unreleased/3274-geo-route-whitelisting.yml
0 → 100644
View file @
2fd5cc2b
---
title
:
Tighten up whitelisting of certain Geo routes
merge_request
:
15082
author
:
type
:
fixed
lib/gitlab/middleware/read_only.rb
View file @
2fd5cc2b
...
@@ -12,6 +12,7 @@ module Gitlab
...
@@ -12,6 +12,7 @@ module Gitlab
def
call
(
env
)
def
call
(
env
)
@env
=
env
@env
=
env
@route_hash
=
nil
if
disallowed_request?
&&
Gitlab
::
Database
.
read_only?
if
disallowed_request?
&&
Gitlab
::
Database
.
read_only?
Rails
.
logger
.
debug
(
'GitLab ReadOnly: preventing possible non read-only operation'
)
Rails
.
logger
.
debug
(
'GitLab ReadOnly: preventing possible non read-only operation'
)
...
@@ -77,11 +78,11 @@ module Gitlab
...
@@ -77,11 +78,11 @@ module Gitlab
end
end
def
grack_route
def
grack_route
r
equest
.
path
.
end_with?
(
'.git/git-upload-pack'
)
r
oute_hash
[
:controller
]
==
'projects/git_http'
&&
route_hash
[
:action
]
==
'git_upload_pack'
end
end
def
lfs_route
def
lfs_route
r
equest
.
path
.
end_with?
(
'/info/lfs/objects/batch'
)
r
oute_hash
[
:controller
]
==
'projects/lfs_api'
&&
route_hash
[
:action
]
==
'batch'
end
end
end
end
end
end
...
...
spec/lib/gitlab/middleware/read_only_spec.rb
View file @
2fd5cc2b
...
@@ -83,6 +83,13 @@ describe Gitlab::Middleware::ReadOnly do
...
@@ -83,6 +83,13 @@ describe Gitlab::Middleware::ReadOnly do
expect
(
subject
).
to
disallow_request
expect
(
subject
).
to
disallow_request
end
end
it
'expects POST of new file that looks like an LFS batch url to be disallowed'
do
response
=
request
.
post
(
'/root/gitlab-ce/new/master/app/info/lfs/objects/batch'
)
expect
(
response
).
to
be_a_redirect
expect
(
subject
).
to
disallow_request
end
context
'whitelisted requests'
do
context
'whitelisted requests'
do
it
'expects DELETE request to logout to be allowed'
do
it
'expects DELETE request to logout to be allowed'
do
response
=
request
.
delete
(
'/users/sign_out'
)
response
=
request
.
delete
(
'/users/sign_out'
)
...
@@ -104,6 +111,25 @@ describe Gitlab::Middleware::ReadOnly do
...
@@ -104,6 +111,25 @@ describe Gitlab::Middleware::ReadOnly do
expect
(
response
).
not_to
be_a_redirect
expect
(
response
).
not_to
be_a_redirect
expect
(
subject
).
not_to
disallow_request
expect
(
subject
).
not_to
disallow_request
end
end
it
'expects a POST request to git-upload-pack URL to be allowed'
do
response
=
request
.
post
(
'/root/rouge.git/git-upload-pack'
)
expect
(
response
).
not_to
be_a_redirect
expect
(
subject
).
not_to
disallow_request
end
it
'expects requests to sidekiq admin to be allowed'
do
response
=
request
.
post
(
'/admin/sidekiq'
)
expect
(
response
).
not_to
be_a_redirect
expect
(
subject
).
not_to
disallow_request
response
=
request
.
get
(
'/admin/sidekiq'
)
expect
(
response
).
not_to
be_a_redirect
expect
(
subject
).
not_to
disallow_request
end
end
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