mirror of
https://github.com/kyverno/kyverno.git
synced 2025-01-20 18:52:16 +00:00
35 lines
No EOL
1 KiB
YAML
35 lines
No EOL
1 KiB
YAML
apiVersion: kyverno.io/v1
|
|
kind: ClusterPolicy
|
|
metadata:
|
|
name: disallow-root-user
|
|
annotations:
|
|
policies.kyverno.io/category: Security
|
|
policies.kyverno.io/description: By default, processes in a container run as a
|
|
root user (uid 0). To prevent potential compromise of container hosts, specify a
|
|
least privileged user ID when building the container image and require that
|
|
application containers run as non root users.
|
|
spec:
|
|
validationFailureAction: audit
|
|
rules:
|
|
- name: validate-runAsNonRoot
|
|
match:
|
|
resources:
|
|
kinds:
|
|
- Pod
|
|
validate:
|
|
message: "Running as root is not allowed. Set runAsNonRoot to true, or use runAsUser"
|
|
anyPattern:
|
|
- spec:
|
|
securityContext:
|
|
runAsNonRoot: true
|
|
- spec:
|
|
securityContext:
|
|
runAsUser: ">0"
|
|
- spec:
|
|
containers:
|
|
- securityContext:
|
|
runAsNonRoot: true
|
|
- spec:
|
|
containers:
|
|
- securityContext:
|
|
runAsUser: ">0" |