diff --git a/.github/workflows/selftest.yml b/.github/workflows/selftest.yml index 6ac5705..6828c9a 100644 --- a/.github/workflows/selftest.yml +++ b/.github/workflows/selftest.yml @@ -76,6 +76,8 @@ jobs: run: bash scripts/test_pr.sh - name: publish.sh unit tests run: bash scripts/test_publish.sh + - name: tools.lock has every tool for x86_64 and arm64 + run: bash scripts/test_tools_lock.sh # Public repository: no internal document names or plan IDs. - name: public-repo hygiene run: | @@ -84,6 +86,65 @@ jobs: exit 1 fi + # Every tool of tools.lock installs on an arm64 runner as an arm64 binary + # and runs. + tools-arm64: + runs-on: ubuntu-24.04-arm + timeout-minutes: 10 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: install every tool + run: | + mapfile -t tools < <(awk '!/^#/ && NF && $1 !~ /\// { print $1 }' tools.lock) + scripts/install-tool.sh "${tools[@]}" + - name: each is an arm64 binary and runs + run: | + fail=0 + while read -r tool args; do + bin=$RUNNER_TEMP/bin/$tool + if ! file -L "$bin" | grep -q 'ARM aarch64'; then + echo "::error::$tool is not an arm64 binary: $(file -L "$bin")" + fail=1 + continue + fi + # shellcheck disable=SC2086 # the arguments are space-separated words + if out=$("$bin" $args 2>&1); then + echo "$tool: $(echo "$out" | head -n 1)" + else + echo "::error::$tool $args failed: $out" + fail=1 + fi + done <<'TOOLS' + gitleaks version + trivy --version + osv-scanner --version + actionlint -version + zizmor --version + pinact --version + shellcheck --version + shfmt --version + just --version + kubeconform -v + helm version --short + bun --version + uv --version + uvx --version + TOOLS + exit "$fail" + + # The shell gate's native arm64 build (build-runs-on), as an image builder + # for arm64 targets uses it. + shell-gate-arm64: + uses: ./.github/workflows/shell-gate.yml + with: + working-directory: tests/fixtures/shell-pass + skip: lint,unit + build-args: out + build-runs-on: ubuntu-24.04-arm + harness-ref: ${{ github.sha }} + # The release signer callers run from their harness checkout # (tools/sign-openpgp): its tests sign with a development key and check the # signatures with gpgv, as an appliance or device does. @@ -518,7 +579,7 @@ jobs: # above succeeded (skipped or cancelled counts as failed). selftest-ok: if: ${{ always() }} - needs: [lint-self, lint-templates, lint-planted, scripts, gate-pass, gate-fail, node-gate-npm, node-gate-npm-tools, node-gate-bun, node-gate-fail, python-gate-pass, python-gate-fail, shell-gate-pass, shell-gate-artifact, shell-gate-fail, security-clean, security-clean-node, security-planted, config-scan-skipped-chart, security-helm, release-dry-run, release-dry-run-package-json, build-context-artifact, release-dry-run-build-context, release-dry-run-image-tag, assert-image-tag, assert-planted] + needs: [lint-self, lint-templates, lint-planted, scripts, gate-pass, gate-fail, node-gate-npm, node-gate-npm-tools, node-gate-bun, node-gate-fail, python-gate-pass, python-gate-fail, shell-gate-pass, shell-gate-artifact, shell-gate-fail, shell-gate-arm64, tools-arm64, security-clean, security-clean-node, security-planted, config-scan-skipped-chart, security-helm, release-dry-run, release-dry-run-package-json, build-context-artifact, release-dry-run-build-context, release-dry-run-image-tag, assert-image-tag, assert-planted] runs-on: ubuntu-latest timeout-minutes: 5 steps: diff --git a/README.md b/README.md index d1cace7..1e6e74a 100644 --- a/README.md +++ b/README.md @@ -261,6 +261,10 @@ The summary lists exceptions that expire within 30 days. [tools.lock](tools.lock) and installed by [scripts/install-tool.sh](scripts/install-tool.sh); Go tools and semgrep are pinned in the workflows' `env` blocks; actions are pinned to commit SHAs. + Every tool has an x86_64 line and a `/arm64` line at the same version; + `install-tool.sh` takes the one of the runner's architecture, so callers and + the gates' `build-runs-on: ubuntu-24.04-arm` work on arm64 runners. + `scripts/test_tools_lock.sh` keeps the two lines in step. - **Self-test.** [selftest.yml](.github/workflows/selftest.yml) runs on every pull request and weekly. The fixtures plant one finding per scanner (a fake key, a reachable call into a vulnerable `golang.org/x/text`, a secret written to diff --git a/scripts/install-tool.sh b/scripts/install-tool.sh index 2f886e1..c275f09 100755 --- a/scripts/install-tool.sh +++ b/scripts/install-tool.sh @@ -3,6 +3,7 @@ # install-tool.sh [...] # Installs into $TOOLS_BIN (default $RUNNER_TEMP/bin, else ~/.local/bin) and # appends that directory to $GITHUB_PATH when running in GitHub Actions. +# On an arm64 runner it takes the /arm64 entry; the binary keeps its name. set -euo pipefail here=$(cd "$(dirname "$0")/.." && pwd) @@ -14,9 +15,16 @@ trap 'rm -rf "$work"' EXIT [ "$#" -gt 0 ] || { echo "usage: install-tool.sh ..." >&2; exit 2; } +machine=${INSTALL_TOOL_MACHINE:-$(uname -m)} +case "$machine" in + x86_64 | amd64) suffix="" ;; + aarch64 | arm64) suffix=/arm64 ;; + *) echo "install-tool: tools.lock has no entries for $machine" >&2; exit 1 ;; +esac + for name in "$@"; do - line=$(awk -v n="$name" '$1 == n { print; exit }' "$lock") - [ -n "$line" ] || { echo "install-tool: $name is not in tools.lock" >&2; exit 1; } + line=$(awk -v n="$name$suffix" '$1 == n { print; exit }' "$lock") + [ -n "$line" ] || { echo "install-tool: $name$suffix is not in tools.lock" >&2; exit 1; } read -r _ version sha url member <<<"$line" dir="$work/$name" mkdir -p "$dir" diff --git a/scripts/test_tools_lock.sh b/scripts/test_tools_lock.sh new file mode 100755 index 0000000..95b3e36 --- /dev/null +++ b/scripts/test_tools_lock.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# tools.lock is well-formed and every tool has an arm64 entry at its version: +# bash scripts/test_tools_lock.sh +set -euo pipefail +lock="$(cd "$(dirname "$0")/.." && pwd)/tools.lock" +fail=0 +bad() { + echo "tools.lock: $*" >&2 + fail=1 +} + +declare -A version +while read -r name ver sha url member extra; do + case "$name" in '' | '#'*) continue ;; esac + [ -n "$member" ] && [ -z "$extra" ] || bad "$name: want 5 fields" + [[ "$sha" =~ ^[0-9a-f]{64}$ ]] || bad "$name: sha256 is not 64 hex digits" + [[ "$url" == https://* ]] || bad "$name: url is not https" + [ -z "${version[$name]+set}" ] || bad "$name is listed twice" + version[$name]=$ver +done <"$lock" + +for name in "${!version[@]}"; do + case "$name" in + */arm64) + base=${name%/arm64} + [ -n "${version[$base]+set}" ] || bad "$name has no x86_64 entry $base" + [ "${version[$base]:-}" = "${version[$name]}" ] || bad "$name is ${version[$name]}, $base ${version[$base]:-missing}" + ;; + */*) bad "$name: the only architecture suffix is /arm64" ;; + *) [ -n "${version[$name/arm64]+set}" ] || bad "$name has no $name/arm64 entry" ;; + esac +done +[ "$fail" = 0 ] && echo "tools.lock: ${#version[@]} entries, every tool for x86_64 and arm64" +exit "$fail" diff --git a/tools.lock b/tools.lock index 4bd33d8..380ee57 100644 --- a/tools.lock +++ b/tools.lock @@ -1,24 +1,40 @@ -# Scanner and linter binaries installed by scripts/install-tool.sh (linux/amd64 runners). -# One line per tool: name version sha256 url member +# Scanner and linter binaries installed by scripts/install-tool.sh (Linux runners). +# One line per tool and architecture: name version sha256 url member +# name the tool for x86_64 (amd64) runners; /arm64 for arm64 runners +# (ubuntu-24.04-arm), same version, next to it # sha256 digest of the downloaded file, as published in the release metadata # member path of the binary inside the archive, or "-" for a bare binary -# Update: bump version + url, take the sha256 from the release asset's digest +# Update: bump version + url of both lines, take the sha256 from the release asset's digest # (gh api repos///releases/tags/ --jq '.assets[] | [.name, .digest]'), # then let selftest.yml prove the new version still finds every planted finding. # # Go tools are not listed here: they run as `go run @` and are # verified by the Go checksum database (versions in the workflows' env blocks). gitleaks 8.30.1 551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_x64.tar.gz gitleaks +gitleaks/arm64 8.30.1 e4a487ee7ccd7d3a7f7ec08657610aa3606637dab924210b3aee62570fb4b080 https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_arm64.tar.gz gitleaks trivy 0.76.0 e24b1c51293c1b15e4ba8d45bbc7891ba053f90278ec2698f3562c993e145fe7 https://github.com/aquasecurity/trivy/releases/download/v0.76.0/trivy_0.76.0_Linux-64bit.tar.gz trivy +trivy/arm64 0.76.0 aab21e677a7b7071fc79f1711480840754c18a1b9d9cefa7ccd06af63a0e8f4c https://github.com/aquasecurity/trivy/releases/download/v0.76.0/trivy_0.76.0_Linux-ARM64.tar.gz trivy osv-scanner 2.7.0 160c6253e2922e9e0a6a9771c5c4c40a4b3c6090b34a3cdd5e80c96cc2e4218b https://github.com/google/osv-scanner/releases/download/v2.7.0/osv-scanner_linux_amd64 - +osv-scanner/arm64 2.7.0 4061ef4c021ed3c47f203b818f337e351336cc5cd67c0274fc36bd1dfc728dd7 https://github.com/google/osv-scanner/releases/download/v2.7.0/osv-scanner_linux_arm64 - actionlint 1.7.12 8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8 https://github.com/rhysd/actionlint/releases/download/v1.7.12/actionlint_1.7.12_linux_amd64.tar.gz actionlint +actionlint/arm64 1.7.12 325e971b6ba9bfa504672e29be93c24981eeb1c07576d730e9f7c8805afff0c6 https://github.com/rhysd/actionlint/releases/download/v1.7.12/actionlint_1.7.12_linux_arm64.tar.gz actionlint zizmor 1.31.1 d185f726bdaf92df78273217dfdd24ebcd6b0ef48cf3ce776ff5762b6e138c99 https://github.com/zizmorcore/zizmor/releases/download/v1.31.1/zizmor-x86_64-unknown-linux-gnu.tar.gz zizmor +zizmor/arm64 1.31.1 37eebbd5762a44f262d94875431b14a6d2402991e90a685113ea97b8b41be833 https://github.com/zizmorcore/zizmor/releases/download/v1.31.1/zizmor-aarch64-unknown-linux-gnu.tar.gz zizmor pinact 5.0.0 d005bbb85da80dacdc07816f24a5da723a9f6d1e9f3d3e7e73df33f9caa1358f https://github.com/suzuki-shunsuke/pinact/releases/download/v5.0.0/pinact_linux_amd64.tar.gz pinact +pinact/arm64 5.0.0 d28ca5e9ddd7950da4a808288f8a83f84fc3ca40e86bab970f3adeef33578c0b https://github.com/suzuki-shunsuke/pinact/releases/download/v5.0.0/pinact_linux_arm64.tar.gz pinact shellcheck 0.11.0 8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198 https://github.com/koalaman/shellcheck/releases/download/v0.11.0/shellcheck-v0.11.0.linux.x86_64.tar.xz shellcheck-v0.11.0/shellcheck +shellcheck/arm64 0.11.0 12b331c1d2db6b9eb13cfca64306b1b157a86eb69db83023e261eaa7e7c14588 https://github.com/koalaman/shellcheck/releases/download/v0.11.0/shellcheck-v0.11.0.linux.aarch64.tar.xz shellcheck-v0.11.0/shellcheck shfmt 3.14.1 76e77641faa025814b77f153b29796b8e6fa2fca03e0c76a691608b86c7ea7bf https://github.com/mvdan/sh/releases/download/v3.14.1/shfmt_v3.14.1_linux_amd64 - +shfmt/arm64 3.14.1 5f2db09dae91fca848f7adbdd014632e921a383863a2ad7e0450ad3aba0c6489 https://github.com/mvdan/sh/releases/download/v3.14.1/shfmt_v3.14.1_linux_arm64 - just 1.59.0 409044617b6f06517c1035e55ca38c8c856ff8b650e41bc2aa1ef82d5903a23e https://github.com/casey/just/releases/download/1.59.0/just-1.59.0-x86_64-unknown-linux-musl.tar.gz just +just/arm64 1.59.0 23871b1702bfd550fb5f901778fd4290ecf2ee034a45a889fbe96d89b188086d https://github.com/casey/just/releases/download/1.59.0/just-1.59.0-aarch64-unknown-linux-musl.tar.gz just kubeconform 0.8.0 9bc2bffbf71f261128533edaf912153948b7ff238f9a531ae6d34466ec287883 https://github.com/yannh/kubeconform/releases/download/v0.8.0/kubeconform-linux-amd64.tar.gz kubeconform +kubeconform/arm64 0.8.0 1f53fc8e81258197a35e8603054162a5af1de8c5af13746c71ab680d9534ed87 https://github.com/yannh/kubeconform/releases/download/v0.8.0/kubeconform-linux-arm64.tar.gz kubeconform helm 3.22.0 1e4ab49e429626cf6c6958d914248b78c9730803c2751b87627e171dc800e7bb https://get.helm.sh/helm-v3.22.0-linux-amd64.tar.gz linux-amd64/helm +helm/arm64 3.22.0 f14e804dfee240f55525b667488fe9adca349e63e00c9af634c0beb1421ac310 https://get.helm.sh/helm-v3.22.0-linux-arm64.tar.gz linux-arm64/helm bun 1.4.4 bf8ccbfb2b0b80159e0f9a6d15c55317add8077534dbc6130a3edb52fccb395c https://github.com/oven-sh/bun/releases/download/bun-v1.4.4/bun-linux-x64.zip bun-linux-x64/bun +bun/arm64 1.4.4 baa6bb36f51d6e58561e02bbea825038a9df454f673d6d776e8bbf86f8c7850e https://github.com/oven-sh/bun/releases/download/bun-v1.4.4/bun-linux-aarch64.zip bun-linux-aarch64/bun uv 0.13.0 1468ebd5a5541121837c5a2817b9972ba6090fa6caa3d142620850a47fb75154 https://github.com/astral-sh/uv/releases/download/0.13.0/uv-x86_64-unknown-linux-gnu.tar.gz uv-x86_64-unknown-linux-gnu/uv +uv/arm64 0.13.0 3ccfb6af6e242433eb552f7d9676abd5412c6595c497e990d9c8cb7b5bd4d2c3 https://github.com/astral-sh/uv/releases/download/0.13.0/uv-aarch64-unknown-linux-gnu.tar.gz uv-aarch64-unknown-linux-gnu/uv uvx 0.13.0 1468ebd5a5541121837c5a2817b9972ba6090fa6caa3d142620850a47fb75154 https://github.com/astral-sh/uv/releases/download/0.13.0/uv-x86_64-unknown-linux-gnu.tar.gz uv-x86_64-unknown-linux-gnu/uvx +uvx/arm64 0.13.0 3ccfb6af6e242433eb552f7d9676abd5412c6595c497e990d9c8cb7b5bd4d2c3 https://github.com/astral-sh/uv/releases/download/0.13.0/uv-aarch64-unknown-linux-gnu.tar.gz uv-aarch64-unknown-linux-gnu/uvx