Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion scripts/ci/_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -742,14 +742,15 @@ prepare_tauri_linuxdeploy_tools_cache() {
return 1
fi

local arch linuxdeploy_arch tools cache bash_path linuxdeploy_wrapper appimage_wrapper
local arch linuxdeploy_arch tools cache bash_path linuxdeploy_wrapper appimage_wrapper linuxdeploy_appdir_bin
arch="$(linuxdeploy_tools_arch)"
linuxdeploy_arch="${arch}"
tools="${MAPLE_NIX_TAURI_LINUXDEPLOY_TOOLS}"
cache="${TAURI_DIR}/target/.tauri"
bash_path="$(command -v bash)"
linuxdeploy_wrapper="${cache}/linuxdeploy-${linuxdeploy_arch}.AppImage"
appimage_wrapper="${cache}/linuxdeploy-plugin-appimage.AppImage"
linuxdeploy_appdir_bin="${cache}/linuxdeploy-${linuxdeploy_arch}.AppDir/usr/bin"

mkdir -p "${cache}"
install -m 0755 "${tools}/AppRun-${arch}" "${cache}/AppRun-${arch}"
Expand All @@ -761,6 +762,9 @@ prepare_tauri_linuxdeploy_tools_cache() {
extract_appimage_tool "${cache}/linuxdeploy-${linuxdeploy_arch}.real.AppImage" "${cache}/linuxdeploy-${linuxdeploy_arch}.AppDir"
extract_appimage_tool "${cache}/linuxdeploy-plugin-appimage.real.AppImage" "${cache}/linuxdeploy-plugin-appimage.AppDir"

install -m 0755 "${cache}/linuxdeploy-plugin-gtk.sh" "${linuxdeploy_appdir_bin}/linuxdeploy-plugin-gtk"
install -m 0755 "${cache}/linuxdeploy-plugin-gstreamer.sh" "${linuxdeploy_appdir_bin}/linuxdeploy-plugin-gstreamer"

cat > "${linuxdeploy_wrapper}" <<EOF
#!${bash_path}
set -euo pipefail
Expand Down Expand Up @@ -840,11 +844,66 @@ exec "\${real_plugin}" "\$@"
EOF
chmod +x "${appimage_wrapper}"

rm -f "${linuxdeploy_appdir_bin}/linuxdeploy-plugin-appimage"
cat > "${linuxdeploy_appdir_bin}/linuxdeploy-plugin-appimage" <<EOF
#!${bash_path}
set -euo pipefail

for arg in "\$@"; do
case "\${arg}" in
--plugin-type)
printf '%s\n' output
exit 0
;;
--plugin-api-version)
printf '%s\n' 0
exit 0
;;
esac
done

appdir=""
previous=""
for arg in "\$@"; do
if [ "\${previous}" = "--appdir" ]; then
appdir="\${arg}"
previous=""
continue
fi

case "\${arg}" in
--appdir=*)
appdir="\${arg#--appdir=}"
;;
--appdir)
previous="--appdir"
;;
esac
done

if [ -n "\${appdir}" ]; then
rm -f "\${appdir}/.DirIcon"
fi

real_plugin="$(printf '%q' "${cache}/linuxdeploy-plugin-appimage.AppDir/AppRun")"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 printf '%q' escaping conflicts with surrounding double quotes in generated script

On line 888, printf '%q' is used to shell-escape the ${cache} path, and the result is placed inside double quotes in the generated script. Since this is an unquoted <<EOF heredoc, the $(printf '%q' ...) is evaluated at generation time, and the escaped output is embedded literally into the generated script.

printf '%q' produces output meant to be used as unquoted shell input (e.g., a space becomes \ ). But when that output appears inside double quotes in the generated script (real_plugin="<escaped_output>"), the escaping semantics change: \ inside double quotes is not a recognized escape sequence, so the backslash is preserved literally. If ${cache} ever contains spaces or other special characters, the generated real_plugin variable will contain literal backslashes, causing the exec on line 895 to fail with a "No such file or directory" error.

Example of incorrect generated script when path has spaces

If cache = /home/my user/project/.tauri, printf '%q' outputs /home/my\ user/project/.tauri/..., and the generated script becomes:

real_plugin="/home/my\ user/project/.tauri/linuxdeploy-plugin-appimage.AppDir/AppRun"

