From 632d2d74653ad09e6430cd6d6d1d9d5a0e4d4f40 Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Mon, 26 Oct 2026 15:18:29 +0100 Subject: [PATCH] Renovate-maintained tool pins: checksum script, PR check, auto tag Trivy and gitleaks were pinned (version + tarball SHA-256 + image digest) with nothing to bump them. Renovate (tth/renovate) now does; .gitea/update-checksums.sh recomputes the SHA-256s after a bump and checks them against the release checksums file; pr-check.yml runs the PR's actions with the Trivy container and with the pinned binary (checksum verified); tag.yml cuts the next vN after renovate-bot's merge. Co-Authored-By: Claude Opus 5.5 --- .gitea/update-checksums.sh | 47 ++++++++++++++++++++++++++++ .gitea/workflows/pr-check.yml | 58 +++++++++++++++++++++++++++++++++++ .gitea/workflows/tag.yml | 31 +++++++++++++++++++ README.md | 8 +++++ 4 files changed, 144 insertions(+) create mode 100644 .gitea/update-checksums.sh create mode 100644 .gitea/workflows/pr-check.yml create mode 100644 .gitea/workflows/tag.yml diff --git a/.gitea/update-checksums.sh b/.gitea/update-checksums.sh new file mode 100644 index 0000000..97c5847 --- /dev/null +++ b/.gitea/update-checksums.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# Recompute the pinned SHA-256 of the Trivy and gitleaks release tarballs +# after a version bump. Renovate runs it as a postUpgradeTask (tth/renovate +# config.json), so a bump PR carries matching checksums; by hand: +# bash .gitea/update-checksums.sh +# +# Each tarball is downloaded and hashed here, and the hash must ALSO match +# the release's own checksums file - the pin is what we verified at bump +# time, the action then refuses any other bytes. +set -euo pipefail +cd "$(dirname "$0")/.." +work=$(mktemp -d) +trap 'rm -rf "$work"' EXIT + +# pin ... +pin() { + local file=$1 vvar=$2 repo=$3 prefix=$4 + shift 4 + local ver + ver=$(sed -n "s/^ *$vvar: *\"\([0-9.]*\)\".*/\1/p" "$file") + [ -n "$ver" ] || { + echo "no $vvar in $file" >&2 + exit 1 + } + local base="https://github.com/$repo/releases/download/v$ver" + curl -fsSL --retry 3 -o "$work/sums" "$base/${prefix}_${ver}_checksums.txt" + while [ "$#" -gt 0 ]; do + local arch=$1 svar=$2 + shift 2 + local tgz="${prefix}_${ver}_${arch}.tar.gz" + curl -fsSL --retry 3 -o "$work/$tgz" "$base/$tgz" + local got want + got=$(sha256sum "$work/$tgz" | cut -d' ' -f1) + want=$(awk -v f="$tgz" '$2 == f {print $1}' "$work/sums") + [ "$got" = "$want" ] || { + echo "$tgz: downloaded $got, release says ${want:-nothing}" >&2 + exit 1 + } + sed -i "s/^\( *$svar: *\)[0-9a-f]\{64\}/\1$got/" "$file" + echo "$tgz $got" + done +} + +pin trivy-gate/action.yml TRIVY_VERSION aquasecurity/trivy trivy \ + Linux-64bit TRIVY_SHA256_AMD64 Linux-ARM64 TRIVY_SHA256_ARM64 +pin gitleaks/action.yml GITLEAKS_VERSION gitleaks/gitleaks gitleaks \ + linux_x64 GITLEAKS_SHA256_X64 linux_arm64 GITLEAKS_SHA256_ARM64 diff --git a/.gitea/workflows/pr-check.yml b/.gitea/workflows/pr-check.yml new file mode 100644 index 0000000..56e118c --- /dev/null +++ b/.gitea/workflows/pr-check.yml @@ -0,0 +1,58 @@ +# PR check (Renovate bumps of Trivy / gitleaks, and any other PR): the +# actions of THIS branch must actually run. Both runtimes of trivy-gate: +# the Trivy container (docker job) and the pinned binary with its checksum +# check (container job without Docker) - a bump with a wrong checksum fails +# here, not in every pipeline that uses the next tag. Required by branch +# protection, so a green PR automerges and tag.yml cuts the next vN. +name: pr-check +on: + pull_request: + +concurrency: + group: pr-check-${{ github.head_ref }} + cancel-in-progress: true + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: trivy-gate, Trivy container, image scan + id: image + uses: ./trivy-gate + with: + image: alpine:3.22@sha256:2e0b81d60597f449baa56dc25d355367869d2dca4cd57e866f1e2b52af3eb55f + runtime: docker + mode: warn + - name: The report is real + run: | + set -euo pipefail + jq -e '.Results | length > 0' "${{ steps.image.outputs.report }}" >/dev/null + echo "blocking=${{ steps.image.outputs.blocking }}" + - name: gitleaks + uses: ./gitleaks + with: + mode: block + + binary: + runs-on: ubuntu-latest + # No Docker CLI here, so trivy-gate falls back to the pinned binary. + container: + image: node:24-trixie-slim@sha256:43b9ba1142b8dcf33fa8f922ca1be85714adc444e0586c7cf7726daaeabc1bea + steps: + - name: Tools the actions expect + run: apt-get update -qq && apt-get install -y -qq --no-install-recommends ca-certificates curl git jq >/dev/null + - uses: actions/checkout@v4 + - name: trivy-gate, pinned binary, fs scan + id: fs + uses: ./trivy-gate + with: + scan-type: fs + runtime: binary + mode: warn + - name: The report is real + run: jq -e 'has("Results") or has("ArtifactName")' "${{ steps.fs.outputs.report }}" >/dev/null + - name: gitleaks, pinned binary + uses: ./gitleaks + with: + mode: block diff --git a/.gitea/workflows/tag.yml b/.gitea/workflows/tag.yml new file mode 100644 index 0000000..4e08661 --- /dev/null +++ b/.gitea/workflows/tag.yml @@ -0,0 +1,31 @@ +# Cut the next major tag (vN) when a Renovate bump of a pinned tool lands on +# main, so the pipelines get it through their own Renovate PR ("update +# ci-actions to vN"). Only renovate-bot's merges: hand-made changes keep +# being tagged by hand, with the README note. +name: tag +on: + push: + branches: [main] + +jobs: + tag: + if: github.actor == 'renovate-bot' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Next vN on HEAD + run: | + set -euo pipefail + git fetch -q --tags + if git tag --points-at HEAD | grep -qE '^v[0-9]+$'; then + echo "HEAD already tagged: $(git tag --points-at HEAD | tr '\n' ' ')"; exit 0 + fi + last=$(git tag -l 'v[0-9]*' | grep -E '^v[0-9]+$' | sed 's/^v//' | sort -n | tail -1) + next="v$((${last:-0} + 1))" + git tag "$next" HEAD + git push origin "refs/tags/$next" + echo "tagged $next on $(git rev-parse --short HEAD): $(git log -1 --format=%s)" diff --git a/README.md b/README.md index 145bacf..c52f48b 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,14 @@ binary is verified by SHA-256. `v3` gitleaks fetches the parent of a single commit in a depth-1 checkout (dispatch/cron runs scanned the whole tree as a root commit before). +Pinned tools (Trivy binary + image, gitleaks) are bumped by Renovate +(tth/renovate). Its post-upgrade task `.gitea/update-checksums.sh` +recomputes the tarball SHA-256 pins (downloaded and checked against the +release's checksums file); `.gitea/workflows/pr-check.yml` runs the actions +of the PR branch with both Trivy runtimes; after the merge `tag.yml` cuts +the next `vN`, which the pipelines then pick up through their own Renovate +PR. Hand-made changes are tagged by hand as before. + ## portainer-deploy Updates a Portainer Swarm stack from a compose file in the repository - the