Fixes project denial of service via gitmodules using Extended ASCII.

This commit is contained in:
Tiago Botelho 2017-09-15 15:28:41 +01:00
parent 5d3f7b133f
commit 0169dd7f6f
3 changed files with 19 additions and 4 deletions

View file

@ -87,10 +87,14 @@ module SubmoduleHelper
namespace = @project.namespace.full_path
end
[
namespace_project_path(namespace, base),
namespace_project_tree_path(namespace, base, commit)
]
begin
[
namespace_project_path(namespace, base),
namespace_project_tree_path(namespace, base, commit)
]
rescue ActionController::UrlGenerationError
[nil, nil]
end
end
def sanitize_submodule_url(url)

View file

@ -0,0 +1,5 @@
---
title: Fixes project denial of service via gitmodules using Extended ASCII.
merge_request: 14301
author:
type: fixed

View file

@ -147,6 +147,12 @@ describe SubmoduleHelper do
expect(helper.submodule_links(submodule_item)).to eq([nil, nil])
end
it 'sanitizes invalid URL with extended ASCII' do
stub_url('é')
expect(helper.submodule_links(submodule_item)).to eq([nil, nil])
end
it 'returns original' do
stub_url('http://mygitserver.com/gitlab-org/gitlab-ce')
expect(submodule_links(submodule_item)).to eq([repo.submodule_url_for, nil])