1
0
mirror of https://github.com/aquasecurity/kube-bench.git synced 2024-12-18 12:48:08 +00:00

Add regex op to test

This commit is contained in:
wwwil 2019-06-04 11:38:17 +01:00
parent e64f61fa7f
commit e4f0f470ee

View File

@ -185,6 +185,11 @@ func (t *testItem) execute(s string) *testOutput {
case "nothave":
expectedResultPattern = " '%s' not have '%s'"
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)