Skip to content

Commit 35f35c3

Browse files
authored
feat(security): replace curl with gh release download and add attestation verification (#109)
- Replace unauthenticated curl download with gh release download authenticated via GH_TOKEN; avoids anonymous API rate limits on shared runners - Add gh attestation verify before tar extraction to validate SLSA v1 provenance published by block/goose since v1.28.0 - Add set -euo pipefail to install step; removes need for per-command error checks and empty-file guard - Replace mktemp file with mktemp -d directory; update trap accordingly - Add GH_TOKEN env to install step (scoped, not global) Aligns with clouatre-labs/aptu action.yml patterns. Closes #5994 Signed-off-by: Hugues Clouâtre <hugues@linux.com>
1 parent f89364c commit 35f35c3

1 file changed

Lines changed: 15 additions & 30 deletions

File tree

action.yml

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,20 @@ runs:
9494
id: install
9595
if: steps.cache-goose.outputs.cache-hit != 'true'
9696
shell: bash
97+
env:
98+
GH_TOKEN: ${{ github.token }}
9799
run: |
100+
set -euo pipefail
98101
VERSION="${{ steps.resolve-version.outputs.version }}"
99-
echo "::group::Installing Goose v$VERSION"
100102
mkdir -p ~/.local/bin
101-
102-
# Validate version format (semver: X.Y.Z or X.Y.Z-prerelease)
103+
echo "::group::Installing Goose v$VERSION"
104+
103105
VERSION="${VERSION#v}"
104106
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
105107
echo "::error::Invalid version format: '$VERSION'. Expected semver (e.g., 1.19.1 or 1.20.0-beta)"
106108
exit 1
107109
fi
108-
109-
# Determine architecture
110+
110111
ARCH="${{ runner.arch }}"
111112
if [ "$ARCH" = "X64" ]; then
112113
GOOSE_ARCH="x86_64"
@@ -116,31 +117,15 @@ runs:
116117
echo "::error::Unsupported architecture: $ARCH"
117118
exit 1
118119
fi
119-
120-
# Download and extract
121-
DOWNLOAD_URL="https://github.com/block/goose/releases/download/v$VERSION/goose-${GOOSE_ARCH}-unknown-linux-gnu.tar.bz2"
122-
echo "Downloading from: $DOWNLOAD_URL"
123-
124-
TEMP_TAR=$(mktemp)
125-
trap "rm -f $TEMP_TAR" EXIT
126-
127-
if ! curl -fsSL "$DOWNLOAD_URL" -o "$TEMP_TAR"; then
128-
echo "::error::Failed to download Goose. Check version and network."
129-
exit 1
130-
fi
131-
132-
if [ ! -s "$TEMP_TAR" ]; then
133-
echo "::error::Downloaded file is empty. Version $VERSION may not exist."
134-
exit 1
135-
fi
136-
137-
if ! tar -xj -C ~/.local/bin -f "$TEMP_TAR"; then
138-
echo "::error::Failed to extract Goose binary."
139-
exit 1
140-
fi
141-
142-
chmod +x ~/.local/bin/goose
143-
120+
121+
ARCHIVE="goose-${GOOSE_ARCH}-unknown-linux-gnu.tar.bz2"
122+
TEMP_DIR=$(mktemp -d)
123+
trap 'rm -rf "$TEMP_DIR"' EXIT
124+
echo "Downloading $ARCHIVE"
125+
gh release download "v${VERSION}" -R block/goose --pattern "${ARCHIVE}" -D "$TEMP_DIR"
126+
gh attestation verify "$TEMP_DIR/${ARCHIVE}" -R block/goose
127+
tar -xj -C ~/.local/bin -f "$TEMP_DIR/${ARCHIVE}"
128+
144129
echo "::endgroup::"
145130
146131
- name: Setup PATH

0 commit comments

Comments
 (0)