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/store/tests/pinned-clone.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 / store / tests / pinned-clone.sh` 110 lines ยท 6624 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # ORACLE: private store fixture, both bases, clone-base/no-base, empty repo and pin lifetime. 3 # No live data or services. The mutant removes clone --no-checkout; the exact panel oracle refuses it. 4 set -euo pipefail 5 cd "$(dirname "$0")/../.." 6 PORT=${PINNED_CLONE_PORT:-18583} 7 case $PORT in 185[5-9][0-9]) ;; *) echo 'REFUSED: private port must be 18550..18599'; exit 2;; esac 8 ss -ltnH "sport = :$PORT" | grep -q . && { echo 'NOT_RUN: port busy'; exit 3; } 9 OMC=${OMEGA_MV:-$HOME/work/flux/omega-mv}/seed/out/omc 10 [ "$(sha256sum "$OMC" | cut -d' ' -f1)" = `3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194` ] 11 T=$(mktemp -d /tmp/forge-pinned-clone.XXXXXX) 12 pid=; pass=0 13 cleanup() { if [ -n "$pid" ]; then kill "$pid" 2>/dev/null || true; wait "$pid" 2>/dev/null || true; fi; [ "${KEEP_TEST_TMP:-0}" = 1 ] || rm -rf "$T"; } 14 trap cleanup EXIT 15 run() { taskset -c "${CORES:-4,5}" nice -n 10 "$@"; } 16 ok() { pass=$((pass+1)); echo "PASS $*"; } 17 die() { echo "FAIL $*"; exit 1; } 18 export GIT_AUTHOR_NAME=fixture GIT_AUTHOR_EMAIL=fixture@invalid GIT_COMMITTER_NAME=fixture GIT_COMMITTER_EMAIL=fixture@invalid 19 export GIT_AUTHOR_DATE=2026-01-01T00:00:00Z GIT_COMMITTER_DATE=2026-01-01T00:00:00Z 20 mkdir -p "$T/w" "$T/store/projects" "$T/data/logs" "$T/bin" "$T/ng" 21 cp server/tests/fake/rad server/tests/fake/getent "$T/bin/" 22 chmod +x "$T/bin/"* 23 : > "$T/ng/dl.log"; : > "$T/ng/access.log" 24 git -C "$T/w" init -q -b main 25 printf '# Fixture\n\n[file](file.txt)\n' > "$T/w/README.md" 26 printf 'old\n' > "$T/w/file.txt" 27 git -C "$T/w" add .; git -C "$T/w" commit -qm one 28 old=$(git -C "$T/w" rev-parse HEAD) 29 printf 'new\n' > "$T/w/file.txt"; git -C "$T/w" commit -qam two 30 head=$(git -C "$T/w" rev-parse HEAD) 31 # Deliberately create a ref named after the older commit but pointing at the newer one. 32 git -C "$T/w" branch "$old" "$head" 33 # These are parser fixtures, not signed landing records. Forge checks record 1's hash and fields. 34 mkproject() { 35 local name=$1 sha=$2 p="$T/store/projects/$1" id 36 mkdir -p "$p/records" 37 if [ "$sha" = none ]; then git init -q --bare "$p/repo.git"; else git clone -q --bare "$T/w" "$p/repo.git"; fi 38 printf 'interplane-project 1\nproject %s\nbranch main\nvisibility public\nowner SHA256:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nalias -\nnonce `00000000000000000000000000000000`\n' "$name" > "$p/records/1" 39 id=$(sha256sum "$p/records/1" | cut -d' ' -f1) 40 printf '%s\t%s\tmain\t%s\tpublic\n' "$name" "$id" "$sha" >> "$T/store/catalog.tsv" 41 } 42 mkproject Name._-9 "$head" 43 mkproject empty none 44 export FORGE_STORE="$T/store" FORGE_SITE_REF=${FORGE_SITE_REF:-`c6c3d3b3d2a846bb60c67b224e18d22e408fa2be`} 45 export FORGE_SITE_STORE=${FORGE_SITE_STORE:-$HOME/interplane-store-owner/projects/interplane.io/repo.git} 46 build() { 47 local name=$1 base=$2 48 export FORGE_CLONE_BASE=$base 49 { printf 'om2\n'; cat $(./run.sh units); } | sed \ 50 -e "s|`2130706433` 18480|`2130706433` $PORT|" \ 51 -e "s|/home/drakestapleton/forge-data/|$T/data/|g" \ 52 -e "s|^text tfzp0 .*|text tfzp0 \"$T/ng/dl.log\"|" \ 53 -e "s|^text tfzp1 .*|text tfzp1 \"$T/ng/access.log\"|" \ 54 -e "s|^text tfzwal .*|text tfzwal \"$T/ng/wal\"|" \ 55 -e "s|^text tfzspth .*|text tfzspth \"$T/counts.snapshot\"|" \ 56 -e "s|^text tfzrad .*|text tfzrad \"$T/bin/rad\"|" \ 57 -e "s|^text tfzgent .*|text tfzgent \"$T/bin/getent\"|" > "$T/$name.om" 58 ! grep -qE '`2130706433` 18480|/home/drakestapleton/forge-data/' "$T/$name.om" || die 'live target remains' 59 run "$OMC" < "$T/$name.om" > "$T/$name.bin" 60 chmod +x "$T/$name.bin" 61 } 62 start() { 63 FORGE_SOCIAL_DIR="$T/data/" taskset -c "${CORES:-4,5}" nice -n 10 "$T/$1.bin" > "$T/$1.log" 2>&1 & pid=$! 64 for _ in {1..60}; do 65 kill -0 "$pid" 2>/dev/null || die 'server exited during startup' 66 curl -fsS --max-time 1 -o /dev/null "http://127.0.0.1:$PORT/explore" 2>/dev/null && return 67 sleep .1 68 done 69 die 'server did not start' 70 } 71 stop() { kill "$pid"; wait "$pid" 2>/dev/null || true; pid=; } 72 get() { [ "$(curl -sS --max-time 20 -o "$T/page" -w '%{http_code}' -H "X-Forge-Base: $2" "http://127.0.0.1:$PORT/drakestapleton/$1")" = 200 ] || die "GET $1"; } 73 panel() { grep -o '
"$T/panel"; } 74 checkpanel() { 75 local base=$1 cb=$2 clone= 76 if [ -n "$cb" ]; then clone="
Git over HTTPS
git clone --no-checkout ${cb}projects/Name._-9/repo.git Name._-9 && git -C Name._-9 checkout --detach $head
"; fi 77 printf '
Get this repository
%s
Source archive of %s
Download ZIP · tar.gz
\n' "$clone" "$head" "$base" "$head" "$base" "$head" > "$T/want" 78 cmp -s "$T/want" "$T/panel" 79 } 80 build good https://interplane.io/ 81 build nobase '' 82 for variant in good nobase; do 83 start "$variant" 84 cb=https://interplane.io/; [ "$variant" = good ] || cb= 85 for base in / /forge/; do 86 get Name._-9 "$base"; panel 87 checkpanel "$base" "$cb" || die "$variant $base exact panel" 88 ok "$variant $base exact commit-pinned panel, translation hints and safe name punctuation" 89 grep -qF "href=\"${base}drakestapleton/Name._-9/tree/$head\"" "$T/page" || die 'Files tab not pinned' 90 grep -qF "blob/$head/file.txt" "$T/page" || die 'README link not pinned' 91 ok "$variant $base Files and README links pinned" 92 get "Name._-9/tree/$old" "$base" 93 grep -qF "tree/$old\"" "$T/page" || die 'commit ref shadowed by same-named branch' 94 grep -qF "commit/$old" "$T/page" || die 'wrong commit rendered' 95 ok 'NEG full commit id wins over conflicting branch' 96 get empty "$base" 97 ! grep -q 'Get this repository' "$T/page" || die 'empty repo has panel' 98 grep -q 'Nothing to download yet' "$T/page" || die 'empty message missing' 99 ! grep -qF "tree/$head" "$T/page" || die 'pin leaked to next page' 100 ok "$variant $base empty repository refuses downloads, pin does not leak" 101 done 102 stop 103 done 104 sed 's/git clone --no-checkout /git clone /' "$T/good.om" > "$T/mutant.om" 105 run "$OMC" < "$T/mutant.om" > "$T/mutant.bin"; chmod +x "$T/mutant.bin" 106 start mutant; get Name._-9 /; panel 107 if checkpanel / https://interplane.io/; then die 'clone mutant escaped oracle'; fi 108 ok 'NEG clone mutant fails exact panel oracle' 109 stop 110 echo "pinned clone: $pass pass, 0 fail"