mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-04-15 07:16:34 +00:00
Merge pull request #375 from replicatedhq/divolgin/redact
Add a default redactor for postgres db connection string
This commit is contained in:
@@ -223,6 +223,11 @@ func getRedactors(path string) ([]Redactor, error) {
|
||||
name: "Redact database connection strings that contain username and password",
|
||||
},
|
||||
// standard postgres and mysql connection strings
|
||||
// protocol://user:password@host:5432/db
|
||||
{
|
||||
regex: `\b(\w*:\/\/)(?P<mask>[^:\"\/]*){1}(:)(?P<mask>[^:\"\/]*){1}(@)(?P<mask>[^:\"\/]*){1}(?P<port>:[\d]*)?(\/)(?P<mask>[\w\d\S-_]+){1}\b`,
|
||||
name: "Redact database connection strings that contain username and password",
|
||||
},
|
||||
{
|
||||
regex: `(?i)(Data Source *= *)(?P<mask>[^\;]+)(;)`,
|
||||
name: "Redact 'Data Source' values commonly found in database connection strings",
|
||||
|
||||
@@ -64,6 +64,10 @@ func Test_Redactors(t *testing.T) {
|
||||
"name": "POSTGRES_CONNECTION_STRING",
|
||||
"value": "Provider=PostgreSQL OLE DB Provider;Data Source=myServerAddress;location=myDataBase;User ID=myUsername;password=myPassword;timeout=1000;"
|
||||
},
|
||||
{
|
||||
"name": "POSTGRES_CONNECTION_STRING_2",
|
||||
"value": "postgres://pg_user:pg_password@pg_host:5432/pg_database"
|
||||
},
|
||||
{
|
||||
"name": "MYSQL_CONNECTION_STRING",
|
||||
"value": "Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;UseProcedureBodies=False;"
|
||||
@@ -868,6 +872,10 @@ func Test_Redactors(t *testing.T) {
|
||||
"name": "POSTGRES_CONNECTION_STRING",
|
||||
"value": "Provider=PostgreSQL OLE DB Provider;Data Source=***HIDDEN***;location=***HIDDEN***;User ID=***HIDDEN***;password=***HIDDEN***;timeout=1000;"
|
||||
},
|
||||
{
|
||||
"name": "POSTGRES_CONNECTION_STRING_2",
|
||||
"value": "postgres://***HIDDEN***:***HIDDEN***@***HIDDEN***:5432/***HIDDEN***"
|
||||
},
|
||||
{
|
||||
"name": "MYSQL_CONNECTION_STRING",
|
||||
"value": "Server=***HIDDEN***;Database=***HIDDEN***;Uid=***HIDDEN***;Pwd=***HIDDEN***;UseProcedureBodies=False;"
|
||||
@@ -1619,7 +1627,7 @@ func Test_Redactors(t *testing.T) {
|
||||
}
|
||||
]`
|
||||
|
||||
wantRedactionsLen := 38
|
||||
wantRedactionsLen := 39
|
||||
wantRedactionsCount := 25
|
||||
|
||||
t.Run("test default redactors", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user