mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2025-12-11 23:50:04 +01:00
parent
2b61b4375a
commit
11c251bd25
2 changed files with 30 additions and 1 deletions
11
main.go
11
main.go
|
|
@ -5,6 +5,7 @@ import (
|
|||
"log"
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/urfave/cli"
|
||||
|
|
@ -19,7 +20,8 @@ func main() {
|
|||
err := app.Run(os.Args)
|
||||
|
||||
if err != nil {
|
||||
_, _ = fmt.Fprintf(os.Stderr, "Error: %s\n", err)
|
||||
errText := redactLogString(fmt.Sprintf("Error: %s\n", err))
|
||||
_, _ = fmt.Fprint(os.Stderr, errText)
|
||||
os.Exit(2)
|
||||
}
|
||||
}
|
||||
|
|
@ -219,3 +221,10 @@ func getDatabaseURL(c *cli.Context) (u *url.URL, err error) {
|
|||
|
||||
return url.Parse(value)
|
||||
}
|
||||
|
||||
// redactLogString attempts to redact passwords from errors
|
||||
func redactLogString(in string) string {
|
||||
re := regexp.MustCompile("([a-zA-Z]+://[^:]+:)[^@]+@")
|
||||
|
||||
return re.ReplaceAllString(in, "${1}********@")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue