mirror of
https://github.com/aquasecurity/kube-bench.git
synced 2025-01-31 10:01:06 +00:00
Merge pull request #258 from aquasecurity/fix-241
Add ":" as a valid flag-value separator for tests
This commit is contained in:
commit
d30786da4a
@ -166,6 +166,8 @@ func (c *Check) Run() {
|
|||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glog.V(3).Info(out.String())
|
||||||
|
|
||||||
finalOutput := c.Tests.execute(out.String())
|
finalOutput := c.Tests.execute(out.String())
|
||||||
if finalOutput != nil {
|
if finalOutput != nil {
|
||||||
c.ActualValue = finalOutput.actualResult
|
c.ActualValue = finalOutput.actualResult
|
||||||
|
@ -158,3 +158,12 @@ groups:
|
|||||||
set: true
|
set: true
|
||||||
|
|
||||||
|
|
||||||
|
- id: 14
|
||||||
|
text: "check that flag some-arg is set to some-val with ':' separator"
|
||||||
|
tests:
|
||||||
|
test_items:
|
||||||
|
- flag: "some-arg"
|
||||||
|
compare:
|
||||||
|
op: eq
|
||||||
|
value: some-val
|
||||||
|
set: true
|
||||||
|
@ -68,7 +68,7 @@ func (t *testItem) execute(s string) *testOutput {
|
|||||||
// --flag
|
// --flag
|
||||||
// somevalue
|
// somevalue
|
||||||
//pttn := `(` + t.Flag + `)(=)*([^\s,]*) *`
|
//pttn := `(` + t.Flag + `)(=)*([^\s,]*) *`
|
||||||
pttn := `(` + t.Flag + `)(=)*([^\s]*) *`
|
pttn := `(` + t.Flag + `)(=|: *)*([^\s]*) *`
|
||||||
flagRe := regexp.MustCompile(pttn)
|
flagRe := regexp.MustCompile(pttn)
|
||||||
vals := flagRe.FindStringSubmatch(s)
|
vals := flagRe.FindStringSubmatch(s)
|
||||||
|
|
||||||
|
@ -110,6 +110,16 @@ func TestTestExecute(t *testing.T) {
|
|||||||
controls.Groups[0].Checks[13],
|
controls.Groups[0].Checks[13],
|
||||||
"2:45 ../kubernetes/kube-apiserver --option --admission-control=Something ---audit-log-maxage=40",
|
"2:45 ../kubernetes/kube-apiserver --option --admission-control=Something ---audit-log-maxage=40",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// check for ':' as argument-value separator, with space between arg and val
|
||||||
|
controls.Groups[0].Checks[14],
|
||||||
|
"2:45 kube-apiserver some-arg: some-val --admission-control=Something ---audit-log-maxage=40",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// check for ':' as argument-value separator, with no space between arg and val
|
||||||
|
controls.Groups[0].Checks[14],
|
||||||
|
"2:45 kube-apiserver some-arg:some-val --admission-control=Something ---audit-log-maxage=40",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
|
Loading…
Reference in New Issue
Block a user