Skip to content

Commit 5ff2e30

Browse files
feat: add provenance verification (#107)
* feat: add provenance verification * cleanup * Update action.yml Co-authored-by: Gerald Pinder <gmpinder@gmail.com> * comment * policy enforcement * remove sed --------- Co-authored-by: Gerald Pinder <gmpinder@gmail.com>
1 parent c1c1e56 commit 5ff2e30

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

action.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ inputs:
104104
and to modify files (such as supplying build information to other scripts) before building.
105105
required: false
106106
default: "false"
107-
cosign_verify_cli:
107+
verify_install:
108108
description: |
109109
Set to true verify the cosign signature for the Blue-Build cli
110110
required: false
@@ -163,14 +163,18 @@ runs:
163163
install-dir: /usr/bin
164164
use-sudo: true
165165

166+
- name: Install the slsa-verifier
167+
if: ${{ inputs.verify_install == 'true' }}
168+
uses: slsa-framework/slsa-verifier/actions/installer@ea584f4502babc6f60d9bc799dbbb13c1caa9ee6 # v2.7.1
169+
166170
# clones user's repo
167171
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
168172
if: ${{ inputs.skip_checkout == 'false' }}
169173
with:
170174
persist-credentials: false
171175

172176
- name: Set container policy to validate Blue-Build cli signature
173-
if: ${{ inputs.cosign_verify_cli == 'true' }}
177+
if: ${{ inputs.verify_install == 'true' }}
174178
shell: bash
175179
run: |
176180
POLICY_FILE="/etc/containers/policy.json"
@@ -221,12 +225,20 @@ runs:
221225
run: |
222226
if [[ "${USE_UNSTABLE_CLI}" == "true" && -z "${CLI_VERSION}" ]]; then
223227
CLI_VERSION_TAG="main"
228+
REPO_TAG="main"
229+
VERIFY_FLAG="--source-branch"
224230
elif [ -n "${CLI_VERSION}" ]; then
225231
CLI_VERSION_TAG="${CLI_VERSION}"
232+
REPO_TAG="${CLI_VERSION}"
233+
VERIFY_FLAG="--source-tag"
226234
else
235+
REPO_TAG=$(curl -s https://api.github.com/repos/blue-build/cli/tags | jq -r '.[0].name')
227236
CLI_VERSION_TAG="v0.9"
237+
VERIFY_FLAG="--source-tag"
228238
fi
229239
echo "cli_version=${CLI_VERSION_TAG}" >> "${GITHUB_OUTPUT}"
240+
echo "repo_tag=${REPO_TAG}" >> "${GITHUB_OUTPUT}"
241+
echo "verify_flag=${VERIFY_FLAG}" >> "${GITHUB_OUTPUT}"
230242
231243
RECIPE_PATH=""
232244
if [ -f "./config/${RECIPE}" ]; then
@@ -240,10 +252,22 @@ runs:
240252
shell: bash
241253
env:
242254
CLI_VERSION_TAG: ${{ steps.build_vars.outputs.cli_version }}
255+
REPO_TAG: ${{ steps.build_vars.outputs.repo_tag }}
256+
VERIFY_FLAG: ${{ steps.build_vars.outputs.verify_flag }}
257+
VERIFY_INSTALL: ${{ inputs.verify_install }}
243258
run: |
259+
set -euo pipefail
260+
CLI_INSTALLER_IMAGE="ghcr.io/blue-build/cli:${CLI_VERSION_TAG}-installer"
261+
if [ "$VERIFY_INSTALL" = "true" ]; then
262+
docker pull "${CLI_INSTALLER_IMAGE}"
263+
CLI_INSTALLER_IMAGE=$(docker inspect --format='{{index .RepoDigests 0}}' "${CLI_INSTALLER_IMAGE}")
264+
slsa-verifier verify-image "${CLI_INSTALLER_IMAGE}" \
265+
--source-uri github.com/blue-build/cli \
266+
"${VERIFY_FLAG}" "${REPO_TAG}"
267+
fi
244268
sudo docker create \
245269
--name blue-build-installer \
246-
"ghcr.io/blue-build/cli:${CLI_VERSION_TAG}-installer"
270+
"${CLI_INSTALLER_IMAGE}"
247271
sudo docker cp blue-build-installer:/out/bluebuild /usr/bin/bluebuild
248272
sudo docker rm blue-build-installer
249273
bluebuild --version

0 commit comments

Comments
 (0)