Skip to content
forked from kiali/kiali

Commit b4acbb8

Browse files
authored
KIALI-2669 Add more validation for custom web root (kiali#991)
- trailing / not allowed (should not happen using the operator, so this is really just a sanity check)
1 parent b522a8a commit b4acbb8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

kiali.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,12 @@ func validateConfig() error {
187187
}
188188

189189
validPathRegEx := regexp.MustCompile(`^\/[a-zA-Z\d_/\$]*$`)
190-
if path := config.Get().Server.WebRoot; !validPathRegEx.MatchString(path) {
191-
return fmt.Errorf("web root must begin with a / and contain only alphanumerics: %v", path)
190+
webRoot := config.Get().Server.WebRoot
191+
if !validPathRegEx.MatchString(webRoot) {
192+
return fmt.Errorf("web root must begin with a / and contain only alphanumerics: %v", webRoot)
193+
}
194+
if webRoot != "/" && strings.HasSuffix(webRoot, "/") {
195+
return fmt.Errorf("web root must not contain a trailing /: %v", webRoot)
192196
}
193197

194198
// log some messages to let the administrator know when credentials are configured certain ways

0 commit comments

Comments
 (0)