[fabrica] Layers and the verifiable build: the layers pipeline runs all five test layers on a NixOS runner with KVM, verify-nix rebuilds a tag and compares with its pin, the release publishes the Nix pin (ianitor-nix.json) under the signed SHA256SUMS; scripts for conformance, load and the pin; docs/verify.md

This commit is contained in:
2026-11-10 21:23:16 +01:00
parent 4692044099
commit 9ae721b79f
12 changed files with 485 additions and 3 deletions
+79
View File
@@ -0,0 +1,79 @@
#!/usr/bin/env bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# ROADMAP §5 layer 2: protocol conformance, Ianitor and Caddy side by side on the same routes
# (tests/diff/src/bin/pair.rs): h2spec (HTTP/2, RFC 9113 and HPACK) and testssl.sh (TLS) against
# each. Raw outputs go to bench/conformance/<engine>-*.{txt,json}; the summary table to stdout.
#
# scripts/conformance.sh # needs caddy, h2spec, testssl.sh, jq on PATH
# nix shell nixpkgs#caddy nixpkgs#h2spec nixpkgs#testssl nixpkgs#jq -c scripts/conformance.sh
#
# Exit status: 1 if Ianitor fails an h2spec case Caddy passes, or testssl.sh rates Ianitor's
# TLS below Caddy's (a regression against the fallback); the rest is reported, not enforced.
# Everything listens on 127.0.0.1.
set -euo pipefail
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
out="$root/bench/conformance"
mkdir -p "$out"
for tool in caddy h2spec jq; do
command -v "$tool" >/dev/null || { echo "missing: $tool" >&2; exit 2; }
done
testssl=$(command -v testssl.sh || command -v testssl || true)
[ -n "$testssl" ] || { echo "missing: testssl.sh" >&2; exit 2; }
profile=${BUILD:-release}
flag=--release
[ "$profile" = debug ] && flag=
cargo build $flag -q -p ianitor-diff --bin ianitor-pair
bin="${CARGO_TARGET_DIR:-$root/target}/$profile/ianitor-pair"
info=$(mktemp)
"$bin" --caddy "$(command -v caddy)" >"$info" &
pair=$!
trap 'kill $pair 2>/dev/null; wait $pair 2>/dev/null; rm -f "$info"' EXIT
for _ in $(seq 1 100); do
[ -s "$info" ] && break
sleep 0.2
done
[ -s "$info" ] || { echo "ianitor-pair did not start" >&2; exit 1; }
port() { jq -r ".$1.https" "$info" | sed 's/.*://'; }
status=0
printf '%-10s %-8s %s\n' engine tool result
for engine in ianitor caddy; do
p=$(port "$engine")
# h2spec names the host for SNI; `localhost` is the pair's only host.
h2spec -h localhost -p "$p" -t -k -o 5 >"$out/$engine-h2spec.txt" 2>&1 || true
summary=$(grep -Eo '[0-9]+ tests, [0-9]+ passed, [0-9]+ skipped, [0-9]+ failed' "$out/$engine-h2spec.txt" | tail -1)
printf '%-10s %-8s %s\n' "$engine" h2spec "${summary:-no summary (see $out/$engine-h2spec.txt)}"
# The failed cases, by id, for the comparison below.
grep -E '^\s+×' -B0 "$out/$engine-h2spec.txt" | sed -E 's/^\s+× //' | sort >"$out/$engine-h2spec-failed.txt" || true
"$testssl" --quiet --color 0 --warnings off --ip 127.0.0.1 --add-ca "$(jq -r .ca "$info")" \
--jsonfile "$out/$engine-testssl.json" --overwrite "https://localhost:$p" \
>"$out/$engine-testssl.txt" 2>&1 || true
grade=$(jq -r '[.[] | select(.id=="overall_grade")][0].finding // "n/a"' "$out/$engine-testssl.json" 2>/dev/null || echo n/a)
bad=$(jq -r '[.[] | select(.severity=="HIGH" or .severity=="CRITICAL")] | length' "$out/$engine-testssl.json" 2>/dev/null || echo "?")
printf '%-10s %-8s %s\n' "$engine" testssl "grade $grade, $bad findings HIGH or CRITICAL"
done
# A case Caddy passes and Ianitor fails is a regression against the fallback.
regressions=$(comm -23 "$out/ianitor-h2spec-failed.txt" "$out/caddy-h2spec-failed.txt" || true)
if [ -n "$regressions" ]; then
echo "h2spec cases Ianitor fails and Caddy passes:" >&2
echo "$regressions" >&2
status=1
fi
rank() { case "$1" in A+) echo 7;; A) echo 6;; A-) echo 5;; B) echo 4;; C) echo 3;; D) echo 2;; E) echo 1;; *) echo 0;; esac; }
gi=$(jq -r '[.[] | select(.id=="overall_grade")][0].finding // ""' "$out/ianitor-testssl.json" 2>/dev/null || true)
gc=$(jq -r '[.[] | select(.id=="overall_grade")][0].finding // ""' "$out/caddy-testssl.json" 2>/dev/null || true)
if [ "$(rank "$gi")" -lt "$(rank "$gc")" ]; then
echo "testssl.sh grades Ianitor ($gi) below Caddy ($gc)" >&2
status=1
fi
jq -c '{build, caddy_version, edge_threads}' "$info" >"$out/run.json"
exit $status