diff --git a/main.go b/main.go index 12756ceed..a8b7792df 100644 --- a/main.go +++ b/main.go @@ -47,7 +47,8 @@ const ( ) var ( - version = "" // Must not be const, set using ldflags at build time + version = "" // Must not be const, set using ldflags at build time + validFeatureNameRe = regexp.MustCompile(`^([-.\w]*)?[A-Za-z0-9]$`) ) // package loggers @@ -355,6 +356,12 @@ func getFeatureLabels(source source.FeatureSource) (labels Labels, err error) { return nil, err } for k := range features { + // Validate label + if !validFeatureNameRe.MatchString(k) { + stderrLogger.Printf("Invalid feature name '%s', ignoring...", k) + continue + } + prefix := source.Name() + "-" switch source.(type) { case local.Source: