mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
add regex search of username and password in urls, which are replaced by strings.Replace
This commit is contained in:
parent
eef01e3703
commit
5669596518
@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
@ -21,6 +22,14 @@ func AdminGetSettings(c *m.ReqContext) {
|
||||
if strings.Contains(keyName, "secret") || strings.Contains(keyName, "password") || (strings.Contains(keyName, "provider_config")) {
|
||||
value = "************"
|
||||
}
|
||||
if strings.Contains(keyName, "url") {
|
||||
var rgx = regexp.MustCompile(`.*:\/\/([^:]*):([^@]*)@.*?$`)
|
||||
var subs = rgx.FindAllSubmatch([]byte(value), -1)
|
||||
if subs != nil && len(subs[0]) == 3 {
|
||||
value = strings.Replace(value, string(subs[0][1]), "******", 1)
|
||||
value = strings.Replace(value, string(subs[0][2]), "******", 1)
|
||||
}
|
||||
}
|
||||
|
||||
jsonSec[keyName] = value
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user