1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-07 00:17:13 +00:00
kyverno/samples/best_practices/disallow_new_capabilities.yaml

32 lines
971 B
YAML
Raw Normal View History

2019-11-13 13:56:20 -08:00
apiVersion: kyverno.io/v1
2019-10-31 18:40:54 -07:00
kind: ClusterPolicy
metadata:
2019-11-09 16:07:16 -08:00
name: disallow-new-capabilities
2019-10-31 18:40:54 -07:00
annotations:
2019-11-09 16:07:16 -08:00
policies.kyverno.io/category: Security
2019-10-31 18:40:54 -07:00
policies.kyverno.io/description: Linux allows defining fine-grained permissions using
capabilities. With Kubernetes, it is possible to add capabilities that escalate the
level of kernel access and allow other potentially dangerous behaviors. This policy
enforces that pods cannot add new capabilities. Other policies can be used to set
default capabilities.
spec:
rules:
2019-11-09 16:07:16 -08:00
- name: validate-add-capabilities
2019-10-31 18:40:54 -07:00
match:
resources:
kinds:
- Pod
validate:
2019-11-09 16:07:16 -08:00
message: "New capabilities cannot be added"
2019-10-31 18:40:54 -07:00
anyPattern:
- spec:
2019-11-01 14:37:17 -07:00
=(securityContext):
=(capabilities):
X(add): null
2019-10-31 18:40:54 -07:00
- spec:
containers:
- name: "*"
2019-11-01 14:37:17 -07:00
=(securityContext):
=(capabilities):
2019-11-09 16:07:16 -08:00
X(add): null