From ece67cd2aec82d661ba355ce6bc6e41bb88001b6 Mon Sep 17 00:00:00 2001 From: Michal Nasiadka Date: Tue, 26 Mar 2024 12:07:14 +0100 Subject: Check if archive is tarfile Change-Id: I802267d848c1dee722015b0d379bd9210f6c103e --- kolla/image/tasks.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/kolla/image/tasks.py b/kolla/image/tasks.py index 1242ecd8d..a36ba5cea 100644 --- a/kolla/image/tasks.py +++ b/kolla/image/tasks.py @@ -308,9 +308,14 @@ 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) # nosec + if tarfile.is_tarfile(archive): + _test_malicious_tarball(archive, items_path) + with tarfile.open(archive, 'r') as archive_tar: + archive_tar.extractall(path=items_path) # nosec + else: + self.logger.error("Archive %s is not a tarfile", + archive) + raise ArchivingError else: try: os.mkdir(items_path) -- cgit v1.2.3