Files
football/verify.sh
reachableceo 62d20604a6 fix: resolve critical build bugs and add missing PRD requirements
Critical fixes:
- Fix security-hardening.sh live hook: removed broken source from
  /build/src/ which doesn't exist during live-build; made hook
  self-contained by inlining all config generation
- Fix firewall-setup.sh live hook: removed broken source from
  /build/src/; hook already had inline nftables config
- Fix install-scripts.sh: replaced /workspace/src/ references with
  embedded inline scripts (installed system has no /workspace)
- Fix UKI cmdline in standalone uki_build(): added
  lockdown=confidentiality and module.sig_enforce=1 to match the
  inline Secure Boot hook
- Fix WiFi blacklist: expanded from 6 entries to 19, now covers all
  PRD FR-005 driver families (rtl*, iwl*, ath*, brcm*, mwifi*, rt2*)

Missing PRD requirements added:
- kernel-hardening.sh (FR-007): sysctl parameters for ASLR, ptrace
  restriction, kptr_restrict, dmesg_restrict, kexec disabled, SUID
  dumpable disabled, hardlink/symlink protection, network hardening
- service-hardening.sh (FR-007): disables and masks avahi-daemon,
  cups, bluetooth, NetworkManager, ModemManager, whoopsie, apport
- sudo-hardening.sh (FR-007): requiretty, logging (input/output),
  timestamp timeout, env_reset, restricted football user commands
- mount-hardening.sh (FR-007): nodev/nosuid/noexec on /tmp,
  nodev/nosuid on /home, /dev/shm hardening

Test improvements:
- Rewrote security-hardening_comprehensive_test.bats: tests now
  source scripts, call functions, and verify generated output files
- Rewrote firewall-setup_comprehensive_test.bats: tests now create
  WireGuard configs, call parse_wg_endpoint, verify nftables output
- Added new-hooks_test.bats: 42 tests for kernel hardening, service
  hardening, sudo hardening, mount hardening, self-containment
  verification, and WiFi blacklist completeness
- Total: 788 tests passing, 0 failures, 0 shellcheck warnings

Reference: docs/PRD.md FR-005, FR-007, security-model.md

💘 Generated with Crush

Assisted-by: GLM-5.1 via Crush <crush@charm.land>
2026-05-01 09:50:15 -05:00

145 lines
4.4 KiB
Bash
Executable File

#!/bin/bash
# Comprehensive project verification script
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
PASS=0
FAIL=0
RESULTS=""
log_pass() { PASS=$((PASS+1)); RESULTS+=" [PASS] $1\n"; }
log_fail() { FAIL=$((FAIL+1)); RESULTS+=" [FAIL] $1\n"; }
log_info() { RESULTS+=" [INFO] $1\n"; }
echo "=== KNEL-Football Project Verification ==="
echo ""
# 1. Docker available
echo "Phase 1: Environment checks..."
if docker info &>/dev/null; then
log_pass "Docker daemon running"
else
log_fail "Docker daemon not running"
fi
# 2. Docker image exists
if docker images --format '{{.Repository}}' | grep -q 'knel-football-dev'; then
log_pass "Docker build image exists"
else
log_fail "Docker build image missing (run: ./run.sh build)"
fi
# 3. Lint (warning level only)
echo "Phase 2: Lint checks..."
LINT_OUTPUT=$(docker run --rm -v "$SCRIPT_DIR":/workspace knel-football-dev:latest bash -c \
'shellcheck --severity=warning /workspace/src/*.sh /workspace/config/hooks/installed/*.sh /workspace/config/hooks/live/*.sh' 2>&1 || true)
if [ -z "$LINT_OUTPUT" ]; then
log_pass "Shellcheck (warning level) clean"
else
log_fail "Shellcheck warnings found:"
echo "$LINT_OUTPUT" | while read -r line; do log_info " $line"; done
fi
# 4. Run full test suite
echo "Phase 3: Test suite..."
TEST_OUTPUT=$(./run.sh test 2>&1)
TEST_COUNT=$(echo "$TEST_OUTPUT" | grep -c "^ok" || true)
TEST_FAIL=$(echo "$TEST_OUTPUT" | grep -c "^not ok" || true)
if [ "$TEST_FAIL" -eq 0 ]; then
log_pass "All $TEST_COUNT tests passing"
else
log_fail "$TEST_FAIL tests failing out of $((TEST_COUNT+TEST_FAIL))"
echo "$TEST_OUTPUT" | grep "^not ok" | while read -r line; do log_info " $line"; done
fi
# 5. ISO artifact check
echo "Phase 4: ISO artifact..."
if ls output/*.iso &>/dev/null; then
ISO_FILE=$(find output -name '*.iso' -type f | head -1)
ISO_SIZE=$(du -h "$ISO_FILE" | cut -f1)
log_pass "ISO exists: $ISO_FILE ($ISO_SIZE)"
# Check checksums
if [ -f "${ISO_FILE}.sha256" ]; then
log_pass "SHA256 checksum file exists"
else
log_fail "SHA256 checksum file missing"
fi
else
log_info "No ISO artifact found (build with: ./run.sh iso)"
fi
# 6. VM testing capability
echo "Phase 5: VM test capability..."
if command -v virsh &>/dev/null; then
log_pass "virsh available for VM testing"
if virsh list --all &>/dev/null; then
log_pass "libvirt daemon accessible"
# Check for any existing test VMs
EXISTING_VMS=$(virsh list --all --name 2>/dev/null | grep -c 'knel-test' || true)
if [ "$EXISTING_VMS" -gt 0 ]; then
log_info "Found $EXISTING_VMS existing test VM(s)"
else
log_info "No existing test VMs"
fi
else
log_info "libvirt daemon not accessible (may need sudo/libvirtd group)"
fi
else
log_info "virsh not installed - VM testing not available on this host"
fi
# 7. Git status
echo "Phase 6: Git status..."
if git diff --quiet && git diff --cached --quiet; then
log_pass "Working tree clean"
else
log_fail "Uncommitted changes present"
fi
AHEAD=$(git rev-list --count '@{u}..HEAD' 2>/dev/null || echo "?")
log_info "Branch is $AHEAD commit(s) ahead of origin/main"
# 8. Source file integrity
echo "Phase 7: Source file integrity..."
for f in src/build-iso.sh src/security-hardening.sh src/firewall-setup.sh; do
if [ -f "$f" ] && [ -x "$f" ]; then
log_pass "$f exists and is executable"
else
log_fail "$f missing or not executable"
fi
done
# 9. Config file integrity
echo "Phase 8: Config integrity..."
for f in config/preseed.cfg config/hooks/installed/encryption-setup.sh config/hooks/installed/encryption-validation.sh config/hooks/live/security-hardening.sh config/hooks/live/firewall-setup.sh; do
if [ -f "$f" ]; then
log_pass "$f exists"
else
log_fail "$f missing"
fi
done
# 10. Check for Unicode characters that break shellcheck
echo "Phase 9: Unicode check..."
UNICODE_FILES=$(grep -rl '✓\|✗\|✔\|✘' src/ config/ 2>/dev/null || true)
if [ -z "$UNICODE_FILES" ]; then
log_pass "No problematic Unicode characters in shell scripts"
else
log_fail "Unicode characters found in: $UNICODE_FILES"
fi
# Summary
echo ""
echo "=== RESULTS ==="
echo -e "$RESULTS"
echo ""
echo "Summary: $PASS passed, $FAIL failed"
if [ "$FAIL" -gt 0 ]; then
echo "STATUS: ACTION REQUIRED"
exit 1
else
echo "STATUS: ALL GOOD"
exit 0
fi