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:
parent
a84b5c9d82
commit
9474ef0815
1 changed files with 8 additions and 1 deletions
9
main.go
9
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:
|
||||
|
|
Loading…
Add table
Reference in a new issue