-
Notifications
You must be signed in to change notification settings - Fork 189
install.sh: silent failure when cosign reports non-semver version #578
Description
Problem
install.sh silently exits with code 1 and no error message when cosign is installed but reports a non-standard version string. This happens on systems where cosign was installed via a distro package manager (e.g. apt on Debian) rather than from the official GitHub releases.
Root cause
Lines 269-272 of install.sh parse the cosign version:
COSIGN_MAJOR_VERSION=$(cosign version | grep GitVersion | sed 's/GitVersion:[[:space:]]*v\{0,1\}//' | grep -oE '^[0-9]+')
if [[ "$COSIGN_MAJOR_VERSION" -lt 2 ]]; then
echo "Warning: cosign version is less than 2.0.0, signature validation may fail."
fiWhen cosign is built from source by a distro packager without setting -ldflags, it reports:
GitVersion: devel
instead of e.g. GitVersion: v2.5.0. The pipeline then yields an empty COSIGN_MAJOR_VERSION, and the integer comparison [[ "" -lt 2 ]] fails. Because set -euo pipefail is active, the script exits immediately -- before any output is printed to the user.
How to reproduce
-
Install cosign via
apton Debian trixie (arm64):sudo apt install cosignThis installs cosign 2.5.0, but the binary reports
GitVersion: devel. -
Run the install script:
curl -fsSL https://raw.githubusercontent.com/opengrep/opengrep/main/install.sh | bashThe script exits silently with code 1.
Suggested fix
Guard the version comparison so that an unparseable version does not crash the script. For example:
COSIGN_MAJOR_VERSION=$(cosign version | grep GitVersion | sed 's/GitVersion:[[:space:]]*v\{0,1\}//' | grep -oE '^[0-9]+' || true)
if [[ -z "$COSIGN_MAJOR_VERSION" ]]; then
echo "Warning: could not determine cosign version. Signature validation may not work correctly."
elif [[ "$COSIGN_MAJOR_VERSION" -lt 2 ]]; then
echo "Warning: cosign version is less than 2.0.0, signature validation may fail."
fiEnvironment
- Debian trixie (13), aarch64 (Raspberry Pi)
- cosign 2.5.0 installed via
apt(dpkg -l cosignshows2.5.0-2+b4) cosign versionoutput:GitVersion: devel