Mask DB password in logs (#1072)

This commit is contained in:
Owen Cliffe
2018-06-19 18:59:28 +01:00
committed by GitHub
parent 4bf23d8c1b
commit 229353051f
2 changed files with 15 additions and 3 deletions

View File

@@ -143,7 +143,7 @@ func (sqlLogsProvider) New(ctx context.Context, u *url.URL) (models.LogStore, er
func newDS(ctx context.Context, url *url.URL) (*SQLStore, error) {
driver := url.Scheme
log := common.Logger(ctx)
log := common.Logger(ctx).WithFields(logrus.Fields{"url": common.MaskPassword(url)})
helper, ok := dbhelper.GetHelper(driver)
if !ok {
@@ -160,7 +160,7 @@ func newDS(ctx context.Context, url *url.URL) (*SQLStore, error) {
sqldb, err := sql.Open(driver, uri)
if err != nil {
log.WithFields(logrus.Fields{"url": uri}).WithError(err).Error("couldn't open db")
log.WithError(err).Error("couldn't open db")
return nil, err
}
@@ -169,7 +169,7 @@ func newDS(ctx context.Context, url *url.URL) (*SQLStore, error) {
// force a connection and test that it worked
err = pingWithRetry(ctx, db)
if err != nil {
log.WithFields(logrus.Fields{"url": uri}).WithError(err).Error("couldn't ping db")
log.WithError(err).Error("couldn't ping db")
return nil, err
}