fix(supabase): db:trial database logs no statement from its first start
The image's init (migrate.sh) sent the supabase_admin password as SQL text while its postgresql.conf logged DDL, so the password reached the container log. The server now starts with -c log_statement=none, which the entrypoint also hands to the init server; a harness check pins it, and DEPLOY.md makes the post-init log scan a production prerequisite.
This commit is contained in:
1 parent
c6c984b954
commit
5f63d2229c
4 files changed
+15
-2
No files matched your search
@@ -46,6 +46,13 @@ Security prerequisites before deploying anything built from `develop`:
|
||||
- the worker's service key out of `.env`, its exposure to the `docker` group
|
||||
settled (RR-4);
|
||||
- images built off the VPS and pulled by digest, base images pinned (RR-6);
|
||||
- a self-hosted Supabase database on the `supabase/postgres` image starts with
|
||||
`-c log_statement=none` on its server command line from its very first
|
||||
start (the image's init sends role passwords as SQL text while its
|
||||
`postgresql.conf` logs DDL; the entrypoint passes the flag to the init
|
||||
server), and right after init its container log (and log files, if any) is
|
||||
scanned for the password, counts only, before anything else
|
||||
(`docs/development/SUPABASE.md` §5.2);
|
||||
- the RLS and API items of RR-3 and RR-4 and the dependency advisories of
|
||||
RR-1 treated or qualified.
|
||||
|
||||
|
||||
@@ -936,7 +936,7 @@ Proven only at the first `create` (the stub harness cannot prove them): the data
|
||||
ownership in the database image, `set local pgaudit.log` and `set local pg_stat_statements.track_utility` accepted by
|
||||
the image, the init's session-level `set` lines (`log_statement`, `log_min_duration_statement`,
|
||||
`log_min_error_statement`, `pgaudit.log`, `pg_stat_statements.track_utility`) accepted by it, whether the image's own
|
||||
init runs an `ALTER USER supabase_admin ... PASSWORD` before the schema file (where the init's settings cannot help), loopback `trust` in its `pg_hba.conf`
|
||||
init runs an `ALTER USER supabase_admin ... PASSWORD` before the schema file (where the init's settings cannot help; the first create, 2026-11-11, proved it does: `migrate.sh` runs the statement on the init temp server and the image's `postgresql.conf` sets `log_statement = 'ddl'`, so the statement with the password reached the db container's log; `create` now starts the server with `-c log_statement=none`, which the entrypoint hands to the init temp server and to the final server; not closed, named only: a failing init statement is still logged at the image's `log_min_error_statement = error`, `migrate.sh` puts the password on psql's command line inside the container during init, and `db-sandbox.sh` starts its database the same way without the flag; the fix is proven only by a `create` on a fresh volume with the container log scanned for the password, counts only, with the scan commands below), loopback `trust` in its `pg_hba.conf`
|
||||
(the rotation's commit marker relies on it), psql's echo of an error statement (a failing rotation statement must not print a
|
||||
secret), and the grant and factor SQL, which the harness checks as text and which first
|
||||
runs at the first real `grant`. Checks to make right after that first `create`, printing no value, only counts.
|
||||
|
||||
@@ -723,6 +723,7 @@ check "create: gateway refuses GoTrue's admin API" log_has 'location /auth/v1/ad
|
||||
check "create: gateway names itself on /__faunosteo_stack" log_has 'location = /__faunosteo_stack { default_type text/plain; return 200 "faunosteo_trial\n"; }'
|
||||
check "create: the database init turns statement logging on errors off first" log_has 'set log_min_error_statement = panic;'
|
||||
check "create: the database init silences statement logging and verbose errors, in order, before the first ALTER" lines_before_first "$(run_line faunosteo_trial_db | sed 's/\\n/\n/g')" '^ALTER ' '\set VERBOSITY terse' "set log_statement = 'none';" 'set log_min_duration_statement = -1;' 'set log_min_error_statement = panic;' "set pgaudit.log = 'none';" 'set pg_stat_statements.track_utility = off;'
|
||||
check "create: statement logging off on the server command line, so the image's init server (its migrate.sh ALTER USER ... PASSWORD) logs no statement" grep -qE 'exec docker-entrypoint\.sh postgres( [^ ]+)* -c log_statement=none( |$)' <(run_line faunosteo_trial_db | sed 's/\\n/\n/g')
|
||||
check "create: migrations through the CLI on the trial URL only" log_has 'supabase --workdir . migration up --db-url postgresql://postgres@127.0.0.1:58432/postgres?sslmode=disable PGPASSWORD=set'
|
||||
check "create: equine_draft.sql loaded" stdin_has "-- Official equine anatomical sheet"
|
||||
check "create: seed.sql never loaded" stdin_lacks faunosteo.local
|
||||
|
||||
+6
-1
@@ -426,8 +426,13 @@ sb_psql() {
|
||||
# rotate-secrets can renew every password through it. A failing ALTER would log its statement,
|
||||
# password included, at the default log_min_error_statement: the session turns statement logging
|
||||
# and verbose errors off first (psql sends the literal password, the server would log it).
|
||||
# The image's own init (migrate.sh) sends the supabase_admin password as SQL text on its init temp
|
||||
# server, and its postgresql.conf logs DDL: -c log_statement=none on the command line reaches that
|
||||
# temp server (the entrypoint passes every argument after postgres to it) and the final server, so
|
||||
# no statement is logged from the first start. The session set lines stay for the schema file itself
|
||||
# (errors, pgaudit, pg_stat_statements).
|
||||
# shellcheck disable=SC2016
|
||||
DB_INIT='cat <<'"'"'EOF'"'"' > /etc/postgresql.schema.sql && exec docker-entrypoint.sh postgres -D /etc/postgresql -c shared_buffers=128MB
|
||||
DB_INIT='cat <<'"'"'EOF'"'"' > /etc/postgresql.schema.sql && exec docker-entrypoint.sh postgres -D /etc/postgresql -c shared_buffers=128MB -c log_statement=none
|
||||
\set VERBOSITY terse
|
||||
set log_statement = '"'"'none'"'"';
|
||||
set log_min_duration_statement = -1;
|
||||
|
||||
Reference in new issue
Block a user