From e81cc3cefc8be016f736534d5dae8e552ad380c9 Mon Sep 17 00:00:00 2001 From: "Julian Borges MD, MS" Date: Mon, 24 Aug 2026 14:29:38 -0400 Subject: [PATCH] fix(install): do not resolve jq/awk through the downloaded release export PATH="$DEST:$PATH" put a just-extracted release tarball ahead of the system PATH, so every later jq and awk resolved out of it. Those compute the readiness score, risk score, finding count and max severity, so a release asset shipping its own jq would control the gate decision without touching the scanner binary. Bind the binary by path instead. jq is already required before the download exists (the latest-version lookup uses it), so it is a system prerequisite and nothing depended on the tarball providing it. Also match the asset name literally in the checksum lookup: $ASSET contains dots, which grep treats as wildcards, so an entry differing only at those positions could be selected. bash -n clean. No behaviour change for any input that works today. --- scan/trustabl-scan.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/scan/trustabl-scan.sh b/scan/trustabl-scan.sh index caa6314..b1bc94a 100644 --- a/scan/trustabl-scan.sh +++ b/scan/trustabl-scan.sh @@ -89,7 +89,11 @@ curl -fSL -H "Accept: application/octet-stream" "${AUTH[@]}" \ # ---- verify checksum (sha256 against the release checksums.txt) ---- if curl -fsSL "${AUTH[@]}" -o "$DEST/checksums.txt" \ "https://github.com/trustabl/trustabl/releases/download/${VER}/checksums.txt" 2>/dev/null; then - EXPECTED=$(grep " ${ASSET}\$" "$DEST/checksums.txt" | awk '{print $1}' | head -1) + # Match the asset name literally. $ASSET contains dots, which grep treats as + # wildcards, so a checksums.txt entry differing from the wanted asset only at + # those positions would satisfy the match. Compare field 2 for equality + # instead, allowing sha256sum's binary-mode "*" prefix. + EXPECTED=$(awk -v a="$ASSET" '$2 == a || $2 == "*" a { print $1 }' "$DEST/checksums.txt" | head -1) if [ -n "$EXPECTED" ]; then ACTUAL=$(sha256sum "$DEST/$ASSET" | awk '{print $1}') if [ "$EXPECTED" != "$ACTUAL" ]; then @@ -105,7 +109,14 @@ else fi tar -xzf "$DEST/$ASSET" -C "$DEST" -export PATH="$DEST:$PATH" +# Bind the downloaded binary by path rather than prepending $DEST to PATH. +# $DEST holds a just-extracted release tarball; putting it first on PATH means +# every later `jq` and `awk` in this script resolves out of that tarball, so a +# compromised release asset could supply its own jq and control every score the +# wrapper computes. jq is already required before the download exists (the +# "latest" version lookup above uses it), so it is a system prerequisite and +# nothing here depends on the tarball providing it. +TRUSTABL_BIN="$DEST/trustabl" # ---- scan ---- set +e @@ -134,11 +145,11 @@ BASE_ARGS=(scan "$TARGET") [ -n "$RULES_REF" ] && BASE_ARGS+=(--rules-ref "$RULES_REF") # Run 1: SARIF (file emit). -trustabl "${BASE_ARGS[@]}" --format sarif > "$SARIF_FILE" +"$TRUSTABL_BIN" "${BASE_ARGS[@]}" --format sarif > "$SARIF_FILE" NATIVE_CODE=$? # Run 2: JSON (drives thresholds, log summary, dotenv). -trustabl "${BASE_ARGS[@]}" --format json > "$JSON_FILE" || true +"$TRUSTABL_BIN" "${BASE_ARGS[@]}" --format json > "$JSON_FILE" || true SCAN_END=$(date -u +%Y-%m-%dT%H:%M:%S) # trustabl's overall_score is a float in [0.0, 1.0]; scale to [0,100] ints.