Commit 61111d4c authored by Ash McKenzie's avatar Ash McKenzie

Bang up predicate methods and use #internal_route?

Extract internal route logic check out into #internal_route?
Add ? to #grack_route and #lfs_route predicate methods
parent c0a5b628
...@@ -77,10 +77,10 @@ module Gitlab ...@@ -77,10 +77,10 @@ module Gitlab
# Overridden in EE module # Overridden in EE module
def whitelisted_routes def whitelisted_routes
grack_route || ReadOnly.internal_routes.any? { |path| request.path.include?(path) } || lfs_route || sidekiq_route? grack_route? || internal_route? || lfs_route? || sidekiq_route?
end end
def grack_route def grack_route?
# Calling route_hash may be expensive. Only do it if we think there's a possible match # Calling route_hash may be expensive. Only do it if we think there's a possible match
return false unless return false unless
request.path.end_with?('.git/git-upload-pack', '.git/git-receive-pack') request.path.end_with?('.git/git-upload-pack', '.git/git-receive-pack')
...@@ -88,7 +88,11 @@ module Gitlab ...@@ -88,7 +88,11 @@ module Gitlab
WHITELISTED_GIT_ROUTES[route_hash[:controller]]&.include?(route_hash[:action]) WHITELISTED_GIT_ROUTES[route_hash[:controller]]&.include?(route_hash[:action])
end end
def lfs_route def internal_route?
ReadOnly.internal_routes.any? { |path| request.path.include?(path) }
end
def lfs_route?
# Calling route_hash may be expensive. Only do it if we think there's a possible match # Calling route_hash may be expensive. Only do it if we think there's a possible match
unless request.path.end_with?('/info/lfs/objects/batch', unless request.path.end_with?('/info/lfs/objects/batch',
'/info/lfs/locks', '/info/lfs/locks/verify') || '/info/lfs/locks', '/info/lfs/locks/verify') ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment