Update upstream source from tag 'upstream/11.5.4+dfsg'

Update to upstream version '11.5.4+dfsg'
with Debian dir 767079a723
This commit is contained in:
Pirate Praveen 2018-12-15 14:42:44 +05:30
commit 5d32bb6e11
4 changed files with 23 additions and 1 deletions

View file

@ -2,6 +2,13 @@
documentation](doc/development/changelog.md) for instructions on adding your own documentation](doc/development/changelog.md) for instructions on adding your own
entry. entry.
## 11.5.4 (2018-12-13)
### Security (1 change)
- Validate LFS hrefs before downloading them.
## 11.5.3 (2018-12-06) ## 11.5.3 (2018-12-06)
### Security (1 change) ### Security (1 change)

View file

@ -1 +1 @@
11.5.3 11.5.4

View file

@ -4,6 +4,8 @@
module Projects module Projects
module LfsPointers module LfsPointers
class LfsDownloadService < BaseService class LfsDownloadService < BaseService
VALID_PROTOCOLS = %w[http https].freeze
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def execute(oid, url) def execute(oid, url)
return unless project&.lfs_enabled? && oid.present? && url.present? return unless project&.lfs_enabled? && oid.present? && url.present?
@ -11,6 +13,7 @@ module Projects
return if LfsObject.exists?(oid: oid) return if LfsObject.exists?(oid: oid)
sanitized_uri = Gitlab::UrlSanitizer.new(url) sanitized_uri = Gitlab::UrlSanitizer.new(url)
Gitlab::UrlBlocker.validate!(sanitized_uri.sanitized_url, protocols: VALID_PROTOCOLS)
with_tmp_file(oid) do |file| with_tmp_file(oid) do |file|
size = download_and_save_file(file, sanitized_uri) size = download_and_save_file(file, sanitized_uri)

View file

@ -54,6 +54,18 @@ describe Projects::LfsPointers::LfsDownloadService do
end end
end end
context 'when a bad URL is used' do
where(download_link: ['/etc/passwd', 'ftp://example.com', 'http://127.0.0.2'])
with_them do
it 'does not download the file' do
expect(subject).not_to receive(:download_and_save_file)
expect { subject.execute(oid, download_link) }.not_to change { LfsObject.count }
end
end
end
context 'when an lfs object with the same oid already exists' do context 'when an lfs object with the same oid already exists' do
before do before do
create(:lfs_object, oid: 'oid') create(:lfs_object, oid: 'oid')