Skip to content

Commit 30ece3b

Browse files
author
LudoLoops
committed
fix(dashboard): validate effective Compose and isolate DB commands (#589)
Addresses the two remaining blockers from the PR #660 review. B-01 — effective Compose provenance: - a managed `docker-compose.yml` must now be byte-identical to the canonical generated document; any added/overriding YAML property is refused; - Compose override files (`compose.override*`, `docker-compose.override*`, `compose.yaml`, …) and ambient `COMPOSE_*` controls (COMPOSE_FILE, COMPOSE_PROJECT_NAME, COMPOSE_PROFILES, …) are rejected before any write or Compose operation; - the effective model is parsed by Compose itself (`docker compose config --format json`, with candidate .env values) and validated for exactly one service, image, loopback port/published mapping, named volume, environment, health check and absence of network_mode — before `.env` is written or the container is started. B-02 — the verified connection is authoritative: - `auth:schema`, `db:push` and `admin:create` run with a sanitized child environment: ambient DATABASE_URL/TEST_DATABASE_URL/PG*/DRIZZLE_* are removed and DATABASE_URL is set to the verified `.env` URL. An exported remote DATABASE_URL can no longer redirect `db:push --force`; this is announced explicitly when it differs. Tests: override file, ambient COMPOSE_FILE, effective extra ports, canonical tampering, ambient hostile DATABASE_URL for schema and admin (asserting the child env), plus the existing refusals. Real-Compose smoke now provisions with hostile ambient DB vars and asserts override/control refusals. Validated: `bun run test` 1398 passed, lint, typecheck, `scripts/test-local-setup.sh` (real Compose/PostgreSQL, positive + hostile paths), `scripts/test-scaffold.sh dashboard`. Refs #589.
1 parent d6fe739 commit 30ece3b

8 files changed

Lines changed: 586 additions & 140 deletions

File tree

‎.changeset/589-local-dashboard-setup.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ Dashboard projects now ship an explicit, safe local-development setup (#589):
66

77
- `bash scripts/setup.sh` still prepares only the private `.env` and a strong Better Auth secret by default; `--compose` generates a loopback-only `docker-compose.yml` (PostgreSQL 17, named volume, health check, per-project random password) and starts it, `--init-schema` generates the pending Better Auth schema and runs `db:push` **only** against that verified local Compose database, and `--admin` creates the first administrator from `ADMIN_NAME`/`ADMIN_EMAIL` (generating a password into the ignored `.env` when missing, never printing it; an existing admin is a no-op).
88
- Generated Dashboards expose `<pm> run dev:setup` and `<pm> run dev:local`; plain `dev` and project creation stay side-effect free, and `svforge create` offers the setup only interactively (headless runs print the exact command instead).
9-
- Existing `docker-compose.yml` files are reused only when they carry the SVForge ownership marker and match the managed service exactly; anything else is refused before credentials are written or Compose runs. Schema initialization verifies the exact URL credentials/port, the running service's published port and its database identity, and `--admin` relies on a dedicated exit code (3 = already exists) instead of message text.
9+
- Existing `docker-compose.yml` files are reused only when they carry the SVForge ownership marker and match the managed service exactly; anything else is refused before credentials are written or Compose runs. Schema initialization validates the effective Compose model (parsed by Compose, including interpolation), refuses override files and ambient `COMPOSE_*` controls, verifies the exact URL credentials/port, the running service's published port and its database identity, and runs `auth:schema`/`db:push`/`admin:create` with a sanitized environment so an exported `DATABASE_URL` can never redirect them away from the verified local `.env` connection. and `--admin` relies on a dedicated exit code (3 = already exists) instead of message text.
1010
- `setup.sh` reruns preserve secrets, volumes and rows; `.env` stays Git-ignored with mode 600; external `DATABASE_URL` values are never replaced and never receive automatic migrations.

0 commit comments

Comments
 (0)