Skip to content
Permalink
Browse files

Obfuscate DSN password when logging connection details, fixes #174 (#176

)
  • Loading branch information...
chiefy authored and dannyvankooten committed Oct 30, 2018
1 parent 02c2eb9 commit acd182689bc75d4af1e93f0e571886ed8982acc2
Showing with 4 additions and 2 deletions.
  1. +4 −2 pkg/datastore/sqlstore/sqlstore.go
@@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"errors"
"regexp"
"time"

_ "github.com/go-sql-driver/mysql" // mysql driver
@@ -39,8 +40,9 @@ func New(c *Config) *sqlstore {
}
db := &sqlstore{dbx, c.Driver, c}

// write log statement
log.Printf("Connected to %s database: %s", c.Driver, c.DSN())
// write log statement, sanitize password
re := regexp.MustCompile(`password=[^ ]+`)
log.Printf("Connected to %s database: %s", c.Driver, re.ReplaceAllString(c.DSN(), `xxxxx`))

// run migrations
db.Migrate()

0 comments on commit acd1826

Please sign in to comment.
You can’t perform that action at this time.