Class: Constraints::RepositoryRedirectUrlConstrainer
- Inherits:
-
Object
- Object
- Constraints::RepositoryRedirectUrlConstrainer
- Defined in:
- lib/constraints/repository_redirect_url_constrainer.rb
Instance Method Summary collapse
-
#container_path?(path) ⇒ Boolean
Check if the path matches any known repository containers.
-
#git_request?(query) ⇒ Boolean
Allow /info/refs, /info/refs?service=git-upload-pack, and /info/refs?service=git-receive-pack, but nothing else.
- #matches?(request) ⇒ Boolean
Instance Method Details
#container_path?(path) ⇒ Boolean
Check if the path matches any known repository containers.
21 22 23 24 25 |
# File 'lib/constraints/repository_redirect_url_constrainer.rb', line 21 def container_path?(path) wiki_path?(path) || ProjectPathValidator.valid_path?(path) || path =~ Gitlab::PathRegex.full_snippets_repository_path_regex end |
#git_request?(query) ⇒ Boolean
Allow /info/refs, /info/refs?service=git-upload-pack, and /info/refs?service=git-receive-pack, but nothing else.
14 15 16 17 18 |
# File 'lib/constraints/repository_redirect_url_constrainer.rb', line 14 def git_request?(query) query.blank? || query == 'service=git-upload-pack' || query == 'service=git-receive-pack' end |
#matches?(request) ⇒ Boolean
5 6 7 8 9 10 |
# File 'lib/constraints/repository_redirect_url_constrainer.rb', line 5 def matches?(request) path = request.params[:repository_path].delete_suffix('.git') query = request.query_string git_request?(query) && container_path?(path) end |