Files
proxmox-scripts/tests/check_ct_source.sh
l.kirchner 490fda2ed1
CI / Shell-Lint (bash -n, source-check, Validierungs-Tests) (pull_request) Has been cancelled
K-114: address cross-review findings
- CTID prompt re-prompts on invalid interactive input (was: abort)
- env-provided NAMESERVER is validated when non-empty ('' stays inherit)
- prompt_validated handles EOF (no infinite loop, clean abort under -e)
- 10# base forcing in vlan/cidr/ipv4 arithmetic (leading zeros are not
  octal errors); is_clean_ascii rejects embedded newline/tab explicitly
  (command substitution strips trailing newlines); is_ipv4_list checks
  the whole string before word splitting
- nameref guard against reserved variable names in prompt_validated/
  require_valid; source-check pattern documented as the repo contract
- 8 new test cases (41 total)
2026-06-12 03:20:11 +02:00

31 lines
980 B
Bash
Executable File

#!/usr/bin/env bash
# K-114: Jedes ct/*.sh MUSS lib/build.func sourcen — der Bug "Helfer nicht
# gesourct, Skript stirbt erst mitten im Lauf" ist zweimal real passiert
# (nexus-db: im Review gefangen; authentik: erst in Produktion).
# Aufruf: tests/check_ct_source.sh [verzeichnis] (Default: ct/)
#
# Bewusst eng: akzeptiert wird NUR die curl-Prozesssubstitutions-Form
# `source <(curl ... build.func)` — das ist der Repo-Vertrag für ct/-Scripts
# (Review-Triage K-114). Lokales Sourcen gehört nicht in ct/*.sh.
set -euo pipefail
DIR="${1:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/ct}"
status=0
shopt -s nullglob
scripts=("$DIR"/*.sh)
if [[ ${#scripts[@]} -eq 0 ]]; then
echo "no scripts found in $DIR" >&2
exit 1
fi
for script in "${scripts[@]}"; do
if grep -Eq 'source[[:space:]]+<\(curl[^)]*build\.func' "$script"; then
echo "ok $script"
else
echo "FEHLT $script — sourct lib/build.func nicht" >&2
status=1
fi
done
exit "$status"