Files
codebase-memory-mcp/tests/test_vt_gate_zero_tolerance_contract.sh
Martin Vogel 3e343a3eb2 ci(release): revert the VT gate to zero tolerance
The pre-release ML false-positive tolerance (single-engine Microsoft "!ml"
verdicts downgradable with Defender endpoint evidence, #1340) is reverted by
owner decision: cbm does not ship binaries carrying a VirusTotal detection,
demonstrably false or not. A "trojan" badge on a release asset is a
reputation cost the project is not willing to price in, however good the
accompanying evidence.

The gate returns to its original form: any detection, by any engine, on any
artifact, on any version blocks the release. The endpoint verification tool
and the evidence side-channel are removed with it; the notes renderer keeps
its extracted-script form but only ever states a verified "0 detections".

False positives are resolved upstream instead: verify the bytes on a real
Defender endpoint, submit a Microsoft false-positive report for the exact
hashes, wait for the detection to clear, then RE-RUN the failed verify job --
which does not rebuild, so the cleared hashes are the shipped hashes.

tests/test_vt_gate_zero_tolerance_contract.sh pins the decision: clean
passes; 1 malicious and 1 suspicious each block across stable, -rc., -pre
and -alpha versions; plus a tripwire for the specific reverted evidence
mechanism returning. Loosening this gate again has to consciously delete
that contract.

The skip_tests dispatch input and the script-extracted notes step survive
the revert -- both are orthogonal to gating policy.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-07-29 21:18:58 +02:00

79 lines
2.8 KiB
Bash

#!/usr/bin/env bash
# Contract: the VirusTotal release gate (scripts/ci/check-virustotal.sh) is
# ZERO tolerance — ANY detection on ANY artifact blocks, with no version
# carve-out, no engine carve-out, and no evidence side-channel.
#
# A tolerance path existed briefly (single-engine Microsoft "!ml" on
# pre-releases, endpoint-evidence-gated) and was deliberately reverted: the
# project does not ship binaries carrying a VirusTotal detection, full stop.
# False positives are resolved upstream (Microsoft FP submission for the exact
# hashes, then re-run the verify job — no rebuild), never by loosening the
# gate. This contract pins that decision against a stubbed VT API so a future
# "just tolerate this one heuristic" change has to consciously delete it.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
GATE="$ROOT/scripts/ci/check-virustotal.sh"
FIX="$(mktemp -d "${TMPDIR:-/tmp}/vt-gate-contract.XXXXXX")"
trap 'rm -rf "$FIX"' EXIT
fail() { echo "FAIL: $*" >&2; exit 1; }
# Tripwire for the specific reverted mechanism (behavioral checks below are
# the real contract; these names only catch that exact machinery returning).
for needle in defender-endpoint-verification av-endpoint-verify; do
if grep -q "$needle" "$GATE"; then
fail "gate references '$needle' — the reverted evidence side-channel is back"
fi
done
mkdir -p "$FIX/bin" "$FIX/work/binaries" "$FIX/responses"
# curl stub: serve the canned VT analysis JSON selected by the id in the URL.
cat > "$FIX/bin/curl" <<'EOF'
#!/usr/bin/env bash
url="${@: -1}"
id="${url##*/analyses/}"
resp="$STUB_RESPONSES/$id.json"
[ -f "$resp" ] || exit 22
cat "$resp"
EOF
chmod +x "$FIX/bin/curl"
mk_response() { # id malicious suspicious
cat > "$FIX/responses/$1.json" <<EOF
{"data":{"attributes":{"status":"completed",
"stats":{"malicious":$2,"suspicious":$3,"undetected":60,"harmless":0}}}}
EOF
}
mk_response clean 0 0
mk_response one_malicious 1 0
mk_response one_suspicious 0 1
echo "release-bytes" > "$FIX/work/binaries/probe"
run_gate() { # version analysis-id -> echoes exit code
rm -f /tmp/vt_gate_fail
local rc=0
(cd "$FIX/work" &&
PATH="$FIX/bin:$PATH" \
STUB_RESPONSES="$FIX/responses" \
VT_API_KEY="stub" \
VERSION="$1" \
VT_ANALYSIS="binaries/probe=https://www.virustotal.com/gui/file-analysis/$2/detection" \
bash "$GATE" >"$FIX/last.log" 2>&1) || rc=$?
echo "$rc"
}
[ "$(run_gate v0.9.1 clean)" = "0" ] || fail "clean scan must pass"
for version in v0.9.1 v0.9.1-rc.1 v0.9.1-pre1 v1.0.0-alpha.1; do
[ "$(run_gate "$version" one_malicious)" != "0" ] || \
fail "1 malicious must block on $version (pre-release carve-outs are gone)"
[ "$(run_gate "$version" one_suspicious)" != "0" ] || \
fail "1 suspicious must block on $version"
done
rm -f /tmp/vt_gate_fail
echo "PASS: VT gate is zero tolerance — every detection blocks on every version"