From 4c9a79ca98dd4d3030954fc3bbea60d91fa5964d Mon Sep 17 00:00:00 2001 From: fl0l0u Date: Sun, 15 Nov 2026 17:21:38 +0000 Subject: [PATCH] tests: the served dashboard bytes get hashed from outside dashboard_page.h is the Node build of dashboard/, committed because the engine's build has no Node. The ctest dashboard_page compares dashboard/'s sources against the digest recorded INSIDE that header -- which proves the sources and the header's own claim agree, nothing more. Rewrite the header and its embedded digest together and the check passes while the engine serves a page nobody built from these sources. artifact_sums.sh hashes the artifact itself from outside, the mechanical half vendor/SHA256SUMS is to vendor/UPSTREAM: tests/ARTIFACTS names every committed built artifact and its hash, and a lone tamper of a served byte now fails. A rebuild re-records the manifest in the same commit. The residual gap -- a single commit rewriting an artifact AND the manifest -- is exactly the vendor-tree gap, and documented as such. --- tests/ARTIFACTS | 1 + tests/CMakeLists.txt | 6 ++++++ tests/artifact_sums.sh | 27 +++++++++++++++++++++++++++ tools/dashboard_embed.py | 5 +++++ 4 files changed, 39 insertions(+) create mode 100644 tests/ARTIFACTS create mode 100755 tests/artifact_sums.sh diff --git a/tests/ARTIFACTS b/tests/ARTIFACTS new file mode 100644 index 00000000..4ecbe693 --- /dev/null +++ b/tests/ARTIFACTS @@ -0,0 +1 @@ +599548556d97ca6ce7b8bc295853f76b4d7408cb2d44105920021176cc027aab core/server/dashboard_page.h diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 797187d9..eb218090 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -851,6 +851,12 @@ if(RAD_PYTHON3 AND EXISTS ${CMAKE_SOURCE_DIR}/dashboard/package.json) LABELS "fast;unit" TIMEOUT ${RAD_TEST_TIMEOUT}) endif() +# The header's digest proves sources and its own claim agree, nothing more: it cannot catch a +# tamper of the committed served bytes that rewrites that digest to match. This hashes the +# artifacts themselves from outside, so tampering with one alone fails. +add_test(NAME artifact_sums + COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/artifact_sums.sh ${CMAKE_SOURCE_DIR}) +set_tests_properties(artifact_sums PROPERTIES LABELS "fast;unit" TIMEOUT 120) if(RAD_PYTHON3) add_test(NAME rad_export_test COMMAND ${RAD_PYTHON3} ${CMAKE_CURRENT_SOURCE_DIR}/rad_export_test.py) set_tests_properties(rad_export_test PROPERTIES LABELS "unit;fast" TIMEOUT ${RAD_TEST_TIMEOUT}) diff --git a/tests/artifact_sums.sh b/tests/artifact_sums.sh new file mode 100755 index 00000000..5b1d46d5 --- /dev/null +++ b/tests/artifact_sums.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# artifact_sums.sh -- checks committed built artifacts against tests/ARTIFACTS. +# +# Some committed files are not sources but a build of sources: core/server/dashboard_page.h is a +# Node build of dashboard/, committed because the engine's build has no Node. The digest recorded +# INSIDE such an artifact proves only that the sources and the artifact's own claim agree -- +# tampering with the artifact together with its embedded digest reads as an honest build. This +# manifest hashes the artifact itself from outside, the mechanical half that vendor/SHA256SUMS is +# to vendor/UPSTREAM: the dashboard_page test keeps sources and header in step, this one checks +# the served bytes. (A tamper that updates the artifact and this manifest in one breath remains, +# exactly as with a vendor file -- the manifest is against drift and lone tampering, not against +# a commit that rewrites the whole record.) +# +# tests/artifact_sums.sh +# +# When an artifact is rebuilt for real, re-record it in the same commit: +# sha256sum $(awk '{print $2}' tests/ARTIFACTS) > tests/ARTIFACTS +set -e +root=${1:?usage: artifact_sums.sh } +cd "$root" +command -v sha256sum >/dev/null || { echo "artifact_sums: sha256sum is required" >&2; exit 1; } +[ -f tests/ARTIFACTS ] || { echo "artifact_sums: tests/ARTIFACTS is missing" >&2; exit 1; } +sha256sum -c --status tests/ARTIFACTS || { + echo "artifact_sums: a committed artifact differs from its recorded hash;" \ + "run sha256sum -c tests/ARTIFACTS to see which" >&2 + exit 1; } +echo "artifact_sums: $(wc -l < tests/ARTIFACTS) artifact(s), every hash matches" diff --git a/tools/dashboard_embed.py b/tools/dashboard_embed.py index c5f27245..c584ea57 100755 --- a/tools/dashboard_embed.py +++ b/tools/dashboard_embed.py @@ -10,6 +10,11 @@ committed as core/server/dashboard_page.h and this keeps the two together: dashboard/THIRD-PARTY-LICENSES.txt (`npm run embed` in dashboard/ builds and writes) check exits 1 if dashboard/'s sources no longer have the recorded digest: someone changed the page's source and did not rebuild the header (the ctest `dashboard_page`) + +The digest lives inside the header and only proves sources and claim agree; the served bytes are +hashed from outside by tests/ARTIFACTS (the ctest `artifact_sums`), so tampering with the header +alone fails. After a real rebuild, re-record both in the same commit: + sha256sum $(awk '{print $2}' tests/ARTIFACTS) > tests/ARTIFACTS """ import hashlib, os, sys