Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/github_import/attachments_downloader_spec.rb')
-rw-r--r--spec/lib/gitlab/github_import/attachments_downloader_spec.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/spec/lib/gitlab/github_import/attachments_downloader_spec.rb b/spec/lib/gitlab/github_import/attachments_downloader_spec.rb
index 84d6713efdb..086aa4be17e 100644
--- a/spec/lib/gitlab/github_import/attachments_downloader_spec.rb
+++ b/spec/lib/gitlab/github_import/attachments_downloader_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Gitlab::GithubImport::AttachmentsDownloader do
+RSpec.describe Gitlab::GithubImport::AttachmentsDownloader, feature_category: :importers do
subject(:downloader) { described_class.new(file_url) }
let_it_be(:file_url) { 'https://example.com/avatar.png' }
@@ -39,6 +39,26 @@ RSpec.describe Gitlab::GithubImport::AttachmentsDownloader do
end
end
+ context 'when file shares multiple hard links' do
+ let(:tmpdir) { Dir.mktmpdir }
+ let(:hard_link) { File.join(tmpdir, 'hard_link') }
+
+ before do
+ existing_file = File.join(tmpdir, 'file.txt')
+ FileUtils.touch(existing_file)
+ FileUtils.link(existing_file, hard_link)
+ allow(downloader).to receive(:filepath).and_return(hard_link)
+ end
+
+ it 'raises expected exception' do
+ expect(Gitlab::Utils::FileInfo).to receive(:linked?).with(hard_link).and_call_original
+ expect { downloader.perform }.to raise_exception(
+ described_class::DownloadError,
+ 'Invalid downloaded file'
+ )
+ end
+ end
+
context 'when filename is malicious' do
let_it_be(:file_url) { 'https://example.com/ava%2F..%2Ftar.png' }