mirror of
https://github.com/coredns/coredns.git
synced 2026-05-25 19:30:23 -04:00
fix: reject unknown chaos block options (#8121)
This commit is contained in:
committed by
GitHub
parent
d9c6b9b8b4
commit
17142359e0
@@ -32,25 +32,30 @@ func parse(c *caddy.Controller) (string, []string, error) {
|
|||||||
|
|
||||||
if c.Next() {
|
if c.Next() {
|
||||||
args := c.RemainingArgs()
|
args := c.RemainingArgs()
|
||||||
|
authors := Owners
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
return trim(chaosVersion), Owners, nil
|
version = trim(chaosVersion)
|
||||||
}
|
} else if len(args) == 1 {
|
||||||
if len(args) == 1 {
|
version = trim(args[0])
|
||||||
return trim(args[0]), Owners, nil
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
version = args[0]
|
version = args[0]
|
||||||
authors := make(map[string]struct{})
|
authorSet := make(map[string]struct{})
|
||||||
for _, a := range args[1:] {
|
for _, a := range args[1:] {
|
||||||
authors[a] = struct{}{}
|
authorSet[a] = struct{}{}
|
||||||
}
|
}
|
||||||
list := []string{}
|
list := make([]string, 0, len(authorSet))
|
||||||
for k := range authors {
|
for k := range authorSet {
|
||||||
k = trim(k) // limit size to 255 chars
|
k = trim(k) // limit size to 255 chars
|
||||||
list = append(list, k)
|
list = append(list, k)
|
||||||
}
|
}
|
||||||
sort.Strings(list)
|
sort.Strings(list)
|
||||||
return version, list, nil
|
authors = list
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.NextBlock() {
|
||||||
|
return "", nil, c.Errf("unknown property '%s'", c.Val())
|
||||||
|
}
|
||||||
|
return version, authors, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return version, Owners, nil
|
return version, Owners, nil
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ func TestSetupChaos(t *testing.T) {
|
|||||||
{
|
{
|
||||||
`chaos v3 "Miek Gieben"`, false, "v3", "Miek Gieben", "",
|
`chaos v3 "Miek Gieben"`, false, "v3", "Miek Gieben", "",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
`chaos v2 {
|
||||||
|
unknown
|
||||||
|
}`, true, "", "", "unknown property",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
|
|||||||
Reference in New Issue
Block a user