From 51b07d9436f821cbaa0d0f0e91a46e3bf36291a1 Mon Sep 17 00:00:00 2001 From: Felddy Date: Mon, 28 Aug 2023 19:20:45 -0400 Subject: [PATCH 1/2] Add file utility to image --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index e1291bb8b..ebf44f47b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -79,6 +79,7 @@ RUN addgroup --system --gid ${FOUNDRY_UID} foundry \ && adduser --system --uid ${FOUNDRY_UID} --ingroup foundry foundry \ && apk --update --no-cache add \ curl \ + file \ jq \ sed \ su-exec \ From f1b89baae9056957fc50edf30f1096008d66524f Mon Sep 17 00:00:00 2001 From: Felddy Date: Mon, 28 Aug 2023 19:25:39 -0400 Subject: [PATCH 2/2] Add logic to verify mime type of release archive --- src/entrypoint.sh | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 690f6cbd3..066b60aea 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -157,8 +157,31 @@ if [ $install_required = true ]; then if [ -f "${release_filename}" ]; then log "Installing Foundry Virtual Tabletop ${FOUNDRY_VERSION}" - unzip -q "${release_filename}" 'resources/*' - log_debug "Installation completed." + + # Check the mime-type of the file + log_debug "Checking mime-type of release file." + mime_type=$(file --mime-type --brief "${release_filename}") + log_debug "Found mime-type: ${mime_type}" + + # Check if the file is a zip archive + if [ "${mime_type}" = "application/zip" ]; then + log_debug "Extracting release file." + unzip -q "${release_filename}" 'resources/*' + log_debug "Installation completed." + elif [ "${mime_type}" = "application/vnd.microsoft.portable-executable" ]; then + log_error "The release file appears to be a Windows executable (.exe)." + log_error "Please provide the 'Linux/NodeJS' version of the release or URL." + exit 1 + elif [ "${mime_type}" = "application/zlib" ]; then + log_error "The release file appears to be a Mac disk image (.dmg)." + log_error "Please provide the 'Linux/NodeJS' version of the release or URL." + exit 1 + else + log_error "The release file does not contain the expected zip data." + log_error "Found: ${mime_type} instead of application/zip" + log_error "Make sure you provided the 'Linux/NodeJS' version of the release or URL." + exit 1 + fi else log_error "Unable to install Foundry Virtual Tabletop!" log_error "Either set FOUNDRY_RELEASE_URL."