zupt/tests/test_help_consistency.sh
Cristian Cezar Moisés 544a2cd647
Some checks failed
CI / build-and-test (clang) (push) Has been cancelled
CI / build-and-test (gcc) (push) Has been cancelled
CI / strict-warnings (clang, -Wall -Wextra -Wpedantic -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnull-dereference -O2 -std=c11 -Werror) (push) Has been cancelled
CI / strict-warnings (gcc, -Wall -Wextra -Wpedantic -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnull-dereference -Wformat-security -Wlogical-op -Wjump-misses-init -Wdouble-promotion -O2 -std=c11 -Werror) (push) Has been cancelled
CI / sanitizers (push) Has been cancelled
CI / pie-hardening (push) Has been cancelled
CI / cross-aarch64 (push) Has been cancelled
CI / dist-reproducibility (push) Has been cancelled
CI / packaging-syntax (push) Has been cancelled
CI / release (push) Has been cancelled
v4.0.0: codec 2.60.4 security release, --pq-box sealed-box mode, F-16 fix
Major release. Highlights:

- Codec: vendored VaptVupt codec moves to canonical 2.60.4 security
  release. Fixes a high-severity OOB heap write in the AVX2 decode fast
  path (reachable on a valid stream sized to exactly content_size, both
  tail variants). Brings CBMC-formally-verified BCJ filters with
  automatic ELF/PE/Mach-O detection. Compressed output stays
  byte-identical (ratio gate Δ 0.00%); wire format unchanged at v1.6.
- New --pq-box sealed-box recipient mode (vendored libpqvaptvupt 0.6.0):
  ML-KEM-768 + X25519 combined via HKDF-SHA256 with domain separation,
  AES-256-CTR + HMAC-SHA256 EtM. Legacy --pq and --pq-sdk stay readable.
- F-16: discloses and fixes a pre-existing data-loss defect in the
  <= 3.8.0 in-tree BCJ encoder. Full back-compat matrix decodes
  byte-exact under 4.0.0; every readable pre-4.0 archive remains readable.

Repository hygiene:
- Sync full 4.0.0 source tree (codec, crypto, SDK, GUI, packaging, tests).
- Remove internal scratch files (PROMPT.md, FORMAL_AUDIT_PROMPT.md)
  and superseded version-specific docs (INTEGRATION_PROTOCOL_2.60.4.md,
  docs/FINDINGS-2.x.md) and a stray test binary.
- Refresh README download/install section to real 4.0.0 release assets;
  bump version badge to 4.0.0.
- Add .gitignore for build outputs (keeps vendored prebuilt libraries).
2026-06-10 18:48:58 -03:00

137 lines
5.1 KiB
Shell
Executable file

