mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 17:02:27 +08:00
Merge branch 'database_url' of https://github.com/Scalingo/grafana into Scalingo-database_url
This commit is contained in:
@ -183,6 +183,11 @@ func shouldRedactKey(s string) bool {
|
||||
return strings.Contains(uppercased, "PASSWORD") || strings.Contains(uppercased, "SECRET")
|
||||
}
|
||||
|
||||
func shouldRedactURLKey(s string) bool {
|
||||
uppercased := strings.ToUpper(s)
|
||||
return strings.Contains(uppercased, "DATABASE_URL")
|
||||
}
|
||||
|
||||
func applyEnvVariableOverrides() {
|
||||
appliedEnvOverrides = make([]string, 0)
|
||||
for _, section := range Cfg.Sections() {
|
||||
@ -197,6 +202,17 @@ func applyEnvVariableOverrides() {
|
||||
if shouldRedactKey(envKey) {
|
||||
envValue = "*********"
|
||||
}
|
||||
if shouldRedactURLKey(envKey) {
|
||||
u, _ := url.Parse(envValue)
|
||||
ui := u.User
|
||||
if ui != nil {
|
||||
_, exists := ui.Password()
|
||||
if exists {
|
||||
u.User = url.UserPassword(ui.Username(), "-redacted-")
|
||||
envValue = u.String()
|
||||
}
|
||||
}
|
||||
}
|
||||
appliedEnvOverrides = append(appliedEnvOverrides, fmt.Sprintf("%s=%s", envKey, envValue))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user