Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
patchelf
desktop-file-utils
rpm
squashfsTools
webkitgtk_4_1
xdg-utils
];
Expand Down
15 changes: 13 additions & 2 deletions scripts/ci/_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -855,12 +855,23 @@ EOF
extract_appimage_tool() {
local appimage="$1"
local out="$2"
local tmp
local offset tmp

command -v unsquashfs >/dev/null 2>&1 || {
echo "unsquashfs is required to extract AppImage tools without executing their runtime." >&2
return 1
}

offset="$(LC_ALL=C grep -abo -m1 'hsqs' "${appimage}" | awk -F: '{ print $1 }' || true)"

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:

#!/bin/bash
set -euo pipefail

tmp="$(mktemp)"
trap 'rm -f "${tmp}"' EXIT

printf 'xxhsqsyyhsqszz' > "${tmp}"

echo "current command output:"
LC_ALL=C grep -abo -m1 'hsqs' "${tmp}"

echo
echo "single offset output:"
LC_ALL=C grep -abo 'hsqs' "${tmp}" | awk -F: 'NR == 1 { print $1; exit }'

Repository: OpenSecretCloud/Maple

Length of output: 128


🏁 Script executed:

#!/bin/bash
set -euo pipefail

tmp="$(mktemp)"
trap 'rm -f "${tmp}"' EXIT

printf 'xxhsqsyyhsqszz' > "${tmp}"

echo "current command output:"
LC_ALL=C grep -abo -m1 'hsqs' "${tmp}"

echo
echo "single offset output:"
LC_ALL=C grep -abo 'hsqs' "${tmp}" | awk -F: 'NR == 1 { print $1; exit }'

Repository: OpenSecretCloud/Maple

Length of output: 128


Fix offset extraction to use only the first -o match (not just the first matching line).

grep -abo -m1 'hsqs' stops after the first matching line, but with -o it can still emit multiple offset:hsqs records from the same line. For a newline-free sample, it outputs 2:hsqs and 8:hsqs (so offset becomes multiline), while the “first record only” pipeline outputs only 2.

Suggested fix
-  offset="$(LC_ALL=C grep -abo -m1 'hsqs' "${appimage}" | awk -F: '{ print $1 }' || true)"
+  offset="$(
+    LC_ALL=C grep -abo 'hsqs' "${appimage}" \
+      | awk -F: 'NR == 1 { print $1; exit }' \
+      || true
+  )"
📝 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
offset="$(LC_ALL=C grep -abo -m1 'hsqs' "${appimage}" | awk -F: '{ print $1 }' || true)"
offset="$(
LC_ALL=C grep -abo 'hsqs' "${appimage}" \
| awk -F: 'NR == 1 { print $1; exit }' \
|| true
)"
🤖 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` at line 865, The current offset assignment (variable
offset) can become multiline because grep -abo -m1 'hsqs' with -o may emit
multiple matches from the same line; change the pipeline so only the first -o
match is considered before extracting the byte position: after the grep call
that currently reads grep -abo -m1 'hsqs' "${appimage}", select the first output
record (e.g., pipe to head -n1 or make awk only handle NR==1) and then extract
the byte offset (the awk field { print $1 }) so offset is a single value.

if [ -z "${offset}" ]; then
echo "Could not locate embedded SquashFS payload in AppImage: ${appimage}" >&2
return 1
fi

tmp="$(mktemp -d)"
rm -rf "${out}"

if ! (cd "${tmp}" && "${appimage}" --appimage-extract >/dev/null); then
if ! unsquashfs -d "${tmp}/squashfs-root" -o "${offset}" "${appimage}" >/dev/null; then
rm -rf "${tmp}"
return 1
fi
Expand Down
Loading