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/collab/tests/postpath.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 / collab / tests / postpath.sh` 53 lines ยท 3374 bytes Raw Blame History 1 #!/bin/bash 2 # ORACLE: host test driver (bash + curl), not product code. 3 # collab/tests/postpath.sh: a POST whose segment after /patches/ or /issues/ is long must not end forged. 4 # copost (collab/co9form.om) looks for the end of the id segment with a bounded scan; the bound was 128 5 # while the rest of the path can be 4096 bytes, so a segment of 129 bytes or more with no slash was 6 # trap 4 (exit 104), with no sign-in. Found in the bound sweep after the review of `486f1cd8`. 7 # A test forged on PORT (default 18500) with a private data dir reads the real store and allow-list 8 # (read-only). Negative control: the same build with the old bound must exit 104 on the 129-byte POST. 9 # Usage: collab/tests/postpath.sh (CORES default 14; POSTPATH_PORT; KEEP=1 keeps the temp dir) 10 set -u 11 H=$(cd "$(dirname "$0")" && pwd) 12 export PORT=${POSTPATH_PORT:-18500} CORES=${CORES:-14} 13 T=$(mktemp -d /tmp/cppost.XXXXXX) 14 PASS=0; FAIL=0; PID= 15 ok() { PASS=$((PASS+1)); echo "PASS $*"; } 16 bad() { FAIL=$((FAIL+1)); echo "FAIL $*"; } 17 check() { if [ "$1" = "$2" ]; then ok "$3 ($1)"; else bad "$3: want $2, got $1"; fi; } 18 trap '[ -n "$PID" ] && kill $PID 2>/dev/null; wait 2>/dev/null; [ -n "${KEEP:-}" ] || rm -rf "$T"' EXIT 19 if ss -ltn | grep -q "127.0.0.1:$PORT "; then echo "NOT_RUN: port $PORT busy"; exit 3; fi 20 R=/drakestapleton/cuda-crack 21 start() { # start OUT [SEDX]: build and start a test forged; PID set 22 mkdir -p "$T/data" 23 DATA=$T/data/ SEDX=${2:-} "$H/tbuild.sh" "$1" || return 1 24 FORGE_SOCIAL_DIR=$T/data/ taskset -c "$CORES" nice -n 10 "$1" 2>> "$1.log" & 25 PID=$! 26 for _ in $(seq 50); do curl -s -o /dev/null "http://127.0.0.1:$PORT/explore" && return 0; sleep 0.1; done 27 return 1 28 } 29 stop() { kill $PID 2> /dev/null; wait $PID 2> /dev/null; PID=; sleep 0.3; } 30 seg() { printf '%*s' "$1" '' | tr ' ' a; } 31 post() { curl -s -o /dev/null --max-time 10 -w '%{http_code}' -X POST --data x=1 -H "X-Forge-Base: ${2:-/}" "http://127.0.0.1:$PORT$1"; } 32 start "$T/forged" || { bad "test forged did not start"; exit 1; } 33 check "$(curl -s -o /dev/null -w '%{http_code}' "http://127.0.0.1:$PORT$R/patches")" 200 "fixture: the patches page of cuda-crack" 34 for s in patches issues; do 35 for n in 128 129 3000; do 36 check "$(post "$R/$s/$(seg $n)")" 405 "POST $s/<$n bytes, no slash>" 37 done 38 check "$(post "$R/$s/$(seg 129)/compose")" 404 "POST $s/<129 bytes>/compose (not an id)" 39 check "$(post "$R/$s/$(seg 129)" /forge/)" 405 "[/forge/] POST $s/<129 bytes>" 40 done 41 check "$(curl -s -o /dev/null -w '%{http_code}' "http://127.0.0.1:$PORT/explore")" 200 "server still answers after the long POST paths" 42 if kill -0 $PID 2> /dev/null; then ok "server process still running"; else bad "server process is gone"; fi 43 stop 44 # negative control: the old bound 45 start "$T/mut" 's/^while lt e n bound 4096$/while lt e n bound 128/' || { bad "mutant did not start"; exit 1; } 46 a=$(grep -c '^while lt e n bound 128$' "$T/forged.om"); b=$(grep -c '^while lt e n bound 128$' "$T/mut.om") 47 [ "$b" = "$((a + 1))" ] && ok "mutant: one scan back at bound 128" || bad "mutant: scans at bound 128: $a, then $b (want one more)" 48 check "$(post "$R/patches/$(seg 128)")" 405 "mutant still answers a 128-byte segment" 49 post "$R/patches/$(seg 129)" > /dev/null 50 wait $PID 2> /dev/null; rc=$?; PID= 51 check "$rc" 104 "NEG the old bound exits on the 129-byte POST (trap 4)" 52 echo "collab postpath: $PASS passed, $FAIL failed" 53 [ "$FAIL" = 0 ]