1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2025-03-28 02:37:11 +00:00

Add validation for feature label names

This commit is contained in:
Markus Lehtonen 2018-09-28 12:38:41 +03:00
parent a84b5c9d82
commit 9474ef0815

View file

@ -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: