mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
added validation on client metadata keys
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -186,6 +187,8 @@ func (c *Command) readConfig() *Config {
|
||||
// Parse the meta flags.
|
||||
metaLength := len(meta)
|
||||
if metaLength != 0 {
|
||||
validKeyRe, _ := regexp.Compile(`^[^.]+(\.[^.]+)*$`)
|
||||
|
||||
cmdConfig.Client.Meta = make(map[string]string, metaLength)
|
||||
for _, kv := range meta {
|
||||
parts := strings.SplitN(kv, "=", 2)
|
||||
@@ -194,6 +197,11 @@ func (c *Command) readConfig() *Config {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !validKeyRe.MatchString(parts[0]) {
|
||||
c.Ui.Error(fmt.Sprintf("Invalid Client.Meta key: %v", parts[0]))
|
||||
return nil
|
||||
}
|
||||
|
||||
cmdConfig.Client.Meta[parts[0]] = parts[1]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user