From facf4422c8d4a666a88f0a1ffd60d96b9732fcfe Mon Sep 17 00:00:00 2001 From: mnovak Date: Sun, 22 Nov 2026 19:04:59 +0100 Subject: [PATCH] [bench] Conformance: the slow-client probes (a TLS handshake that never starts, an HTTP/2 header block that never ends) against both engines, and Caddy's real version from the binary's build info --- scripts/conformance.sh | 14 +++++++++++++- tests/diff/src/bin/pair.rs | 34 +++++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/scripts/conformance.sh b/scripts/conformance.sh index 800c7a3..8838297 100755 --- a/scripts/conformance.sh +++ b/scripts/conformance.sh @@ -18,7 +18,7 @@ set -euo pipefail root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) out="$root/bench/conformance" mkdir -p "$out" -for tool in caddy h2spec jq; do +for tool in caddy h2spec jq; do # and python3 for the slow-client probes, when present command -v "$tool" >/dev/null || { echo "missing: $tool" >&2; exit 2; } done testssl=$(command -v testssl.sh || command -v testssl || true) @@ -60,6 +60,18 @@ for engine in ianitor caddy; do 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" + + # Slow clients (QC phase 4, tests/support/probes): a TLS handshake that never starts, and an + # HTTP/2 header block that never ends; how long each engine keeps them open (75 s at most). + if command -v python3 >/dev/null; then + probes="$root/tests/support/probes" + python3 "$probes/slow.py" 127.0.0.1 "$p" idle 75 localhost >"$out/$engine-slow-idle.txt" 2>&1 & + a=$! + python3 "$probes/h2slow.py" 127.0.0.1 "$p" 75 localhost >"$out/$engine-slow-h2.txt" 2>&1 & + b=$! + wait $a $b || true + printf '%-10s %-8s %s\n' "$engine" slow "$(cut -d';' -f1 "$out/$engine-slow-idle.txt" | head -1); $(cut -d';' -f1 "$out/$engine-slow-h2.txt" | head -1)" + fi done # A case Caddy passes and Ianitor fails is a regression against the fallback. diff --git a/tests/diff/src/bin/pair.rs b/tests/diff/src/bin/pair.rs index 46f586a..109d2de 100644 --- a/tests/diff/src/bin/pair.rs +++ b/tests/diff/src/bin/pair.rs @@ -95,6 +95,34 @@ mod unix { } } + /// `caddy version`, or, for a `go install`ed Caddy that says "unknown", its module version + /// from the binary's build info (`go version -m`). + fn caddy_version(caddy: &std::path::Path) -> String { + let out = |cmd: &mut std::process::Command| { + cmd.output() + .map(|o| String::from_utf8_lossy(&o.stdout).trim().to_owned()) + .unwrap_or_default() + }; + let v = out(std::process::Command::new(caddy).arg("version")); + if !v.is_empty() && v != "unknown" { + return v; + } + let info = out(std::process::Command::new("go") + .args(["version", "-m"]) + .arg(caddy)); + info.lines() + .map(|l| l.split_whitespace().collect::>()) + .find(|f| f.len() >= 3 && f[0] == "mod" && f[1] == "github.com/caddyserver/caddy/v2") + .map(|f| { + format!( + "{} (go install; {})", + f[2], + info.lines().next().unwrap_or("").trim() + ) + }) + .unwrap_or(v) + } + fn addrs(t: &Target) -> serde_json::Value { json!({ "http": t.http.to_string(), "https": t.https.to_string() }) } @@ -158,11 +186,7 @@ mod unix { &caddy2_cfg, &[("GOMAXPROCS", "2")], ); - let caddy_version = std::process::Command::new(&caddy) - .arg("version") - .output() - .map(|o| String::from_utf8_lossy(&o.stdout).trim().to_owned()) - .unwrap_or_default(); + let caddy_version = caddy_version(&caddy); println!( "{}",