fix(selfhost): avoid postgres url argv leaks - #2461
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
gittensory-ui | 6511de4 | Commit Preview URL Branch Preview URL |
Jul 02 2026, 06:23 AM |
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-02 06:25:36 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 2 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2461 +/- ##
=======================================
Coverage 95.83% 95.83%
=======================================
Files 224 224
Lines 24996 24996
Branches 9091 9091
=======================================
Hits 23954 23954
Misses 428 428
Partials 614 614 🚀 New features to boost your workflow:
|
The postgres migrator now reads DATABASE_URL from the environment instead of taking --postgres-url on argv (avoiding a credential leak through process listings), and the docs were updated to match. But the snippet set DATABASE_URL as a plain (non-exported) shell assignment, so a user pasting the block verbatim would run the two following npm run selfhost:postgres:migrate commands without the variable in their environment, failing with "--postgres-url or DATABASE_URL must be a postgres:// URL".
…nd manual-review classification (#2740) * fix(selfhost): fix Grafana reporting exporter's Postgres connection and manual-review classification PGDATABASE="$PG_DB" psql treats PGDATABASE as a literal database name, not a connection URL -- libpq does not URI-expand it the way it does a positional dbname argument, so every Postgres-backed reporting export was silently falling back to a local Unix-socket connection attempt and failing. Fix: split the postgres:// URL into PGHOST/PGPORT/PGUSER/ PGPASSWORD/PGDATABASE/PGSSLMODE and export them, so psql connects over the intended TCP host while the credential never appears on argv (preserving the process-listing leak protection from #2461). Also broadens the manual-review classification: a 'neutral' gate conclusion is now counted as 'manual' (matching gateHeld's held-for- review definition), not silently bucketed as 'commented'/'comment'. * fix(selfhost): handle bracketed IPv6 hosts in the Postgres URL splitter postgres://u:p@[::1]:5432/db split host:port on the first colon, which cuts a bracketed IPv6 literal apart (PGHOST='[', PGPORT=':1]:5432') since the address itself contains colons. Handle the bracketed forms (with and without a trailing port) before falling back to plain first-colon splitting for an ordinary hostname/IPv4 host.
Motivation
psqland process argv, since command-line arguments can be read by other local users on typical systems.Description
PGDATABASEinstead of passing the full URL as apsqlpositional argument inscripts/export-grafana-reporting-db.sh.DATABASE_URL=…and removing the expanded--postgres-url "$DATABASE_URL"command-line example inapps/gittensory-ui/src/routes/docs.self-hosting-backup-scaling.tsx.scripts/migrate-selfhost-sqlite-to-postgres.tsto recommendDATABASE_URLand warn against using--postgres-urlon shared hosts.psqlhelper intest/unit/selfhost-grafana-reporting.test.tsthat fails if a Postgres URL appears inpsqlargv or if the URL is not supplied viaPGDATABASE.Testing
npx vitest run test/unit/selfhost-grafana-reporting.test.ts, which passed (all tests green).npm run ui:lint, which completed successfully with existing warnings only (no errors).npm run typecheck, which completed successfully.git diff --checkand local formatting commands, which reported no blocking issues;npm run test:ciandnpm audit --audit-level=moderatecould not complete due to external network/setup constraints and therefore were not fully exercised.Codex Task