1
0
mirror of https://github.com/aquasecurity/kube-bench.git synced 2024-11-22 08:08:07 +00:00

bugfix: false negative when audit_config file not found (#1376)

In case of RKE, env error comes with exit status 1, so added OR codition to match with error text as well.

resolve: #1364
This commit is contained in:
Devendra Turkar 2023-02-14 14:02:02 +05:30 committed by GitHub
parent c17b4dd2ba
commit fc72a8a620
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -209,7 +209,9 @@ func (c *Check) runAuditCommands() (lastCommand string, err error) {
c.AuditConfigOutput, err = runAudit(c.AuditConfig) c.AuditConfigOutput, err = runAudit(c.AuditConfig)
// when file not found then error comes as exit status 127 // when file not found then error comes as exit status 127
if err != nil && strings.Contains(err.Error(), "exit status 127") && // in some env same error comes as exit status 1
if err != nil && (strings.Contains(err.Error(), "exit status 127") ||
strings.Contains(err.Error(), "No such file or directory")) &&
(c.AuditEnvOutput != "" || c.AuditOutput != "") { (c.AuditEnvOutput != "" || c.AuditOutput != "") {
// suppress file not found error when there is Audit OR auditEnv output present // suppress file not found error when there is Audit OR auditEnv output present
glog.V(3).Info(err) glog.V(3).Info(err)