mirror of
https://github.com/aquasecurity/kube-bench.git
synced 2024-12-18 20:58:10 +00:00
Add regex op to test
This commit is contained in:
parent
e64f61fa7f
commit
e4f0f470ee
@ -185,6 +185,11 @@ func (t *testItem) execute(s string) *testOutput {
|
|||||||
case "nothave":
|
case "nothave":
|
||||||
expectedResultPattern = " '%s' not have '%s'"
|
expectedResultPattern = " '%s' not have '%s'"
|
||||||
result.testResult = !strings.Contains(flagVal, t.Compare.Value)
|
result.testResult = !strings.Contains(flagVal, t.Compare.Value)
|
||||||
|
|
||||||
|
case "regex":
|
||||||
|
expectedResultPattern = " '%s' matched by '%s'"
|
||||||
|
opRe := regexp.MustCompile(t.Compare.Value)
|
||||||
|
result.testResult = opRe.MatchString(flagVal)
|
||||||
}
|
}
|
||||||
|
|
||||||
result.ExpectedResult = fmt.Sprintf(expectedResultPattern, t.Flag, t.Compare.Value)
|
result.ExpectedResult = fmt.Sprintf(expectedResultPattern, t.Flag, t.Compare.Value)
|
||||||
|
Loading…
Reference in New Issue
Block a user