MM-51768: Scrub username/password from SQL datasource (#22731)

https://mattermost.atlassian.net/browse/MM-51768
```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2023-04-03 23:41:51 +05:30
коммит произвёл GitHub
родитель 1762dfce22
Коммит dacac2e3ed
7 изменённых файлов: 80 добавлений и 81 удалений

Просмотреть файл

@@ -179,27 +179,6 @@ func IsDatabaseDSN(dsn string) bool {
strings.HasPrefix(dsn, "postgresql://")
}
// stripPassword remove the password from a given DSN
func stripPassword(dsn, schema string) string {
prefix := schema + "://"
dsn = strings.TrimPrefix(dsn, prefix)
i := strings.Index(dsn, ":")
j := strings.LastIndex(dsn, "@")
// Return error if no @ sign is found
if j < 0 {
return "(omitted due to error parsing the DSN)"
}
// Return back the input if no password is found
if i < 0 || i > j {
return prefix + dsn
}
return prefix + dsn[:i+1] + dsn[j:]
}
func isJSONMap(data string) bool {
var m map[string]any
return json.Unmarshal([]byte(data), &m) == nil