Skip to content

Commit bb6be4b

Browse files
committed
fix(kwctl-installer): wrong signature verification
In a recent kwctl-installer change the script used to download and verify the kwctl binary has a bug. The script is trying to download a file that does not existe in the release page. The sigstore bundle required to perform the verification is inside the zip file together with the binary. Therefore, the script should use the file from the bundle to verify the binary before installation. This commit does this issue. Assisted-by: Github Copilot Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com>
1 parent 0f1672d commit bb6be4b

2 files changed

Lines changed: 29 additions & 10 deletions

File tree

kwctl-installer/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
This action downloads latest stable release of kwctl and installs that inside
44
of the GitHub action path.
55

6+
The downloaded zip contains both the `kwctl` binary and its
7+
`.bundle.sigstore` file. The action verifies the extracted binary with
8+
`cosign verify-blob` before installation.
9+
10+
> [!NOTE]
11+
> This action installs `cosign`
12+
613
## Inputs
714

815
* `KWCTL_VERSION`: (**optional**) the version of kwctl to be downloaded

kwctl-installer/action.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,45 @@ inputs:
77
kwctl-version:
88
description: "kwctl release to be installed"
99
required: false
10-
default: "v1.33.1"
10+
default: "v1.34.2"
1111
runs:
1212
using: "composite"
1313
steps:
14+
- uses: sigstore/cosign-installer@cad07c2e89fa2edd6e2d7bab4c1aa38e53f76003 # v4.1.1
15+
1416
- shell: bash
1517
run: |
1618
#!/bin/bash
17-
set -e
19+
set -euo pipefail
1820
1921
KWCTL_VERSION="${{ inputs.kwctl-version }}"
22+
SEMVER_PATTERN='^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'
23+
24+
if [[ ! "$KWCTL_VERSION" =~ $SEMVER_PATTERN ]]; then
25+
echo "Invalid kwctl-version: '$KWCTL_VERSION'. Expected format: v<major>.<minor>.<patch> (optional pre-release/build metadata)."
26+
exit 1
27+
fi
2028
2129
# Build name of gihub release asset
2230
OS=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]' | sed 's/macos/darwin/')
2331
ARCH=$(echo "${{ runner.arch }}" | sed -E 's/X64/x86_64/; s/ARM64/aarch64/')
2432
ASSET="kwctl-${OS}-${ARCH}"
2533
2634
INSTALL_DIR=$HOME/.kwctl
35+
ZIP_FILE=$INSTALL_DIR/$ASSET.zip
36+
BUNDLE_FILE=$INSTALL_DIR/$ASSET.bundle.sigstore
2737
2838
mkdir -p $INSTALL_DIR
29-
curl -sL https://github.com/kubewarden/kubewarden-controller/releases/download/${KWCTL_VERSION}/${ASSET}.zip -o $INSTALL_DIR/$ASSET.zip
30-
curl -sL https://github.com/kubewarden/kubewarden-controller/releases/download/${KWCTL_VERSION}/${ASSET}.zip.bundle.sigstore \
31-
-o $INSTALL_DIR/$ASSET.zip.bundle.sigstore
32-
gh attestation verify $INSTALL_DIR/$ASSET.zip \
33-
--bundle $INSTALL_DIR/$ASSET.zip.bundle.sigstore \
34-
--repo kubewarden/kubewarden-controller
35-
unzip -o $INSTALL_DIR/$ASSET.zip -d $INSTALL_DIR
36-
rm $INSTALL_DIR/$ASSET.zip
39+
curl -fsSL https://github.com/kubewarden/kubewarden-controller/releases/download/${KWCTL_VERSION}/${ASSET}.zip -o $ZIP_FILE
40+
unzip -o $ZIP_FILE -d $INSTALL_DIR
41+
rm $ZIP_FILE
42+
43+
cosign verify-blob \
44+
--certificate-oidc-issuer=https://token.actions.githubusercontent.com \
45+
--certificate-identity="https://github.com/kubewarden/kubewarden-controller/.github/workflows/build-kwctl.yml@refs/tags/${KWCTL_VERSION}" \
46+
--bundle $BUNDLE_FILE \
47+
$INSTALL_DIR/$ASSET
48+
rm $BUNDLE_FILE
3749
3850
mv $INSTALL_DIR/$ASSET $INSTALL_DIR/kwctl
3951
chmod 755 $INSTALL_DIR/kwctl

0 commit comments

Comments
 (0)