Files
greptimedb/src/common
Lei, HUANG 57767f4a67 fix: prevent credential leaks in sanitize_connection_string (#8539)
Reopens #8486, which was accidentally closed (and whose branch history
I've since repaired, so it couldn't be reopened in place).

## What's changed and why

`sanitize_connection_string` redacts `store_addrs` before they're
logged, but the previous hand-rolled parsing missed several forms and
could leak passwords.

Per the review on #8486 (@killme2008 suggested the `url` crate; @v0y4g3r
listed additional libpq formats):

- **URL-form addresses** (`mysql://`, `postgresql://`, `http://` etcd)
are now parsed with the **`url` crate**; the userinfo password and any
`password` query parameter are redacted.
- **libpq keyword DSNs** (`host=… password=…`) are handled by a small
redactor covering `password = x` (spaces around `=`),
single/double-quoted values with spaces, and `\`-escaped quotes.

I kept a dedicated redactor for the keyword-DSN form rather than
`tokio-postgres`, since `tokio-postgres` is an optional/feature-gated
dependency in `common-meta` (this function runs unconditionally) and
`store_addrs` also covers mysql/etcd, which it can't parse.

## Checklist

- [x] I have written the necessary rustdoc comments.
- [x] I have added the necessary unit tests.

By submitting this pull request, I confirm that my contribution is made
under the terms of the GreptimeDB CLA.
2026-07-23 07:05:34 +00:00
..
2026-06-30 07:37:31 +00:00