mirror of
https://github.com/block/buzz.git
synced 2026-10-28 13:01:10 +00:00
fix(seed): refuse connection-string PGDATABASE in local-only admin seed guard
psql -d treats URI and key=value values as full connection strings that override -h, so PGDATABASE could route the unarmed fixture writer to a shared database. Accept only a plain database name before either psql path, and extend the refusal test with URI and key/value cases (host=, hostaddr=, service=) plus a plain-name control that must reach psql. Also note in replica_fence that prepared-transaction coverage comes from the retained deferred trigger, not the insert-time app guard. Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
This commit is contained in:
@@ -31,6 +31,12 @@ case "${PGHOST}" in
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
# psql -d treats URI and key=value values as full connection strings that
|
||||
# override -h, so accept only a plain database name.
|
||||
if [[ ! "${PGDATABASE}" =~ ^[A-Za-z0-9_-]+$ ]]; then
|
||||
echo "error: admin seed requires a local PostgreSQL target with a plain PGDATABASE name" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if command -v psql >/dev/null 2>&1; then
|
||||
run_psql() {
|
||||
|
||||
Reference in New Issue
Block a user