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/dl/tests/pinned-archives.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 / dl / tests / pinned-archives.sh` 83 lines ยท 4762 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # ORACLE: exercise the deployed edge CGI's commit archives with private Git fixtures, no sockets. 3 # The product CGI and nginx snippet stay byte-identical to their deployed copies. Only this 4 # private executable's fixed public root is substituted. Every accepted class has a refused twin. 5 set -euo pipefail 6 cd "$(dirname "$0")/../.." 7 T=$(mktemp -d /tmp/forge-pinned-archive.XXXXXX) 8 trap '[ "${KEEP_TEST_TMP:-0}" = 1 ] || rm -rf "$T"' EXIT 9 run() { taskset -c "${CORES:-4,5}" nice -n 10 "$@"; } 10 pass=0 11 ok() { pass=$((pass+1)); echo "PASS $*"; } 12 die() { echo "FAIL $*"; exit 1; } 13 export GIT_AUTHOR_NAME=fixture GIT_AUTHOR_EMAIL=fixture@invalid GIT_COMMITTER_NAME=fixture GIT_COMMITTER_EMAIL=fixture@invalid 14 export GIT_AUTHOR_DATE=2026-01-01T00:00:00Z GIT_COMMITTER_DATE=2026-01-01T00:00:00Z 15 mkdir -p "$T/public" "$T/w" 16 git -C "$T/w" init -q -b main 17 printf 'one\n' > "$T/w/README" 18 git -C "$T/w" add README; git -C "$T/w" commit -qm one 19 old=$(git -C "$T/w" rev-parse HEAD) 20 printf 'two\n' >> "$T/w/README"; git -C "$T/w" commit -qam two 21 head=$(git -C "$T/w" rev-parse HEAD) 22 branch=$(printf branch | git -C "$T/w" commit-tree "$old^{tree}") 23 tag=$(printf tag | git -C "$T/w" commit-tree "$old^{tree}") 24 dangling=$(printf dangling | git -C "$T/w" commit-tree "$old^{tree}") 25 git clone -q --bare "$T/w" "$T/public/fixture.git" 26 G=(git --git-dir="$T/public/fixture.git") 27 # Objects unreachable from main are copied explicitly, then only two get canonical refs. 28 for c in "$branch" "$tag" "$dangling"; do "${G[@]}" fetch -q "$T/w" "$c"; done 29 "${G[@]}" update-ref refs/heads/other "$branch" 30 "${G[@]}" update-ref refs/tags/only-tag "$tag" 31 "${G[@]}" update-ref refs/noncanonical/hidden "$dangling" 32 blob=$("${G[@]}" rev-parse "$head:README") 33 sed "s|^export GIT_PROJECT_ROOT=.*|export GIT_PROJECT_ROOT=$T/public|" infra/bazinga/omega-read > "$T/omega-read" 34 req() { 35 local path=$1 method=${2:-GET} 36 run env PATH_INFO="/fixture$path" REQUEST_METHOD="$method" QUERY_STRING= sh "$T/omega-read" > "$T/response" 37 # CGI headers end in CRLF CRLF. Keep archive bytes unmodified. 38 if head -1 "$T/response" | grep -q '^Status:'; then 39 status=$(head -1 "$T/response" | tr -d '\r' | cut -d' ' -f2) 40 else status=200; fi 41 LC_ALL=C awk '{ n += length($0) + 1; if ($0 == "\r") {print n; exit} }' "$T/response" > "$T/offset" 42 dd if="$T/response" of="$T/body" bs=1 skip="$(cat "$T/offset")" status=none 43 LC_ALL=C awk '$0 == "\r" {exit} {sub(/\r$/, ""); print}' "$T/response" > "$T/headers" 44 } 45 accept() { 46 local sha=$1 fmt=$2 path=${3:-/commits/$1.$2} 47 req "$path" 48 [ "$status" = 200 ] || die "$path status $status" 49 grep -qF "Content-Disposition: attachment; filename=fixture-$sha.$fmt" "$T/headers" || die disposition 50 grep -qF "ETag: \"$sha\"" "$T/headers" || die etag 51 grep -qFx 'Cache-Control: no-cache' "$T/headers" || die cache 52 local mime=application/zip; [ "$fmt" != tar.gz ] || mime=application/gzip 53 grep -qFx "Content-Type: $mime" "$T/headers" || die type 54 "${G[@]}" archive --format="$fmt" --prefix="fixture-$sha/" "$sha" > "$T/want" 55 cmp -s "$T/want" "$T/body" || die "$path body" 56 ok "$path status, type, disposition, cache, etag and archive bytes" 57 } 58 refuse() { req "$1"; [ "$status" = 404 ] && [ ! -s "$T/body" ] || die "$1 expected empty 404"; ok "NEG $1 empty 404"; } 59 for sha in "$head" "$old" "$branch" "$tag"; do 60 for fmt in zip tar.gz; do accept "$sha" "$fmt"; refuse "/commits/${sha:0:39}.$fmt"; done 61 done 62 refuse "/commits/${head:0:7}.zip" 63 for sha in "$dangling" "$blob" `0000000000000000000000000000000000000000` "${head^^}" "${head}0"; do refuse "/commits/$sha.zip"; done 64 for suffix in '' .tar .tgz .ZIP .zip. .zip/; do refuse "/commits/$head$suffix"; done 65 req "/commits/$head.zip" HEAD 66 [ "$status" = 200 ] && [ ! -s "$T/body" ] || die 'HEAD response' 67 ok 'HEAD has the same archive headers and no body' 68 req /refs/heads/main.zip 69 [ "$status" = 200 ] || die 'old branch route' 70 "${G[@]}" archive --format=zip --prefix=fixture-main/ "$head" > "$T/want" 71 cmp -s "$T/want" "$T/body" || die 'old branch bytes' 72 ok 'old /refs/heads/main.zip keeps its branch prefix' 73 refuse /refs/heads/missing.zip 74 req /archive/main.zip 75 [ "$status" = 200 ] && cmp -s "$T/want" "$T/body" || die 'old CGI archive alias' 76 ok 'old CGI /archive/main.zip alias stays equal' 77 # Mutant: remove reachability check. The same dangling request must now violate the refusal. 78 sed '/\[ -n "$visible" \] || notfound/d' "$T/omega-read" > "$T/mutant" 79 mv "$T/omega-read" "$T/good"; mv "$T/mutant" "$T/omega-read" 80 req "/commits/$dangling.zip" 81 [ "$status" = 200 ] && [ -s "$T/body" ] || die 'reachability mutant not detected' 82 ok 'NEG reachability mutant exposes hidden commit and fails the refusal oracle' 83 echo "pinned archives: $pass pass, 0 fail"