Files
figcraft/packaging/server/install-test.sh
bflatastic e0435d4eb4 M9: close the remaining open-hosting DoS paths
Second security review:
- a broadcast counts once against the queued-bytes budget; each block of
  addresses gets at most an eighth; when the budget runs out the biggest
  consumer is shed, not the receiver
- forced compactions at most once a minute per file
- plugin downloads check the per-address share before the global budget
  and before reading
- install.sh never replaces a Caddyfile with other sites (one import line,
  once; install-test.sh in packaging lint); the built binary runs only as
  the server's account
- bytes being read count against per-block and global budgets, the
  biggest readers dropped first
- block multipliers x2 (/56) and x4 (/48), connection caps at most a
  sixteenth/eighth of all; global publish and download budgets eight times
  a /48's share
- problems capped at 200; writes refused below max(1 GiB, two files) free;
  the private-server file cap documented
2026-10-12 11:40:03 +07:00

44 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Checks install.sh's Caddyfile handling without installing anything (no root, no network):
# a Caddyfile with other sites is never replaced, only gains one import line, and stays the same
# however often install.sh runs. Run by the packaging lint workflow.
#
# Usage: packaging/server/install-test.sh
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORK="$(mktemp -d)"
trap 'rm -rf "$WORK"' EXIT
FAILED=0
main() { bash "$HERE/install.sh" --caddy-main "$1" ops@example.com; }
fail() { printf 'FAIL: %s\n' "$*" >&2; FAILED=1; }
# Missing: ours.
main "$WORK/none" >"$WORK/out"
grep -qx 'import figcraft-server.caddy' "$WORK/out" || fail "a new Caddyfile imports our site"
grep -q 'email ops@example.com' "$WORK/out" || fail "a new Caddyfile has the certificate email"
# The example site the package ships: replaced by ours.
printf '# The Caddyfile is an easy way to configure your Caddy web server.\n:80 {\n\troot * /usr/share/caddy\n\tfile_server\n}\n' >"$WORK/default"
main "$WORK/default" >"$WORK/out"
grep -q 'usr/share/caddy' "$WORK/out" && fail "the packaged example site is replaced"
# Someone else's sites: kept, one import added, and the next run changes nothing.
printf 'shop.example.com {\n\treverse_proxy 127.0.0.1:8080\n}\n' >"$WORK/theirs"
cp "$WORK/theirs" "$WORK/run1"
main "$WORK/run1" >"$WORK/run2"
grep -q 'shop.example.com' "$WORK/run2" || fail "the operator's site is kept"
[ "$(grep -c 'import figcraft-server.caddy' "$WORK/run2")" = 1 ] || fail "one import line is added"
main "$WORK/run2" >"$WORK/run3"
cmp -s "$WORK/run2" "$WORK/run3" || fail "running again leaves a Caddyfile with other sites as it is"
main "$WORK/run3" >"$WORK/run4"
cmp -s "$WORK/run3" "$WORK/run4" || fail "and again"
# Ours, run again: unchanged (it imports our site).
main "$WORK/none" >"$WORK/ours1"
main "$WORK/ours1" >"$WORK/ours2"
cmp -s "$WORK/ours1" "$WORK/ours2" || fail "our own Caddyfile stays the same"
if [ "$FAILED" = 0 ]; then echo "install.sh Caddyfile handling: ok"; fi
exit "$FAILED"