Sanitize url for printing when given password passed as parameter

Signed-off-by: AlexDHoffer <alexdchoffer@gmail.com>
This commit is contained in:
AlexDHoffer 2022-08-18 16:27:19 -07:00
parent c84fc4a13a
commit 04e73d413c

View File

@ -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()
}