#!/bin/bash
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (c) 2025-2026 Cristian Cezar Moisés
#
# Regression test for the `vaptvupt help` output.
#
# History:
# F-13 (v3.0.2): the usage() string literal exceeded C99's 4095-char
# limit (4121 chars), triggering -Woverlength-strings. Also, the
# help text had drifted out of date during the v3.0.0 rename:
# - Examples still said `zupt compress`, `zupt extract`, etc.
# - "Compression: LZ77 (1MB window) + Huffman entropy coding" —
# false; the default codec is now VaptVupt LZ + ANS 2.48.5
# - "License: AGPL-3.0-or-later (Zupt)" — should be (VaptVupt)
#
# This test asserts the help output stays consistent with reality.
# Run from repo root after a build.
set -u
PASS=0; FAIL=0
P() { echo "$1"; PASS=$((PASS+1)); }
F() { echo "$1"; FAIL=$((FAIL+1)); }
BIN=./vaptvupt
[ -x ./vaptvupt ] || BIN=./zupt
[ -x "$BIN" ] || { echo "ERROR: no built binary found"; exit 2; }
HELP=$("$BIN" help 2>&1)
echo "Help consistency"
# ─── F-13 guard: usage() string-literal size ───
# Each fprintf-passed string literal (after adjacent concatenation)
# must be under C99's 4095-char limit. We use a python helper to
# walk fprintf(...) calls and measure the concatenated literal.
python3 > /tmp/usage_size_check.txt <<'PYEOF'
import re
src = open('src/zupt_main.c').read()
pattern = re.compile(r'fprintf\(\s*\w+\s*,\s*((?:"(?:[^"\\]|\\.)*"\s*)+)', re.S)
worst = 0
worst_lineno = 0
for m in pattern.finditer(src):
block = m.group(1)
literals = re.findall(r'"((?:[^"\\]|\\.)*)"', block)
concat = ''.join(literals)
actual = len(re.sub(r'\\.', 'X', concat))
if actual > worst:
worst = actual
worst_lineno = src[:m.start()].count('\n') + 1
if worst >= 4095:
print(f"FAIL:{worst}:{worst_lineno}")
else:
print(f"PASS:{worst}:{worst_lineno}")
PYEOF
RES=$(tail -1 /tmp/usage_size_check.txt)
if [[ "$RES" == PASS:* ]]; then
L=${RES#PASS:}; L=${L%:*}
P "usage() string literals are under C99 4095-char limit (worst: $L chars)"
else
L=${RES#FAIL:}; LINE=${L##*:}; L=${L%:*}
F "usage() has a string literal of $L chars at line $LINE — over C99 4095 limit (F-13 regression)"
fi
# ─── Brand consistency ───
# The help output must use the new binary name in examples, not the old one.
if echo "$HELP" | grep -qE '^\s+vaptvupt (compress|extract|list|test|bench|keygen|info|disk)'; then
P "examples use 'vaptvupt' command name"
else
F "examples don't use 'vaptvupt' — still saying 'zupt'?"
fi
# Conversely, the example lines shouldn't start with `zupt ` (the
# bare legacy name in example commands is the drift we just fixed).
LEGACY_EX=$(echo "$HELP" | grep -cE '^\s{1,4}zupt (compress|extract|list|test|bench|keygen) ')
if [ "$LEGACY_EX" -eq 0 ]; then
P "no examples use the bare legacy 'zupt' command name"
else
F "$LEGACY_EX example lines still use the legacy 'zupt' command name"
fi
# ─── Codec consistency ───
# Help text must mention the actual default codec, not the v2.x one.
if echo "$HELP" | grep -q "VaptVupt LZ + ANS"; then
P "help mentions VaptVupt LZ + ANS as the default codec"
else
F "help doesn't mention VaptVupt LZ + ANS — still claiming LZ77+Huffman?"
fi
# Conversely, the BARE phrase "LZ77 (1MB window) + Huffman" was the v2.x
# default-codec description; if it's still there, the help text is stale.
if echo "$HELP" | grep -q "LZ77 (1MB window) + Huffman entropy coding"; then
F "help still has the stale v2.x 'LZ77 (1MB window) + Huffman' description"
else
P "help doesn't have the stale v2.x default-codec description"
fi
# ─── License consistency ───
if echo "$HELP" | grep -q "AGPL-3.0-or-later (VaptVupt)"; then
P "help shows the correct license attribution (VaptVupt)"
else
F "help has wrong license attribution — should say AGPL-3.0-or-later (VaptVupt)"
fi
# Commercial-licensing contact visible.
if echo "$HELP" | grep -q "sac@securityops.co"; then
P "help shows the commercial-licensing contact (sac@securityops.co)"
else
F "help is missing the commercial-licensing contact"
fi
# ─── KDF consistency ───
# Argon2id is the default since v2.4.1; the help must say so.
if echo "$HELP" | grep -qE "Argon2id.*default"; then
P "help correctly identifies Argon2id as the default KDF"
else
F "help doesn't identify Argon2id as the default KDF"
fi
# ─── Format consistency ───
if echo "$HELP" | grep -qE "Format:\s+v1\.6"; then
P "help reports the correct format version (v1.6)"
else
F "help doesn't report the correct format version"
fi
# ─── Functional check: help command works ───
if "$BIN" help >/dev/null 2>&1; then
P "vaptvupt help exits successfully"
else
F "vaptvupt help exits with non-zero status"
fi
echo ""
echo " ───────────────────────────────────────"
echo " Help consistency: $PASS passed, $FAIL failed"
echo " ───────────────────────────────────────"
[ "$FAIL" = 0 ] || exit 1