From cb4c56679df063296d6cd6c7e10ea8b074c78e63 Mon Sep 17 00:00:00 2001 From: noah Date: Sun, 18 Oct 2026 21:56:00 -0600 Subject: [PATCH] Verify wx source provenance before reusing prefix --- .gitea/workflows/next.yml | 7 +------ .gitea/workflows/release.yml | 9 +-------- .gitea/workflows/verify.yml | 9 +-------- ci/ensure-wx-prefix.sh | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 22 deletions(-) create mode 100644 ci/ensure-wx-prefix.sh diff --git a/.gitea/workflows/next.yml b/.gitea/workflows/next.yml index ac8a7dae..2003f78f 100644 --- a/.gitea/workflows/next.yml +++ b/.gitea/workflows/next.yml @@ -38,12 +38,7 @@ jobs: path: /root/.cache/wx-3.3.3-linux key: ${{ steps.wx-key.outputs.key }} - name: Build wxWidgets - run: | - if [ ! -x "$WX_PREFIX/bin/wx-config" ] || - [ ! -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ]; then - bash scripts/build-wx-linux.sh - fi - [ -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ] + run: bash ci/ensure-wx-prefix.sh - name: Save vendored wxWidgets build if: steps.wx-cache.outputs.cache-hit != 'true' uses: actions/cache/save@v4 diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 5f0aaed2..f17cafc2 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -66,14 +66,7 @@ jobs: key: ${{ steps.wx-key.outputs.key }} - name: Build wxWidgets (once, then cached) - run: | - if [ ! -x "$WX_PREFIX/bin/wx-config" ] || - [ ! -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ]; then - bash scripts/build-wx-linux.sh - else - echo "wx prefix restored from cache" - fi - [ -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ] + run: bash ci/ensure-wx-prefix.sh - name: Save vendored wxWidgets build if: steps.wx-cache.outputs.cache-hit != 'true' diff --git a/.gitea/workflows/verify.yml b/.gitea/workflows/verify.yml index b1001067..ea36a7bb 100644 --- a/.gitea/workflows/verify.yml +++ b/.gitea/workflows/verify.yml @@ -68,14 +68,7 @@ jobs: - name: Build wxWidgets (once, then cached) if: steps.surface.outputs.surface == 'full' - run: | - if [ ! -x "$WX_PREFIX/bin/wx-config" ] || - [ ! -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ]; then - bash scripts/build-wx-linux.sh - else - echo "wx prefix restored from cache" - fi - [ -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ] + run: bash ci/ensure-wx-prefix.sh - name: Save vendored wxWidgets build if: steps.surface.outputs.surface == 'full' && steps.wx-cache.outputs.cache-hit != 'true' diff --git a/ci/ensure-wx-prefix.sh b/ci/ensure-wx-prefix.sh new file mode 100644 index 00000000..62f0fa81 --- /dev/null +++ b/ci/ensure-wx-prefix.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MIT +# Use the matching image or cache prefix; rebuild after a vendored source bump. +set -euo pipefail + +prefix="${WX_PREFIX:?WX_PREFIX is required}" +expected="$(awk '$1 == "sha256:" {print $2}' thirdparty/wxwidgets/VERSION)" +[[ "$expected" =~ ^[0-9a-f]{64}$ ]] || { + echo 'invalid pinned wxWidgets source digest' >&2 + exit 1 +} +marker="$prefix/.alkane-source-sha256" +if [ -e "$marker" ] && [ "$(cat "$marker")" != "$expected" ]; then + python3 - "$prefix" <<'PY' +from pathlib import Path +import shutil +import sys + +prefix = Path(sys.argv[1]) +allowed = Path('/root/.cache/wx-3.3.3-linux') +if prefix != allowed or prefix.is_symlink(): + raise SystemExit('refusing unsafe wxWidgets prefix reset') +if prefix.is_dir(): + shutil.rmtree(prefix) +PY +fi +if [ ! -x "$prefix/bin/wx-config" ] || + [ ! -s "$prefix/lib/libwx_gtk3u-3.3.a" ]; then + bash scripts/build-wx-linux.sh +else + echo 'wx prefix available from matching image or cache' +fi +[ -s "$prefix/lib/libwx_gtk3u-3.3.a" ] +printf '%s\n' "$expected" > "$marker"