Skip to content

Commit

Permalink
fix: fail for irrelevant resources
Browse files Browse the repository at this point in the history
reported in aquasecurity/trivy#4922
since the failRootGroupId rule is given a default value, it doesn't fail
the deny rule and results in a false detection. added an explicit check for
the failRootGropuId truthiness to resolve.
  • Loading branch information
itaysk committed Jan 10, 2024
1 parent 8b3cedc commit 14535b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ failRootGroupId {
}

deny[res] {
failRootGroupId
output := failRootGroupId
msg := kubernetes.format(sprintf("%s %s in %s namespace should set spec.securityContext.runAsGroup, spec.securityContext.supplementalGroups[*] and spec.securityContext.fsGroup to integer greater than 0", [lower(kubernetes.kind), kubernetes.name, kubernetes.namespace]))
res := result.new(msg, output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,13 @@ test_failRootGroupId_failed {

count(r) > 0
}

test_failRootGroupId_irrelevant {
r := deny with input as {
"apiVersion": "v1",
"kind": "ClusterRole",
"metadata": {"name": "hello"}
}

count(r) > 0
}

0 comments on commit 14535b3

Please sign in to comment.