Skip to content

Commit

Permalink
dashboard/app: stricter check on namespace names
Browse files Browse the repository at this point in the history
Check that namespaces don't contain bad chars.
  • Loading branch information
dvyukov committed Apr 10, 2019
1 parent e39dbde commit 31e097a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions dashboard/app/config.go
Expand Up @@ -135,8 +135,9 @@ type KernelRepo struct {
}

var (
clientNameRe = regexp.MustCompile("^[a-zA-Z0-9-_]{4,100}$")
clientKeyRe = regexp.MustCompile("^[a-zA-Z0-9]{16,128}$")
namespaceNameRe = regexp.MustCompile("^[a-zA-Z0-9-_.]{4,32}$")
clientNameRe = regexp.MustCompile("^[a-zA-Z0-9-_.]{4,100}$")
clientKeyRe = regexp.MustCompile("^[a-zA-Z0-9]{16,128}$")
)

type (
Expand Down Expand Up @@ -202,8 +203,8 @@ func checkConfig(cfg *GlobalConfig) {
}

func checkNamespace(ns string, cfg *Config, namespaces, clientNames map[string]bool) {
if ns == "" {
panic("empty namespace name")
if !namespaceNameRe.MatchString(ns) {
panic(fmt.Sprintf("bad namespace name: %q", ns))
}
if namespaces[ns] {
panic(fmt.Sprintf("duplicate namespace %q", ns))
Expand Down

0 comments on commit 31e097a

Please sign in to comment.