mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-04-07 17:51:33 +00:00
Sanitize url for printing when given password passed as parameter
Signed-off-by: AlexDHoffer <alexdchoffer@gmail.com>
This commit is contained in:
parent
c84fc4a13a
commit
04e73d413c
@ -217,5 +217,14 @@ func loggableDSN(dsn string) string {
|
||||
pDSN.User = url.UserPassword(pDSN.User.Username(), "PASSWORD_REMOVED")
|
||||
}
|
||||
|
||||
// Blank password data from parameters if not nil
|
||||
q := pDSN.Query()
|
||||
if q != nil {
|
||||
if q.Get("password") != "" {
|
||||
q.Set("password", "PASSWORD_REMOVED")
|
||||
pDSN.RawQuery = q.Encode()
|
||||
}
|
||||
}
|
||||
|
||||
return pDSN.String()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user