The variable now contains a literal backslash instead of just a space.

Compare with the analogous appimage_wrapper script at scripts/ci/_common.sh:836 which correctly uses \${script_dir} (a runtime variable inside double quotes) — no printf '%q' needed. The fix here is to either drop printf '%q' and rely on the double quotes in the generated script, or remove the double quotes and let printf '%q' stand alone as an unquoted assignment.

Suggested change
real_plugin="$(printf '%q' "${cache}/linuxdeploy-plugin-appimage.AppDir/AppRun")"
real_plugin="${cache}/linuxdeploy-plugin-appimage.AppDir/AppRun"
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


if [ ! -x "\${real_plugin}" ]; then
echo "Missing extracted linuxdeploy AppImage plugin at \${real_plugin}" >&2
exit 1
fi

exec "\${real_plugin}" "\$@"
Comment on lines +888 to +895

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

tmp="$(mktemp -d "/tmp/maple verify.XXXXXX")"
mkdir -p "${tmp}"
touch "${tmp}/AppRun"
chmod +x "${tmp}/AppRun"

bad="$(printf '%q' "${tmp}/AppRun")"
good="${tmp}/AppRun"

echo "bad=${bad}"
echo "good=${good}"

[ -x "${good}" ] && echo "good path resolves"
if [ -x "${bad}" ]; then
  echo "unexpected: bad path resolved"
  exit 1
else
  echo "expected: %q-escaped value is not a valid filesystem path in variable context"
fi

Repository: OpenSecretCloud/Maple

Length of output: 236


Avoid printf '%q' when computing real_plugin
In scripts/ci/_common.sh, assigning real_plugin via printf '%q' can produce a value containing literal backslashes (e.g., for spaces). When later used in test -x/exec, that value won’t match the real filesystem path.

Suggested patch
-real_plugin="$(printf '%q' "${cache}/linuxdeploy-plugin-appimage.AppDir/AppRun")"
+real_plugin="${cache}/linuxdeploy-plugin-appimage.AppDir/AppRun"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
real_plugin="$(printf '%q' "${cache}/linuxdeploy-plugin-appimage.AppDir/AppRun")"
if [ ! -x "\${real_plugin}" ]; then
echo "Missing extracted linuxdeploy AppImage plugin at \${real_plugin}" >&2
exit 1
fi
exec "\${real_plugin}" "\$@"
real_plugin="${cache}/linuxdeploy-plugin-appimage.AppDir/AppRun"
if [ ! -x "\${real_plugin}" ]; then
echo "Missing extracted linuxdeploy AppImage plugin at \${real_plugin}" >&2
exit 1
fi
exec "\${real_plugin}" "\$@"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/ci/_common.sh` around lines 888 - 895, The assignment of real_plugin
using printf '%q' can inject backslashes and produce a non-matching path; change
the assignment in scripts/ci/_common.sh to set real_plugin to the raw path
(e.g., using direct expansion of
${cache}/linuxdeploy-plugin-appimage.AppDir/AppRun or resolving it with realpath
if normalization is needed) instead of printf '%q', and keep the existing quoted
checks ([ ! -x "${real_plugin}" ]) and exec ("${real_plugin}" "$@") so the test
-x and exec operate on the actual filesystem path.

EOF
chmod +x "${linuxdeploy_appdir_bin}/linuxdeploy-plugin-appimage"

print_file_hashes \
"${cache}/AppRun-${arch}" \
"${cache}/linuxdeploy-${linuxdeploy_arch}.real.AppImage" \
"${cache}/linuxdeploy-${linuxdeploy_arch}.AppImage" \
"${cache}/linuxdeploy-${linuxdeploy_arch}.AppDir/AppRun" \
"${linuxdeploy_appdir_bin}/linuxdeploy-plugin-appimage" \
"${linuxdeploy_appdir_bin}/linuxdeploy-plugin-gtk" \
"${linuxdeploy_appdir_bin}/linuxdeploy-plugin-gstreamer" \
"${cache}/linuxdeploy-plugin-appimage.real.AppImage" \
"${cache}/linuxdeploy-plugin-appimage.AppImage" \
"${cache}/linuxdeploy-plugin-appimage.AppDir/AppRun" \
Expand Down
Loading