Files
urutau/scripts/screenshots.sh
T
Lucas RayanandClaude Opus 5.5 6941106172
Release / Plan (reuse the published image?) (push) Successful in 6s
Release / ci (push) Skipped
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Successful in 17s
Release / Gitea release (push) Skipped
docs: bring README, docs, screenshots and changelog up to 1.6.0
Rewritten README and interface/configuration/CLI/Docker/support/architecture
docs (EN and pt-BR) from the 1.6.0 code; all 80 screenshots regenerated,
incidents pages added; changelog audited against the tags (1.4.0 date,
1.4.6/1.4.7 items, 1.5.0 details, 1.5.8 shipped inside 1.6.0, compare
links); compose and .env.example expose the enforce, egress, probe and
Tor settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 21:41:50 -03:00

123 lines
7.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Regenerates the screenshots in docs/img from the real Urutau dashboard.
#
# Nothing in the pictures is real: scripts/screenshots/demo writes a DEMO geolocation
# database (MMDB, city + asn) that maps sub-ranges of the reserved documentation addresses
# (198.18.0.0/15, 203.0.113.0/24, 198.51.100.0/24, 192.0.2.0/24, 2001:db8::/32) to real
# cities, plus 30 days of synthetic Traefik / auth.log / fail2ban.log files for two servers
# (edge-1, edge-2) with domains under example.com/.org/.net. Two Urutau instances (a hub and
# one peer, ports 18880/18881) read them, new events keep arriving while the pages are
# captured (so the live map has arcs), and headless Chrome takes the pictures.
#
# scripts/screenshots.sh # writes docs/img
# OUT=/tmp/img scripts/screenshots.sh # writes elsewhere
#
# Variables: ONLY (comma list of page ids to capture), OUT, HUB_PORT (18880), PEER_PORT (18881), LOGIN_PORT (18882), CHROME,
# PUPPETEER_CORE (default: newest Chrome in ~/.cache/puppeteer and puppeteer-core in
# ~/.claude/tools/node_modules). Needs go, node, curl, openssl and Chrome. No network use.
# Idempotent: it builds into a temporary directory, kills what it started (by PID) when done
# and overwrites the same file names. oxipng/pngquant are used when installed.
set -euo pipefail
root=$(cd "$(dirname "$0")/.." && pwd)
out=${OUT:-$root/docs/img}
hub_port=${HUB_PORT:-18880}
peer_port=${PEER_PORT:-18881}
login_port=${LOGIN_PORT:-18882}
work=$(mktemp -d)
pids=()
cleanup() {
for p in "${pids[@]}"; do kill "$p" 2>/dev/null || true; done
for p in "${pids[@]}"; do wait "$p" 2>/dev/null || true; done
rm -rf "$work"
}
trap cleanup EXIT
for port in "$hub_port" "$peer_port" "$login_port"; do
if curl -fsS -m 1 "http://127.0.0.1:$port/api/health" >/dev/null 2>&1; then
echo "port $port is already in use; stop that instance first" >&2
exit 1
fi
done
export TZ=UTC
# Hidden demo-only switch: reserved ranges count as public for the second firewall (see internal/enforce/policy.go).
export URUTAU_DEMO_RESERVED_PUBLIC=1
mkdir -p "$out" "$work/bin"
(cd "$root" && go build -trimpath -o "$work/bin/urutau" ./cmd/urutau && go build -o "$work/bin/demo" ./scripts/screenshots/demo)
urutau="$work/bin/urutau"
demo="$work/bin/demo"
# Demo geolocation base and logs (relative to "now").
"$demo" geo "$work/geo"
"$demo" logs "$work/hub/logs" edge-1 1
"$demo" logs "$work/peer/logs" edge-2 2
"$demo" egress "$work/hub/egress"
"$demo" check "$work"/hub/logs/* "$work"/peer/logs/* "$work"/hub/egress/* # fails on any IP outside the reserved ranges
export URUTAU_PEER_TOKEN=$(openssl rand -base64 48 | tr -d '\n')
start() { # start name port dir [extra flags...]
local name=$1 port=$2 dir=$3; shift 3
"$urutau" serve --name "$name" --bind "127.0.0.1:$port" --data-dir "$dir/data" \
--traefik-log "$dir/logs/access.log" --auth-log "$dir/logs/auth.log" --fail2ban-log "$dir/logs/fail2ban.log" \
--geo-dir "$work/geo" --geo-update 0 --insecure-no-auth "$@" > "$dir.log" 2>&1 &
pids+=($!)
}
start edge-2 "$peer_port" "$work/peer" --location "39.0438,-77.4874,edge-2"
start edge-1 "$hub_port" "$work/hub" --location "50.1109,8.6821,edge-1" \
--enforce observe --egress on --egress-log "$work/hub/egress/egress.log" --egress-containers "$work/hub/egress/containers.map" \
--egress-workloads "ciberlab=name:ciberlab:scanner" --peer "edge-2=http://127.0.0.1:$peer_port"
# A third, short-lived instance with authentication on, only for the login page.
mkdir -p "$work/login/data"
URUTAU_TOKEN=$(openssl rand -base64 48 | tr -d '\n') URUTAU_PEER_TOKEN= "$urutau" serve --name edge-1 \
--bind "127.0.0.1:$login_port" --data-dir "$work/login/data" --traefik-log "" --auth-log "" --fail2ban-log "" \
--geo-dir "$work/geo" --geo-update 0 > "$work/login.log" 2>&1 &
pids+=($!)
for port in "$hub_port" "$peer_port" "$login_port"; do
ok=0
for _ in $(seq 1 150); do
curl -fsS "http://127.0.0.1:$port/api/health" >/dev/null 2>&1 && { ok=1; break; }
sleep 0.2
done
[ "$ok" = 1 ] || { echo "instance on port $port did not start:" >&2; tail -20 "$work"/*.log >&2; exit 1; }
done
# wait until the hub has read the backfill (the request counter stops growing)
prev=-1
for _ in $(seq 1 240); do
n=$(curl -fsS "http://127.0.0.1:$hub_port/api/v1/summary?range=30d" 2>/dev/null | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{try{console.log(JSON.parse(s).totals.requests||0)}catch{console.log(0)}})' || echo 0)
[ "${n:-0}" -gt 1000 ] && [ "$n" = "$prev" ] && break
prev=$n
sleep 1
done
# Demo incident tickets (manual ones; the egress/enforce detections may add automatic ones).
inc() { curl -fsS -X "$1" -H 'Content-Type: application/json' -d "$3" "http://127.0.0.1:$hub_port/api/v1/incidents$2"; }
idof() { node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>console.log(JSON.parse(s).id))'; }
i1=$(inc POST "" '{"title":"Multi-vector attacker 203.0.113.45 hitting edge-1","detail":"SSH brute force followed by web probing of /wp-login.php and /.env from the same address.","severity":"high","host":"edge-1","tags":["brute-force","web-probe"],"author":"ana"}' | idof)
inc POST "/$i1/comments" '{"text":"Confirmed in the replay: SSH password guessing, then the probe wave starts 40 minutes later.","author":"ana"}' >/dev/null
inc POST "/$i1/comments" '{"text":"Address added to the second firewall in observe mode; waiting for the next window before enforcing.","author":"bruno"}' >/dev/null
inc PATCH "/$i1" '{"status":"investigating","assignee":"ana","author":"ana"}' >/dev/null
i2=$(inc POST "" '{"title":"Unusual outbound connections from the scanner workload","detail":"The ciberlab scanner opened connections to many hosts on port 445.","severity":"medium","host":"edge-1","tags":["egress"],"author":"bruno"}' | idof)
inc PATCH "/$i2" '{"status":"true_positive","verdict":"Expected: scheduled scan of the lab range.","author":"bruno"}' >/dev/null
i3=$(inc POST "" '{"title":"Spike of 404s on example.org","detail":"A crawler walked a list of old URLs.","severity":"low","host":"edge-2","tags":["crawler"],"author":"ana"}' | idof)
inc PATCH "/$i3" '{"status":"false_positive","verdict":"Search engine crawler.","author":"ana"}' >/dev/null
inc POST "" '{"title":"Review the fail2ban ban time on edge-2","detail":"Repeat offenders return after the ban expires.","severity":"info","host":"edge-2","tags":["hardening"],"author":"bruno"}' >/dev/null
# New events keep arriving while the pages are captured.
"$demo" live 900 "$work/hub/logs:edge-1" "$work/peer/logs:edge-2" > "$work/live.log" 2>&1 &
pids+=($!)
sleep 6
if [ -n "${TABLES_ONLY:-}" ]; then
# mobile table check (375x812) instead of the documentation pictures: TABLES_ONLY=1 OUT=/tmp/x scripts/screenshots.sh
node "$root/scripts/screenshots/tables.mjs" "http://127.0.0.1:$hub_port" "$out"; exit $?
fi
node "$root/scripts/screenshots/shots.mjs" "http://127.0.0.1:$hub_port" "http://127.0.0.1:$login_port" "$out"
if command -v oxipng >/dev/null; then oxipng -q -o 3 --strip safe "$out"/*.png
elif command -v pngquant >/dev/null; then for f in "$out"/*.png; do pngquant --quality 90-100 --force --output "$f" "$f"; done; fi
echo "screenshots written to $out"