fix(scan): check for required commands before scanning - #39
Open
joeymussalli wants to merge 1 commit into
Open
Conversation
Nothing guarantees the script's dependencies are present when it runs. The
CodePipeline buildspec tries to install jq and curl like this:
- command -v jq >/dev/null 2>&1 || { yum -y install jq || (apt-get ...); } >/dev/null 2>&1 || true
which discards the output and ends in `|| true`, so an install that fails --
unsupported base image, no network, no package manager, not root -- leaves the
build going with the tool missing and nothing said about it. The CodeCatalyst
workflow attempts no install at all; it just runs the script.
The failure that follows is misattributed. With jq absent, the guard that
validates trustabl.json cannot parse it and the run fails with "no usable
trustabl.json -- results cannot be trusted", pointing the user at the scan
result when the real problem is the build image. Worse is grep or head going
missing: the checksum lookup quietly yields an empty EXPECTED, the script
prints "not listed in checksums.txt -- skipping verification", and the release
binary runs unverified.
- Check curl, jq, tar, awk, grep, head and uname up front; on failure name
every missing command at once and exit 2, the code docs/EVALUATION.md already
documents as "scanner or I/O error ... the output should not be trusted".
- `git` is deliberately excluded. Every call is inside a guard, and without it
the script degrades to BR=unknown and REPO=$TARGET rather than breaking, so
requiring it would reject build images that work fine today.
- `tr` and `seq` are excluded because they ship in coreutils alongside `head`,
which is checked.
Left the buildspec's `|| true` alone on purpose. That fallback only matters
when the tool is genuinely absent and the install genuinely failed, and in that
case the preflight's message is more useful than a raw package-manager error
would be. Removing it would trade a clear diagnosis for a noisier one.
Verified against a sandboxed PATH: silent and exit 0 with everything present;
exit 2 naming exactly the missing tools for one, two and three of them removed;
and still exit 0 with git removed, confirming it stays optional.
joeymussalli
force-pushed
the
fix/preflight-dependency-check
branch
from
August 24, 2026 20:05
b356c52 to
5922a14
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nothing guarantees the script's dependencies are present when it runs. The CodePipeline buildspec tries to install jq and curl like this:
which discards the output and ends in
|| true, so an install that fails -- unsupported base image, no network, no package manager, not root -- leaves the build going with the tool missing and nothing said about it. The CodeCatalyst workflow attempts no install at all; it just runs the script.The failure that follows is misattributed. With jq absent, the guard that validates trustabl.json cannot parse it and the run fails with "no usable trustabl.json -- results cannot be trusted", pointing the user at the scan result when the real problem is the build image. Worse is grep or head going missing: the checksum lookup quietly yields an empty EXPECTED, the script prints "not listed in checksums.txt -- skipping verification", and the release binary runs unverified.
gitis deliberately excluded. Every call is inside a guard, and without it the script degrades to BR=unknown and REPO=$TARGET rather than breaking, so requiring it would reject build images that work fine today.trandseqare excluded because they ship in coreutils alongsidehead, which is checked.Left the buildspec's
|| truealone on purpose. That fallback only matters when the tool is genuinely absent and the install genuinely failed, and in that case the preflight's message is more useful than a raw package-manager error would be. Removing it would trade a clear diagnosis for a noisier one.Verified against a sandboxed PATH: silent and exit 0 with everything present; exit 2 naming exactly the missing tools for one, two and three of them removed; and still exit 0 with git removed, confirming it stays optional.