Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 5 additions & 22 deletions checkov/kubernetes/checks/graph_checks/ReadAllSecrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,11 @@ definition:
- Role
- or:
- cond_type: attribute
attribute: rules.resources
operator: not_intersects
value:
- 'secrets'
- '*'
resource_types:
- ClusterRole
- Role
- cond_type: attribute
attribute: rules.verbs
operator: not_intersects
value:
- 'get'
- 'watch'
- 'list'
- '*'
resource_types:
- ClusterRole
- Role
- cond_type: attribute
attribute: rules.resourceNames
operator: exists
attribute: >-
$.rules[?((@.resources[*] == 'secrets' | @.resources[*] == '*') &
(@.verbs[*] == 'get' | @.verbs[*] == 'watch' | @.verbs[*] == 'list' |
@.verbs[*] == '*') & !@.resourceNames)]
operator: jsonpath_not_exists
resource_types:
- ClusterRole
- Role
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: mixed-secret-reader
rules:
- apiGroups:
- ""
resources:
- "secrets"
verbs:
- "get"
- "watch"
- "list"
- apiGroups:
- ""
resources:
- "secrets"
resourceNames:
- "pull-secret"
verbs:
- "get"
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: mixed-secrets-global
subjects:
- kind: ServiceAccount
name: sa1
roleRef:
kind: ClusterRole
name: mixed-secret-reader
apiGroup: rbac.authorization.k8s.io
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ pass:
- "ClusterRoleBinding.default.read-pods-global"
- "RoleBinding.my-namespace.my-role-binding"
fail:
- "ClusterRoleBinding.default.read-secrets-global"
- "ClusterRoleBinding.default.read-secrets-global"
- "ClusterRoleBinding.default.mixed-secrets-global"