Skip to content

Commit c0f1248

Browse files
authored
Merge pull request #218 from stackhpc/upstream/wallaby-2023-04-24
Synchronise wallaby with upstream
2 parents 76951b2 + b92d883 commit c0f1248

File tree

4 files changed

+78
-1
lines changed

4 files changed

+78
-1
lines changed

docker/cinder/cinder-volume/Dockerfile.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
99

1010
{% if base_package_type == 'rpm' %}
1111
{% set cinder_volume_packages = [
12+
'device-mapper-multipath',
1213
'nfs-utils',
1314
'nvmetcli',
1415
'python3-rtslib',
@@ -24,6 +25,7 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
2425
{% elif base_package_type == 'deb' %}
2526
{% set cinder_volume_packages = [
2627
'lsscsi',
28+
'multipath-tools',
2729
'nfs-common',
2830
'nvme-cli',
2931
'sysfsutils',

docker/nova/nova-libvirt/Dockerfile.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
2222
'libvirt-daemon',
2323
'libvirt-daemon-config-nwfilter',
2424
'libvirt-daemon-driver-nwfilter',
25+
'libvirt-daemon-driver-nodedev',
2526
'openvswitch',
2627
'qemu-img',
2728
'qemu-kvm',

kolla/image/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ def update_buildargs(self):
491491
def builder(self, image):
492492

493493
def _test_malicious_tarball(archive, path):
494-
tar_file = tarfile.open(archive, 'r|gz')
494+
tar_file = tarfile.open(archive, 'r|*')
495495
for n in tar_file.getnames():
496496
if not os.path.abspath(os.path.join(path, n)).startswith(path):
497497
tar_file.close()

kolla/tests/test_build.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,83 @@ def test_process_source(self, mock_get, mock_client,
301301
else:
302302
self.assertIsNotNone(get_result)
303303

304+
@mock.patch.dict(os.environ, clear=True)
305+
@mock.patch('docker.APIClient')
306+
def test_local_directory(self, mock_client):
307+
self.conf.set_override('install_type', 'source')
308+
tmpdir = tempfile.mkdtemp()
309+
file_name = 'test.txt'
310+
file_path = os.path.join(tmpdir, file_name)
311+
saved_umask = os.umask(0o077)
312+
313+
try:
314+
with open(file_path, 'w') as f:
315+
f.write('Hello')
316+
317+
self.dc = mock_client
318+
self.image.plugins = [{
319+
'name': 'fake-image-base-plugin-test',
320+
'type': 'local',
321+
'enabled': True,
322+
'source': tmpdir}
323+
]
324+
push_queue = mock.Mock()
325+
builder = build.BuildTask(self.conf, self.image, push_queue)
326+
builder.run()
327+
self.assertTrue(builder.success)
328+
329+
except IOError:
330+
print('IOError')
331+
else:
332+
os.remove(file_path)
333+
finally:
334+
os.umask(saved_umask)
335+
os.rmdir(tmpdir)
336+
304337
@mock.patch.dict(os.environ, clear=True)
305338
@mock.patch('docker.APIClient')
306339
def test_malicious_tar(self, mock_client):
340+
self.conf.set_override('install_type', 'source')
341+
tmpdir = tempfile.mkdtemp()
342+
file_name = 'test.txt'
343+
archive_name = 'my_archive.tar'
344+
file_path = os.path.join(tmpdir, file_name)
345+
archive_path = os.path.join(tmpdir, archive_name)
346+
# Ensure the file is read/write by the creator only
347+
saved_umask = os.umask(0o077)
348+
349+
try:
350+
with open(file_path, 'w') as f:
351+
f.write('Hello')
352+
353+
with tarfile.open(archive_path, 'w') as tar:
354+
tar.add(file_path, arcname='../test.txt')
355+
356+
self.dc = mock_client
357+
self.image.plugins = [{
358+
'name': 'fake-image-base-plugin-test',
359+
'type': 'local',
360+
'enabled': True,
361+
'source': archive_path}
362+
]
363+
364+
push_queue = mock.Mock()
365+
builder = build.BuildTask(self.conf, self.image, push_queue)
366+
builder.run()
367+
self.assertFalse(builder.success)
368+
369+
except IOError:
370+
print('IOError')
371+
else:
372+
os.remove(file_path)
373+
os.remove(archive_path)
374+
finally:
375+
os.umask(saved_umask)
376+
os.rmdir(tmpdir)
377+
378+
@mock.patch.dict(os.environ, clear=True)
379+
@mock.patch('docker.APIClient')
380+
def test_malicious_tar_gz(self, mock_client):
307381
self.conf.set_override('install_type', 'source')
308382
tmpdir = tempfile.mkdtemp()
309383
file_name = 'test.txt'

0 commit comments

Comments
 (0)