| ... | @@ -1753,22 +1753,23 @@ describe Gitlab::Git::Repository, :seed_helper do |
... | @@ -1753,22 +1753,23 @@ describe Gitlab::Git::Repository, :seed_helper do |
|
|
end
|
|
end
|
|
|
|
|
|
|
|
describe '#create_from_bundle' do
|
|
describe '#create_from_bundle' do
|
|
|
let(:bundle_path) { File.join(Dir.tmpdir, "repo-#{SecureRandom.hex}.bundle") }
|
|
let(:valid_bundle_path) { File.join(Dir.tmpdir, "repo-#{SecureRandom.hex}.bundle") }
|
|
|
|
let(:malicious_bundle_path) { Rails.root.join('spec/fixtures/malicious.bundle') }
|
|
|
let(:project) { create(:project) }
|
|
let(:project) { create(:project) }
|
|
|
let(:imported_repo) { project.repository.raw }
|
|
let(:imported_repo) { project.repository.raw }
|
|
|
|
|
|
|
|
before do
|
|
before do
|
|
|
expect(repository.bundle_to_disk(bundle_path)).to be_truthy
|
|
expect(repository.bundle_to_disk(valid_bundle_path)).to be_truthy
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
after do
|
|
|
FileUtils.rm_rf(bundle_path)
|
|
FileUtils.rm_rf(valid_bundle_path)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
it 'creates a repo from a bundle file' do
|
|
it 'creates a repo from a bundle file' do
|
|
|
expect(imported_repo).not_to exist
|
|
expect(imported_repo).not_to exist
|
|
|
|
|
|
|
|
result = imported_repo.create_from_bundle(bundle_path)
|
|
result = imported_repo.create_from_bundle(valid_bundle_path)
|
|
|
|
|
|
|
|
expect(result).to be_truthy
|
|
expect(result).to be_truthy
|
|
|
expect(imported_repo).to exist
|
|
expect(imported_repo).to exist
|
| ... | @@ -1776,11 +1777,17 @@ describe Gitlab::Git::Repository, :seed_helper do |
... | @@ -1776,11 +1777,17 @@ describe Gitlab::Git::Repository, :seed_helper do |
|
|
end
|
|
end
|
|
|
|
|
|
|
|
it 'creates a symlink to the global hooks dir' do
|
|
it 'creates a symlink to the global hooks dir' do
|
|
|
imported_repo.create_from_bundle(bundle_path)
|
|
imported_repo.create_from_bundle(valid_bundle_path)
|
|
|
hooks_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access { File.join(imported_repo.path, 'hooks') }
|
|
hooks_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access { File.join(imported_repo.path, 'hooks') }
|
|
|
|
|
|
|
|
expect(File.readlink(hooks_path)).to eq(Gitlab.config.gitlab_shell.hooks_path)
|
|
expect(File.readlink(hooks_path)).to eq(Gitlab.config.gitlab_shell.hooks_path)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
it 'raises an error if the bundle is an attempted malicious payload' do
|
|
|
|
expect do
|
|
|
|
imported_repo.create_from_bundle(malicious_bundle_path)
|
|
|
|
end.to raise_error(::Gitlab::Git::BundleFile::InvalidBundleError)
|
|
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
describe '#checksum' do
|
|
describe '#checksum' do
|
| ... | |
... | |
| ... | | ... | |