fix(clio-probes): make the read-only DB rail a genuine allow-list, and test it
The previous proxy CLAIMED to allow only from() while implementing a deny-list
of property names, and the reviewer walked past it twice: `db.rest` is a public
property holding the PostgrestClient, so `db.rest.from(t).update(...)` and
`db.rest.rpc(...)` never met the guard, and `db.schema("public").from(t)`
returns a fresh, unwrapped builder. Enumerating the ways out of a client is a
game you lose on the next dependency bump; naming the one way in is not.
Reading ANY property other than `from` now throws. Symbols and `then` are the
two deliberate exceptions and return undefined rather than throwing - a proxy
that throws on Symbol.toStringTag explodes the moment anything logs it, and one
returning a function for `then` looks thenable to `await`. Neither can reach the
database.
Moved into scripts/readOnlyDb.ts so the guarantee can be unit-tested without
importing a script that runs on import, with scripts/readOnlyDb.test.ts (15
tests) covering the happy read path, all four builder writes, every refused
entry point, both proven bypasses, and the inert symbol/then handling. The
reviewer's point that a manual one-off smoke adds no regression protection is
correct - this survives refactors. vitest.config.ts include extended to
scripts/**/*.test.ts so `npm test` runs it.
Verified: tsc --noEmit + tsc -p tsconfig.scripts.json clean; prettier clean;
15/15 new tests; --dry-run clean; and the real Supabase client still reads
through the stricter proxy (offline smoke with dummy env reaches the network
rather than a blocked-access throw).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
| Repository | Sloth-ninja/JessicaOSS |
|---|---|
| Author | sloth-ninja <ezanahaddis@gmail.com> |
| Authored | |
| Committed | |
| Parents | fd29a7b5 |
| Stats | 4 files changed , +267 , -84 |
| Part of | Guard-railed Clio live-probe runner |
Capture this commit into my fork
Download a Markdown prompt that tells Claude how to port this
exact commit into your working tree. Run it via
claude -p < capture-commit-711ea9b3.md
from inside the repo you want the change in.