diff --git a/Dockerfile b/Dockerfile index c941fc478..8b17936a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,6 +48,7 @@ RUN apt-get update \ && apt-get install --no-install-recommends -y \ git \ ssh-client \ + libmagic1 \ gnupg \ ca-certificates \ && apt-get clean \ diff --git a/kapitan/utils.py b/kapitan/utils.py index a0745d1ce..14067cdba 100644 --- a/kapitan/utils.py +++ b/kapitan/utils.py @@ -9,6 +9,7 @@ import collections import json import logging +import magic import math import os import re @@ -530,6 +531,11 @@ def make_request(source): def unpack_downloaded_file(file_path, output_path, content_type): """unpacks files of various MIME type and stores it to the output_path""" + + if (content_type == None or content_type == "application/octet-stream"): + if re.search(r"^Zip archive data.*", magic.from_file(file_path)): + content_type = 'application/zip' + if content_type == "application/x-tar": tar = tarfile.open(file_path) tar.extractall(path=output_path) diff --git a/requirements.txt b/requirements.txt index a7a3a5e62..3a11561cf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -188,6 +188,8 @@ python-dateutil==2.8.2 # botocore python-gnupg==0.4.7 # via -r requirements.txt +python-magic==0.4.27 + # via -r requirements.txt pytz==2021.1 # via # -r requirements.txt