Archived
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.
This commit is contained in:
1 parent
70be48c6fa
commit
4c9a79ca98
4 files changed
+39
No files matched your search
@@ -0,0 +1 @@
|
||||
599548556d97ca6ce7b8bc295853f76b4d7408cb2d44105920021176cc027aab core/server/dashboard_page.h
|
||||
@@ -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})
|
||||
|
||||
Executable
+27
@@ -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 <repo-root>
|
||||
#
|
||||
# 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 <repo-root>}
|
||||
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"
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user