Rule request: detect database connection strings with inline credentials (postgres/mysql/mongodb)
Related: #1715 (that issue is SQL-Server-specific; this covers postgres://, mysql://, and mongodb://)
Problem
I searched the published default config: 222 rules, none match postgres://user:pass@host or the mysql:// / mongodb:// equivalents.
- The only
user:pass@rule issidekiq-sensitive-url, hardcoded tocontribsys.com. mongodbandmysqlappear only as stopwords insidegeneric-api-key— so users who disable that rule (which Gitleaks' own docs suggest for noisy repos) have zero coverage.
Every Supabase, Heroku, Railway, and Render app ships a DATABASE_URL in this shape. It is one of the most common credential formats in the wild.
The localhost objection
postgres://user:pass@localhost is everywhere in test fixtures and docker-compose files. Rather than dropping the rule, this can be handled with stopwords / an allowlist for local hosts (localhost, 127.0.0.1, ::1).
Proposed solution
A new rule covering postgres://, mysql://, mongodb+srv:// etc. with Keywords set to ["postgres", "mysql", "mongodb"] (these appear in plain text, so keyword filtering works normally here).
I'm preparing a PR with the Go rule file and built-in true/false positive validation.
Source: gitleaks/gitleaks