diff --git a/pkg/customAnalyzer/customAnalyzer.go b/pkg/customAnalyzer/customAnalyzer.go index 29e1b49dd0..803386a76f 100644 --- a/pkg/customAnalyzer/customAnalyzer.go +++ b/pkg/customAnalyzer/customAnalyzer.go @@ -3,6 +3,7 @@ package customanalyzer import ( "fmt" "reflect" + "regexp" ) type CustomAnalyzerConfiguration struct { @@ -22,6 +23,12 @@ func NewCustomAnalyzer() *CustomAnalyzer { } func (*CustomAnalyzer) Check(actualConfig []CustomAnalyzerConfiguration, name, url string, port int) error { + validNameRegex := `^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$` + validName := regexp.MustCompile(validNameRegex) + if !validName.MatchString(name) { + return fmt.Errorf("invalid name format. Must match %s", validNameRegex) + } + for _, analyzer := range actualConfig { if analyzer.Name == name { return fmt.Errorf("custom analyzer with the name '%s' already exists. Please use a different name", name)