Commit c4b71fc4 authored by DJ Mountney's avatar DJ Mountney Committed by DJ Mountney

Merge branch 'path-disclosure-proj-import-export' into 'security'

Fix for path disclosure in project import/export

See merge request !2080
parent aa21d8cc
...@@ -391,7 +391,10 @@ module ProjectsHelper ...@@ -391,7 +391,10 @@ module ProjectsHelper
def sanitize_repo_path(project, message) def sanitize_repo_path(project, message)
return '' unless message.present? return '' unless message.present?
message.strip.gsub(project.repository_storage_path.chomp('/'), "[REPOS PATH]") exports_path = File.join(Settings.shared['path'], 'tmp/project_exports')
filtered_message = message.strip.gsub(exports_path, "[REPO EXPORT PATH]")
filtered_message.gsub(project.repository_storage_path.chomp('/'), "[REPOS PATH]")
end end
def project_feature_options def project_feature_options
......
---
title: Fix path disclosure in project import/export
merge_request:
author:
...@@ -127,6 +127,7 @@ describe ProjectsHelper do ...@@ -127,6 +127,7 @@ describe ProjectsHelper do
before do before do
allow(project).to receive(:repository_storage_path).and_return('/base/repo/path') allow(project).to receive(:repository_storage_path).and_return('/base/repo/path')
allow(Settings.shared).to receive(:[]).with('path').and_return('/base/repo/export/path')
end end
it 'removes the repo path' do it 'removes the repo path' do
...@@ -135,6 +136,13 @@ describe ProjectsHelper do ...@@ -135,6 +136,13 @@ describe ProjectsHelper do
expect(sanitize_repo_path(project, import_error)).to eq('Could not clone [REPOS PATH]/namespace/test.git') expect(sanitize_repo_path(project, import_error)).to eq('Could not clone [REPOS PATH]/namespace/test.git')
end end
it 'removes the temporary repo path used for uploads/exports' do
repo = '/base/repo/export/path/tmp/project_exports/uploads/test.tar.gz'
import_error = "Unable to decompress #{repo}\n"
expect(sanitize_repo_path(project, import_error)).to eq('Unable to decompress [REPO EXPORT PATH]/uploads/test.tar.gz')
end
end end
describe '#last_push_event' do describe '#last_push_event' do
......
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