Skip to content

Commit 04e73d4

Browse files
committed
Sanitize url for printing when given password passed as parameter
Signed-off-by: AlexDHoffer <[email protected]>
1 parent c84fc4a commit 04e73d4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cmd/postgres_exporter/util.go

+9
Original file line numberDiff line numberDiff line change
@@ -217,5 +217,14 @@ func loggableDSN(dsn string) string {
217217
pDSN.User = url.UserPassword(pDSN.User.Username(), "PASSWORD_REMOVED")
218218
}
219219

220+
// Blank password data from parameters if not nil
221+
q := pDSN.Query()
222+
if q != nil {
223+
if q.Get("password") != "" {
224+
q.Set("password", "PASSWORD_REMOVED")
225+
pDSN.RawQuery = q.Encode()
226+
}
227+
}
228+
220229
return pDSN.String()
221230
}

0 commit comments

Comments
 (0)