aboutsummaryrefslogtreecommitdiff
path: root/kolla/image
diff options
context:
space:
mode:
authorMichal Nasiadka <mnasiadka@gmail.com>2023-03-16 10:04:47 +0000
committerMichal Nasiadka <mnasiadka@gmail.com>2023-03-17 09:09:35 +0000
commit3d008b7f5ec2a54d004e8e9370f303ef9dc7858b (patch)
tree3752fa4bd32b4523f8ca1380b06a63c13f161689 /kolla/image
parent12d431e3994023ce735a2352554a99a5cc9431c9 (diff)
downloadkolla-3d008b7f5ec2a54d004e8e9370f303ef9dc7858b.tar.gz
kolla-3d008b7f5ec2a54d004e8e9370f303ef9dc7858b.zip
Test for unsafe files in tarfile.extractall
In addition to that, mark bifrost unbuildable since it's failing on EPEL 9 enablement. Closes-Bug: #1990432 Change-Id: I650fcbc8f773fad8116338f6fb0cf7b4f4f17b33
Diffstat (limited to 'kolla/image')
-rw-r--r--kolla/image/tasks.py11
-rw-r--r--kolla/image/unbuildable.py2
2 files changed, 12 insertions, 1 deletions
diff --git a/kolla/image/tasks.py b/kolla/image/tasks.py
index 5038c1d52..091f41f65 100644
--- a/kolla/image/tasks.py
+++ b/kolla/image/tasks.py
@@ -264,6 +264,14 @@ class BuildTask(EngineTask):
def builder(self, image):
+ def _test_malicious_tarball(archive, path):
+ tar_file = tarfile.open(archive, 'r|gz')
+ for n in tar_file.getnames():
+ if not os.path.abspath(os.path.join(path, n)).startswith(path):
+ tar_file.close()
+ self.logger.error(f'Unsafe filenames in archive {archive}')
+ raise ArchivingError
+
def make_an_archive(items, arcname, item_child_path=None):
if not item_child_path:
item_child_path = arcname
@@ -277,8 +285,9 @@ class BuildTask(EngineTask):
archives.append(archive_path)
if archives:
for archive in archives:
+ _test_malicious_tarball(archive, items_path)
with tarfile.open(archive, 'r') as archive_tar:
- archive_tar.extractall(path=items_path)
+ archive_tar.extractall(path=items_path) # nosec
else:
try:
os.mkdir(items_path)
diff --git a/kolla/image/unbuildable.py b/kolla/image/unbuildable.py
index dc5183162..c27eb9593 100644
--- a/kolla/image/unbuildable.py
+++ b/kolla/image/unbuildable.py
@@ -24,6 +24,7 @@ UNBUILDABLE_IMAGES = {
# Issues for SHA1 keys:
# https://github.com/grafana/grafana/issues/41036
'centos': {
+ "bifrost-base", # EPEL-related breakage
"hacluster-pcs", # Missing crmsh package
"nova-spicehtml5proxy", # Missing spicehtml5 package
"ovsdpdk", # Not supported on CentOS
@@ -34,6 +35,7 @@ UNBUILDABLE_IMAGES = {
},
'rocky': {
+ "bifrost-base", # EPEL-related breakage
"hacluster-pcs", # Missing crmsh package
"nova-spicehtml5proxy", # Missing spicehtml5 package
"ovsdpdk", # Not supported on CentOS