From 67cfc116b9b0f89054e7552f94b5295be1aced4e Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Sat, 3 Oct 2026 17:37:36 +0300 Subject: [PATCH] -redundant check invalid-format checksums will be rejected during comparison anyway --- plugins/pyenv-binary/libexec/pyenv-binary-install | 6 +----- plugins/pyenv-binary/test/install.bats | 14 -------------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/plugins/pyenv-binary/libexec/pyenv-binary-install b/plugins/pyenv-binary/libexec/pyenv-binary-install index 18c6fa44..f52c7b6d 100755 --- a/plugins/pyenv-binary/libexec/pyenv-binary-install +++ b/plugins/pyenv-binary/libexec/pyenv-binary-install @@ -106,10 +106,6 @@ if grep -qxF -- "$entry" <<<"$definitions"; then exit fi -if ! [[ "$expected_sha" =~ ^[0-9a-fA-F]{64}$ ]]; then - echo "pyenv-binary: invalid checksum for $entry" >&2 - exit 1 -fi expected_sha="$(printf '%s' "$expected_sha" | tr '[:upper:]' '[:lower:]')" curl -fsSL -o "$tmpdir/$entry" "$base_url/$entry" @@ -123,7 +119,7 @@ else echo "pyenv-binary: need sha256sum, shasum or openssl to verify $entry" >&2 exit 1 fi -if [ "$actual_sha" != "$expected_sha" ]; then +if [[ $expected_sha != "$actual_sha" ]]; then echo "pyenv-binary: checksum mismatch for $entry" >&2 exit 1 fi diff --git a/plugins/pyenv-binary/test/install.bats b/plugins/pyenv-binary/test/install.bats index 028e207d..6b71024e 100644 --- a/plugins/pyenv-binary/test/install.bats +++ b/plugins/pyenv-binary/test/install.bats @@ -102,20 +102,6 @@ STUB [ ! -e "$BATS_TEST_TMPDIR/downloaded" ] } -@test "rejects an invalid published checksum when definition lookup fails" { - create_stub lsb_release 'case "$1" in -si) echo Ubuntu;; -sr) echo 24.04;; esac' - use_manifest - printf '3.14.7\t3.14.7-ubuntu-24.04-x86_64\tLinux\tx86_64\t%s\tinvalid\n' \ - "$(host_distro)" >> "$BATS_TEST_TMPDIR/plugin/share/pyenv-binary/versions/3.14" - create_stub uname 'case "$1" in -s) echo Linux;; -m) echo x86_64;; esac' - create_stub pyenv-install 'exit 1' - create_stub curl 'touch "$BATS_TEST_TMPDIR/downloaded"; exit 1' - - run pyenv-binary-install 3.14.7 - assert_failure "pyenv-binary: invalid checksum for 3.14.7-ubuntu-24.04-x86_64" - [ ! -e "$BATS_TEST_TMPDIR/downloaded" ] -} - @test "installs a matching published binary with an uppercase checksum" { create_stub lsb_release 'case "$1" in -si) echo Ubuntu;; -sr) echo 24.04;; esac' use_manifest