Skip to content

Commit 486fe1f

Browse files
fix: correct v2.0.1 sha256s and harden update-formula sha256 validation
- Replace garbage 'Not' sha256 values (committed from 404 response) with the real v2.0.1 checksums: darwin-arm64: 435a330e3b2f9ad987740ef01be04445b823757fe83fb3a2620f836acbf6fce7 linux-x86_64: 426eacde20837835674cd04397caa2407bd1e2a4f41bda738254b41298e4da9d - Switch curl to -f so HTTP 4xx/5xx errors are fatal (prevents silent 404 body capture) - Add regex validation: abort with a clear error if the downloaded sha256 is not exactly 64 lowercase hex chars, preventing garbage commits like 7989b4a Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 7989b4a commit 486fe1f

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

.github/workflows/update-formula.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,31 @@ jobs:
2424
CLEAN_VERSION="${VERSION#v}"
2525
echo "version=${CLEAN_VERSION}" >> $GITHUB_OUTPUT
2626
27-
# Download checksums
27+
# Download checksums — fail if assets return 404 or content is not a 64-char hex string
2828
BASE_URL="https://github.com/amberframework/amber_cli/releases/download/${VERSION}"
2929
30-
curl -sL "${BASE_URL}/amber_cli-darwin-arm64.tar.gz.sha256" -o darwin.sha256
31-
curl -sL "${BASE_URL}/amber_cli-linux-x86_64.tar.gz.sha256" -o linux.sha256
32-
33-
echo "darwin_sha256=$(cut -d' ' -f1 < darwin.sha256)" >> $GITHUB_OUTPUT
34-
echo "linux_sha256=$(cut -d' ' -f1 < linux.sha256)" >> $GITHUB_OUTPUT
30+
curl -fsSL "${BASE_URL}/amber_cli-darwin-arm64.tar.gz.sha256" -o darwin.sha256 || {
31+
echo "ERROR: failed to download darwin sha256 for ${VERSION}" >&2; exit 1
32+
}
33+
curl -fsSL "${BASE_URL}/amber_cli-linux-x86_64.tar.gz.sha256" -o linux.sha256 || {
34+
echo "ERROR: failed to download linux sha256 for ${VERSION}" >&2; exit 1
35+
}
36+
37+
DARWIN_SHA="$(cut -d' ' -f1 < darwin.sha256)"
38+
LINUX_SHA="$(cut -d' ' -f1 < linux.sha256)"
39+
40+
# Validate: must be exactly 64 lowercase hex characters
41+
if ! echo "${DARWIN_SHA}" | grep -qE '^[0-9a-f]{64}$'; then
42+
echo "ERROR: darwin sha256 is not a valid 64-char hex string: '${DARWIN_SHA}'" >&2
43+
exit 1
44+
fi
45+
if ! echo "${LINUX_SHA}" | grep -qE '^[0-9a-f]{64}$'; then
46+
echo "ERROR: linux sha256 is not a valid 64-char hex string: '${LINUX_SHA}'" >&2
47+
exit 1
48+
fi
49+
50+
echo "darwin_sha256=${DARWIN_SHA}" >> $GITHUB_OUTPUT
51+
echo "linux_sha256=${LINUX_SHA}" >> $GITHUB_OUTPUT
3552
3653
- name: Update formula
3754
env:

Formula/amber_cli.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ class AmberCli < Formula
1414
on_macos do
1515
if Hardware::CPU.arm?
1616
url "https://github.com/amberframework/amber_cli/releases/download/v2.0.1/amber_cli-darwin-arm64.tar.gz"
17-
sha256 "Not"
17+
sha256 "435a330e3b2f9ad987740ef01be04445b823757fe83fb3a2620f836acbf6fce7"
1818
end
1919
end
2020

2121
on_linux do
2222
if Hardware::CPU.intel?
2323
url "https://github.com/amberframework/amber_cli/releases/download/v2.0.1/amber_cli-linux-x86_64.tar.gz"
24-
sha256 "Not"
24+
sha256 "426eacde20837835674cd04397caa2407bd1e2a4f41bda738254b41298e4da9d"
2525
end
2626
end
2727

0 commit comments

Comments
 (0)