fix(supabase): sheet-assets e2e can no longer reach DEV

The runner read the DEV keys from supabase status and targeted
http://127.0.0.1:54321 (two read-only incidents on 2026-11-01). It now
refuses, before building or any request, every URL but the sandbox gateway
and every key not issued by the sandbox; no DEV URL, port or key remains.
Same bytes as the V1-2 runner; that branch brings the sandbox command.
This commit is contained in:
bchanot committed 2026-11-02 00:24:02 +01:00
1 parent 9135d73cfa
commit e24e747d90
3 files changed
+33 -14

No files matched your search

+1 -1
View File
@@ -135,7 +135,7 @@ pnpm preview:draft # same, then serves it
pnpm import:equine --check | --out <dir> # since R5.6 the official seed writer: the Rust pipeline (same as `pnpm r5:import-equine`), fingerprint `sha256-rfc8785-validated-v1`; the TypeScript generator left at R5.7 (replayed from a historical revision only, RUST.md §11.23)
pnpm r5:import-equine --check | --out <dir> # the Rust pipeline (R5.2 importer, R5.3 draft, R5.4 review files): compare the 18 generated files with the committed folders (bytes; app drawings under the declared R3 rule), or write <dir>/{legacy-import,draft} into an empty folder; never deletes (scripts/import-equine.sh, first run compiles)
pnpm assets:upload [--check] <seed folder> # R5.5: uploads the sheet drawings of a generated seed folder to the LOCAL stack's private bucket (Rust `upload-sheet-assets`, feature `upload`; SUPABASE_URL local with a port, SUPABASE_SERVICE_ROLE_KEY typed, never printed; no overwrite, confirm after verify; run by hand, scripts/upload-sheet-assets.sh)
pnpm e2e:sheet-assets # scripts/sheet-assets-e2e.sh: that tool against the local stack (upload, rerun, anon and wrong key, refused destinations); run by hand
pnpm e2e:sheet-assets # scripts/sheet-assets-e2e.sh: sandbox only, refuses before any request unless the sandbox gateway URL and sandbox-issued keys are set (its runner `pnpm db:sandbox sheet-assets-e2e` arrives with V1-2); never DEV
pnpm report:compare <pdf|dir>... # archive check: attachment vs its v3 reading, unresolved items flagged (docs/PDF-FORMAT.md); the core's `report-compare` binary since R4.7 (scripts/report-compare.sh, first run compiles)
# Rust (docs/development/RUST.md) — native toolchain (user-level rustup, channel of rust-toolchain.toml) first
+6 -2
View File
@@ -156,8 +156,12 @@ destination, content, handshake, state, access), 2 an argument that is not
UTF-8, 3 network. The DEV address counts only if it is an address of this
machine. The key is
never printed and goes through no proxy. `pnpm e2e:sheet-assets` runs the
whole behaviour against the local stack (upload, rerun, anon and wrong key,
refused destinations, unreachable port). The TypeScript tool
whole behaviour (upload, rerun, anon and wrong key, refused destinations,
unreachable port) on the throwaway sandbox only: since 2026-11-02 it refuses,
before building or any request, every target but the sandbox gateway
`http://127.0.0.1:57800` with keys issued by the sandbox (its runner
`pnpm db:sandbox sheet-assets-e2e` arrives with V1-2); it never reads the DEV
keys and never targets DEV. The TypeScript tool
(`packages/supabase/scripts/upload-sheet-assets.ts`) was deleted at R5.7 (RUST.md §11.23).
### 3.2 Files worker (Storage, Step 8)
+26 -11
View File
@@ -1,8 +1,10 @@
#!/usr/bin/env bash
# `pnpm e2e:sheet-assets`: the sheet-asset upload tool against the LOCAL Supabase stack (R5.5,
# docs/development/SUPABASE.md §3.1). Needs `pnpm db:start`. Run by hand: it uploads the equine
# draft drawing to the local bucket and confirms its row (idempotent; a rerun changes nothing).
# The keys are read from `pnpm supabase status`, held in variables, never printed.
# `pnpm e2e:sheet-assets` (= `pnpm db:sandbox sheet-assets-e2e`): the sheet-asset upload tool against the
# throwaway SANDBOX stack (docs/development/SUPABASE.md §3.1, §5.1), never DEV. It uploads the equine draft
# drawing to the sandbox bucket and confirms its row (idempotent; a rerun changes nothing).
# The runner (scripts/db-sandbox.sh) starts the gateway and passes SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY
# and SUPABASE_ANON_KEY in the environment; this script refuses anything else before building or any
# request, and never prints a key.
#
# Checks: --check writes nothing; a first run uploads and confirms; a rerun has nothing to do;
# the anon key and a wrong key are refused; a destination that is not a local stack is refused
@@ -10,17 +12,30 @@
set -uo pipefail
cd "$(dirname "$0")/.."
SANDBOX_URL=http://127.0.0.1:57800
SERVICE=${SUPABASE_SERVICE_ROLE_KEY:-}
ANON=${SUPABASE_ANON_KEY:-}
# A key is accepted only when its JWT payload names the sandbox issuer; nothing is printed.
sandbox_key() { printf '%s' "$1" | python3 -I -c '
import base64, json, sys
try:
p = sys.stdin.read().split(".")[1]
sys.exit(0 if json.loads(base64.urlsafe_b64decode(p + "=" * (-len(p) % 4))).get("iss") == "db-sandbox" else 1)
except Exception:
sys.exit(1)'; }
if [ "${SUPABASE_URL:-}" != "$SANDBOX_URL" ] || ! sandbox_key "$SERVICE" || ! sandbox_key "$ANON"; then
echo "sheet-assets-e2e: refused, nothing was run. Sandbox only: the sandbox gateway URL and sandbox-issued" >&2
echo "keys, set by pnpm db:sandbox sheet-assets-e2e where that runner exists; it never targets DEV." >&2
exit 2
fi
. scripts/rust-env.sh
SEED=supabase/seed/anatomical-sheets/equine/draft
BIN=target/release/upload-sheet-assets
FAIL=0
env -u SUPABASE_SERVICE_ROLE_KEY cargo build --release --locked -q -p faunosteo-core --features upload --bin upload-sheet-assets || exit 2
STATUS=$(bash scripts/supabase.sh status -o json 2>/dev/null) || { echo "stack not running (pnpm db:start)"; exit 2; }
field() { printf '%s' "$STATUS" | python3 -c "import json,sys;print(json.load(sys.stdin)['$1'])"; }
SERVICE=$(field SERVICE_ROLE_KEY)
ANON=$(field ANON_KEY)
LOCAL=http://127.0.0.1:54321
LOCAL=http://127.0.0.1:57800
# expect <name> <expected exit> <url> <key> <args...>; output kept to grep, keys never echoed.
expect() {
@@ -42,8 +57,8 @@ expect "rerun" 0 "$LOCAL" "$SERVICE" "$SEED"
grep -q "nothing to do" <<<"$LAST" && echo "PASS rerun has nothing to do" || { echo "FAIL rerun did work"; FAIL=1; }
expect "anon key refused" 1 "$LOCAL" "$ANON" "$SEED"
expect "wrong key refused" 1 "$LOCAL" "not-a-valid-key" "$SEED"
expect "https refused" 1 "https://127.0.0.1:54321" "$SERVICE" "$SEED"
expect "non-local host refused" 1 "http://example.test:54321" "$SERVICE" "$SEED"
expect "https refused" 1 "https://127.0.0.1:57800" "$SERVICE" "$SEED"
expect "non-local host refused" 1 "http://example.test:57800" "$SERVICE" "$SEED"
expect "no port refused" 1 "http://127.0.0.1" "$SERVICE" "$SEED"
expect "unreachable port" 3 "http://127.0.0.1:9" "$SERVICE" "$SEED"
expect "folder outside the seed" 1 "$LOCAL" "$SERVICE" --check crates/core/src