Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/interplane-forge/blob/main/server/tests/check.sh # interplane-forge INTERPLANE Forge Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `interplane-forge / server / tests / check.sh` 242 lines ยท 15672 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # server/tests/check.sh: host gates for the server-side fixes of review forge-web-`13102b54` 3 # (P3-3 keyed rate limiter, P3-4 Origin check on POST, P3-5 explicit deny list). 4 # bash server/tests/check.sh (spark; FORGED_CPUS default 4,5; FORGE_TEST_PORT default 18488) 5 # 1. ratelim: server/tests/ratelim.om composed with every forged unit calls the real fratelim. 6 # Negative control: the same test against the unkeyed util.om of `687e03a` must FAIL (P3-3 collision). 7 # 2. HTTP: a trial forged with its port, RIDS.md, storage and data dir redirected into a temp dir. 8 # The temp RIDS.md lists cuda-crack (control) plus omega-pearl, aien-crypto and pearl-alias 9 # (RID z2ft64...), each with storage present (symlinks to real public repos), so only fdeny can 10 # refuse them. Negative control: a mutant with fdeny and the Origin check removed must serve 11 # the denied rows (200) and accept a foreign Origin. 12 # Read-only on real storage; never touches 18480, ~/forge-data or port 18091. 13 # The Radicle storage the fixtures link to is FORGE_TEST_RSTORE (default ~/radicle-storage-frozen/storage, 14 # the read-only copy kept after the Radicle removal of 2026-11-14), and the site chrome comes from its 15 # interplane.io repository. STORE_VARIANT=1 (with IPL_DIR) runs the same gates against the 16 # store-reading build: the fixture becomes a store (store/tests/fixstore.sh) whose public lines are 17 # the test RIDS.md rows (the store build serves every public line), and the deny mutant removes the 18 # store's deny step (store/repos.om xscheck). 19 set -u 20 cd "$(dirname "$0")/../.." 21 ROOT=$(pwd) 22 CORES=${FORGED_CPUS:-4,5} 23 PORT=${FORGE_TEST_PORT:-18488} 24 OMC=$HOME/work/flux/omega-mv/seed/out/omc 25 STORE=${FORGE_TEST_RSTORE:-$HOME/radicle-storage-frozen/storage} 26 export FORGE_SITE_STORE=${FORGE_SITE_STORE:-$STORE/`z399yKvnXcBQNkKoq86iBDgTvQ5QV`} 27 SV=${STORE_VARIANT:-0} 28 OK_RID=z631r2JJiVT8it4tST7RK24hpowi # cuda-crack 29 R1=`z44GqrPVAPjZkhoD2MWVjqy18ighN` # aien-sovereign-core-mv storage, listed as omega-pearl 30 R2=z6do9WDBhuSnvopDkgFdFr1yWA62 # omega-mv storage, listed as aien-crypto 31 DENY=`z2ft64NFLsKzWttCXw6NWNbRQLggQ` # withdrawn omega-pearl RID 32 T=$(mktemp -d) 33 if [ "$SV" = 1 ]; then 34 # the unit gate (section 1) compiles the store units against the real table; section 2 its own 35 export FORGE_STORE=$T/store 36 echo "STORE_VARIANT: store-reading build, store $T/store" 37 fi 38 pid= 39 pass=0; fail=0 40 ok() { pass=$((pass+1)); echo "PASS $*"; } 41 bad() { fail=$((fail+1)); echo "FAIL $*"; } 42 cleanup() { [ -n "$pid" ] && kill "$pid" 2>/dev/null; wait 2>/dev/null; rm -rf "$T"; } 43 trap cleanup EXIT 44 if ss -ltn | grep -q "127.0.0.1:$PORT "; then echo "NOT_RUN: port $PORT busy"; exit 3; fi 45 run() { taskset -c "$CORES" nice -n 10 "$@"; } 46 47 compose() { # compose OUT [util.om] : every unit, main renamed so a test main can follow 48 local util=${2:-server/util.om} 49 { printf 'om2\n'; for u in $(./run.sh units); do 50 [ "$u" = server/util.om ] && cat "$util" || cat "$u"; done; } > "$1" 51 } 52 53 # ---- 1. rate limiter unit gate 54 compose "$T/rl.om" 55 sed -i 's/^fn main to int$/fn fmainx to int/' "$T/rl.om" 56 cat server/tests/ratelim.om >> "$T/rl.om" 57 if run "$OMC" < "$T/rl.om" > "$T/rl" 2> "$T/rl.err"; then 58 chmod 755 "$T/rl"; run "$T/rl"; rc=$? 59 [ "$rc" = 0 ] && ok "ratelim: 30/60s per IP, other IPs and old-bucket colliders unaffected, 300-IP fill" || bad "ratelim exit $rc" 60 else bad "ratelim compile: $(cat "$T/rl.err")"; fi 61 git show `687e03a`:server/util.om > "$T/oldutil.om" 62 printf 'global fretry ulong 1\nglobal fcspsb ulong 1\nglobal ftxmore ulong 1\nglobal fag uchar 256\nglobal fagl ulong 1\nglobal frf uchar 256\nglobal frfl ulong 1\nglobal fbig uchar `3145728`\nglobal fbigl ulong 1\nfn fsetsbx to void\nput fcspsb 0 1\nend\n' >> "$T/oldutil.om" 63 # the allow-list size the current units loop to (server/util.om FAMAX, 2026-11-14); the old table stays 64 printf 'const FAMAX ulong 64\n' >> "$T/oldutil.om" 65 # the "moving" 503 flag the current pages and JSON errors read (server/util.om fmvng, restore 2026-11-14) 66 printf 'global fmvng ulong 1\n' >> "$T/oldutil.om" 67 # the streaming exec of the current util.om (browse reads ref lists through it); the limiter under test 68 # stays the unkeyed one of `687e03a` 69 # Keep the current file-input exec path available to the patch handlers in the negative-control build. 70 sed -n '/^fn fchildin /,/^fn fdrain /{ /^fn fdrain /!p; }; /^fn fexecin /,/^fn fxput /{ /^fn fxput /!p; }' server/util.om >> "$T/oldutil.om" 71 sed -n '/^note streaming exec (fsopen/,/^global fsrs /p; /^note ---- streaming exec/,/^note ---- path builder/{/^note ---- path builder/!p}' server/util.om >> "$T/oldutil.om" 72 if grep -q '^global frlk ' "$T/oldutil.om"; then 73 bad "ratelim negative control: `687e03a` util.om is unexpectedly keyed" 74 else 75 # the old util.om has none of the store words, so this control composes the default units in 76 # both variants (the limiter is the same code in both builds) 77 (unset FORGE_STORE; compose "$T/rln.om" "$T/oldutil.om") 78 sed -i 's/^fn main to int$/fn fmainx to int/' "$T/rln.om" 79 cat server/tests/ratelim.om >> "$T/rln.om" 80 if run "$OMC" < "$T/rln.om" > "$T/rln" 2> "$T/rln.err"; then 81 chmod 755 "$T/rln"; run "$T/rln"; rc=$? 82 [ "$rc" != 0 ] && ok "ratelim negative control: unkeyed `687e03a` limiter fails (exit $rc)" || bad "ratelim negative control passed on the unkeyed limiter" 83 else bad "ratelim negative control compile: $(cat "$T/rln.err")"; fi 84 fi 85 86 # ---- 2. HTTP trial 87 mkdir -p "$T/storage" "$T/data/logs" "$T/ng" "$T/bin" 88 cp server/tests/fake/rad server/tests/fake/getent "$T/bin/" 89 chmod 755 "$T/bin/rad" "$T/bin/getent" 90 ln -s "$STORE/$OK_RID" "$T/storage/$OK_RID" 91 ln -s "$STORE/$R1" "$T/storage/$R1" 92 ln -s "$STORE/$R2" "$T/storage/$R2" 93 ln -s "$STORE/$OK_RID" "$T/storage/$DENY" 94 LONG_RID=`z2nYCN9XZAPjNohqT8bz46rcs9zvZ` # benchmarks-mv: has a file whose path is 123 bytes 95 LONGP=drakestapleton/benchmarks-mv/blob/`16a2f69624386f04436cd4f94bc0ee86ebf64def`/prime-drag-race/evidence/2026-10-05-campaign/c4/runs/blobs/`d01f5e3febda1c6fdcbdba83800d07f4fdfaec1d7385a1ae8c829a87c3a88da7` 96 ln -s "$STORE/$LONG_RID" "$T/storage/$LONG_RID" 97 cat > "$T/RIDS.md" < "$1.bin" 2> "$T/build.err" || { bad "build $1: $(cat "$T/build.err")"; exit 1; } 131 chmod 755 "$1.bin" 132 FORGE_SOCIAL_DIR="$T/data/" taskset -c "$CORES" nice -n 10 "$1.bin" > "$1.log" 2>&1 & 133 pid=$! 134 for _ in $(seq 50); do curl -s -o /dev/null "http://127.0.0.1:$PORT/explore" && return; sleep 0.2; done 135 bad "trial forged did not listen on $PORT"; exit 1 136 } 137 stop() { # stop the trial and wait until its port is free 138 kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid= 139 for _ in $(seq 50); do ss -ltn | grep -q "127.0.0.1:$PORT " || return; sleep 0.2; done 140 bad "trial forged still listening on $PORT"; exit 1 141 } 142 get() { curl -s -o "$T/b" -w '%{http_code}' -H 'X-Forge-Base: /' -H 'X-Real-IP: 10.9.9.9' "http://127.0.0.1:$PORT/$1"; } 143 post() { # post PATH [ORIGIN] 144 local h=() 145 [ -n "${2:-}" ] && h=(-H "Origin: $2") 146 curl -s -o "$T/b" -D "$T/h" -w '%{http_code}' -X POST -H 'X-Forge-Base: /' -H 'X-Real-IP: 10.9.9.8' \ 147 ${h[@]+"${h[@]}"} --data-urlencode csrf=x "http://127.0.0.1:$PORT/$1" 148 } 149 want() { [ "$2" = "$3" ] && ok "$1 = $2" || bad "$1 = $2 (want $3)"; } 150 151 compose "$T/f.om"; redirect "$T/f.om" 152 start "$T/f.om" 153 want "GET drakestapleton/cuda-crack (control)" "$(get drakestapleton/cuda-crack)" 200 154 want "GET drakestapleton/omega-pearl (listed, storage present)" "$(get drakestapleton/omega-pearl)" 404 155 want "GET drakestapleton/aien-crypto (listed, storage present)" "$(get drakestapleton/aien-crypto)" 404 156 want "GET drakestapleton/pearl-alias (RID $DENY)" "$(get drakestapleton/pearl-alias)" 404 157 want "GET drakestapleton/pearl-alias/tree/main" "$(get drakestapleton/pearl-alias/tree/main)" 404 158 want "GET rad:$DENY" "$(get "rad:$DENY")" 404 159 want "GET rad:$R1 (listed as omega-pearl)" "$(get "rad:$R1")" 404 160 get explore > /dev/null 161 if grep -q 'omega-pearl\|aien-crypto\|pearl-alias' "$T/b"; then bad "explore lists a denied repo"; else ok "explore lists no denied repo"; fi 162 grep -q '/drakestapleton/cuda-crack"' "$T/b" && ok "explore lists cuda-crack" || bad "explore lacks cuda-crack" 163 want "POST star, Origin https://evil.example" "$(post drakestapleton/cuda-crack/star https://evil.example)" 403 164 want "POST star, Origin https://interplane.io.evil.example" "$(post drakestapleton/cuda-crack/star https://interplane.io.evil.example)" 403 165 want "POST star, Origin null" "$(post drakestapleton/cuda-crack/star null)" 403 166 want "POST star, Origin http://interplane.io" "$(post drakestapleton/cuda-crack/star http://interplane.io)" 403 167 want "POST follow, Origin https://evil.example" "$(post follow https://evil.example)" 403 168 for o in https://interplane.io https://www.aienos.com ""; do 169 c=$(post drakestapleton/cuda-crack/star "$o") 170 l=$(tr -d '\r' < "$T/h" | sed -n 's/^[Ll]ocation: //p') 171 [ "$c $l" = "303 /login" ] && ok "POST star, Origin '${o:-absent}' = 303 /login (session gate decides)" || bad "POST star, Origin '${o:-absent}' = $c '$l' (want 303 /login)" 172 done 173 # a path or a header longer than a loop bound must not end the server: a loop count past its bound 174 # is trap 4 (exit 104), and the live forged exited that way 189 times on 2026-11-09 175 want "GET blob whose path is 123 bytes" "$(get "$LONGP")" 200 176 grep -q '[^<]*prime-drag-race/evidence' "$T/b" && ok "its title carries the path" || bad "its title lacks the path" 177 for v in blame commits; do want "GET $v of the 123-byte path" "$(get "${LONGP/blob/$v}")" 200; done 178 big=$(awk 'BEGIN { for (i = 0; i < 6000; i++) printf "a" }') 179 for h in Cookie Origin If-None-Match X-Real-IP X-Forge-Base; do 180 c=$(curl -s -o /dev/null -w '%{http_code}' -H "$h: $big" "http://127.0.0.1:$PORT/explore") 181 [ "$c" != 000 ] && ok "GET explore with a 6,000-byte $h answers ($c)" || bad "GET explore with a 6,000-byte $h: no answer" 182 done 183 want "GET explore after them (server still up)" "$(get explore)" 200 184 # access log: nine fields; agent and referrer as sent, a space as "+", "-" when absent, 200 bytes at most 185 lreq() { # lreq IP [curl args]: one GET /explore from IP, then that line of the trial's log 186 # forged sends the response before it writes the log line, so the line can come after curl 187 # returns: wait for a new line of this address, 5 s at most. No new line prints nothing, and 188 # the checks on the empty line fail. 189 local ip=$1 n0 n; shift 190 n0=$(grep -c " $ip " "$T/$LOGOF.log") 191 curl -s -o /dev/null -H 'X-Forge-Base: /' -H "X-Real-IP: $ip" "$@" "http://127.0.0.1:$PORT/explore" 192 for _ in $(seq 50); do 193 n=$(grep -c " $ip " "$T/$LOGOF.log") 194 if [ "$n" -gt "$n0" ]; then grep " $ip " "$T/$LOGOF.log" | tail -n 1; return 0; fi 195 sleep 0.1 196 done 197 return 1 198 } 199 LOGOF=f.om 200 l=$(lreq 10.9.9.7 -A 'Mozilla/5.0 (X11; Linux) Test Browser' -e 'https://example.org/a page') 201 want "log line fields" "$(printf '%s\n' "$l" | awk '{print NF}')" 9 202 want "log agent" "$(printf '%s\n' "$l" | cut -d' ' -f8)" 'Mozilla/5.0+(X11;+Linux)+Test+Browser' 203 want "log referrer" "$(printf '%s\n' "$l" | cut -d' ' -f9)" 'https://example.org/a+page' 204 want "log first fields keep their form" "$(printf '%s\n' "$l" | cut -d' ' -f2-5)" '10.9.9.7 1 /explore 200' 205 l=$(lreq 10.9.9.6 -H 'User-Agent:') 206 want "log without agent and referrer" "$(printf '%s\n' "$l" | cut -d' ' -f8-)" '- -' 207 l=$(lreq 10.9.9.5 -A "$big" -e "https://example.org/$big") 208 want "log agent of 6,000 bytes is cut to" "$(printf '%s\n' "$l" | cut -d' ' -f8 | tr -d '\n' | wc -c | tr -d ' ')" 200 209 want "log referrer of 6,020 bytes is cut to" "$(printf '%s\n' "$l" | cut -d' ' -f9 | tr -d '\n' | wc -c | tr -d ' ')" 200 210 l=$(lreq 10.9.9.4 -A "$(printf 'a\tb')") 211 want "log agent with a tab" "$(printf '%s\n' "$l" | cut -d' ' -f8)" 'a?b' 212 c=$(curl -s -o /dev/null -w '%{http_code}' -H 'X-Real-IP: 10.9.9.3' -A "$(printf 'a\177b')" "http://127.0.0.1:$PORT/explore") 213 want "agent with a DEL is refused by the HTTP layer and leaves no log line" "$c $(grep -c ' 10\.9\.9\.3 ' "$T/f.om.log")" "400 0" 214 want "GET explore after the long agent (server still up)" "$(get explore)" 200 215 stop 216 217 compose "$T/m.om"; redirect "$T/m.om" 218 if [ "$SV" = 1 ]; then 219 grep -c '^if fdeny k$' "$T/m.om" | grep -qx 1 || { bad "mutant: store deny site not found"; exit 1; } 220 sed -i 's/^if fdeny k$/if false/' "$T/m.om" 221 else 222 grep -c '^if and not fdeny i fstok i$' "$T/m.om" | grep -qx 1 || { bad "mutant: fdeny call site not found"; exit 1; } 223 fi 224 grep -c '^if and eq get fmeth 0 3 not forigok$' "$T/m.om" | grep -qx 1 || { bad "mutant: Origin gate not found"; exit 1; } 225 grep -c '^for i ulong hmin n 120 bound 120$' "$T/m.om" | grep -qx 1 || { bad "mutant: title loop not found"; exit 1; } 226 grep -c '^flga get fag i$' "$T/m.om" | grep -qx 1 || { bad "mutant: agent log site not found"; exit 1; } 227 sed -i -e 's/^if and not fdeny i fstok i$/if fstok i/' -e 's/^if and eq get fmeth 0 3 not forigok$/if eq get fmeth 0 99/' -e 's/^for i ulong hmin n 120 bound 120$/for i ulong n bound 120/' -e 's/^flga get fag i$/flgc get fag i/' "$T/m.om" 228 start "$T/m.om" 229 LOGOF=m.om 230 l=$(lreq 10.9.9.7 -A 'Mozilla/5.0 (X11; Linux) Test Browser') 231 n=$(printf '%s\n' "$l" | awk '{print NF}') 232 [ "$n" != 9 ] && ok "mutant that logs the agent raw writes $n fields (negative control: not 9)" || bad "mutant that logs the agent raw still writes 9 fields" 233 want "mutant GET drakestapleton/omega-pearl (negative control)" "$(get drakestapleton/omega-pearl)" 200 234 want "mutant GET drakestapleton/pearl-alias (negative control)" "$(get drakestapleton/pearl-alias)" 200 235 c=$(post drakestapleton/cuda-crack/star https://evil.example) 236 [ "$c" != 403 ] && ok "mutant POST with foreign Origin = $c (negative control: not 403)" || bad "mutant POST with foreign Origin still 403" 237 c=$(get "$LONGP"); sleep 0.3 238 if kill -0 "$pid" 2>/dev/null; then bad "mutant without the title cap survived the 123-byte path ($c)"; else wait "$pid"; ok "mutant without the title cap ends on the 123-byte path (exit $?, negative control)"; fi 239 stop 240 241 echo "server/tests/check.sh: $pass passed, $fail failed" 242 [ "$fail" = 0 ] && bash server/tests/title.sh