Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Commit 7b6d240

Browse files
ashutoshgngwrRobAtticus
authored andcommitted
Mask password in log messages
It is generally good security practice to not write actual passwords into logs. This now replaces it a set of four stars.
1 parent 7590788 commit 7b6d240

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/postgresql/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"os"
99
"reflect"
10+
"regexp"
1011
"sort"
1112
"strings"
1213
"time"
@@ -89,7 +90,7 @@ func NewClient(cfg *Config) *Client {
8990
return sql.Open("postgres", connStr)
9091
})
9192

92-
log.Info("msg", connStr)
93+
log.Info("msg", regexp.MustCompile("password='(.+?)'").ReplaceAllLiteralString(connStr, "password='****'"))
9394

9495
if err != nil {
9596
log.Error("err", err)

0 commit comments

Comments
 (0)