mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
* Allow some helm policies to be excluded Signed-off-by: Trey Dockendorf <tdockendorf@osc.edu> * Make Helm security policies opt-in when podSecurityStandard=custom Signed-off-by: Trey Dockendorf <tdockendorf@osc.edu>
36 lines
No EOL
1.2 KiB
YAML
36 lines
No EOL
1.2 KiB
YAML
{{- $name := "disallow-selinux" }}
|
|
{{- if eq (include "kyverno.podSecurityDefault" (merge (dict "name" $name) .)) "true" }}
|
|
apiVersion: kyverno.io/v1
|
|
kind: ClusterPolicy
|
|
metadata:
|
|
name: {{ $name }}
|
|
annotations:
|
|
policies.kyverno.io/title: Disallow SELinux
|
|
policies.kyverno.io/category: Pod Security Standards (Default)
|
|
policies.kyverno.io/description: >-
|
|
SELinux options can be used to escalate privileges and should not be allowed.
|
|
spec:
|
|
validationFailureAction: {{ .Values.validationFailureAction }}
|
|
background: true
|
|
rules:
|
|
- name: seLinux
|
|
match:
|
|
resources:
|
|
kinds:
|
|
- Pod
|
|
validate:
|
|
message: >-
|
|
Setting custom SELinux options is disallowed. The fields
|
|
spec.securityContext.seLinuxOptions, spec.containers[*].securityContext.seLinuxOptions,
|
|
and spec.initContainers[*].securityContext.seLinuxOptions must be empty.
|
|
pattern:
|
|
spec:
|
|
=(securityContext):
|
|
X(seLinuxOptions): "null"
|
|
=(initContainers):
|
|
- =(securityContext):
|
|
X(seLinuxOptions): "null"
|
|
containers:
|
|
- =(securityContext):
|
|
X(seLinuxOptions): "null"
|
|
{{- end -}} |