mirror of
https://github.com/kyverno/kyverno.git
synced 2025-04-13 15:57:31 +00:00
37 lines
1.2 KiB
YAML
37 lines
1.2 KiB
YAML
{{- $name := "disallow-privileged-containers" }}
|
|
{{- if eq (include "kyverno-policies.podSecurityBaseline" (merge (dict "name" $name) .)) "true" }}
|
|
apiVersion: kyverno.io/v1
|
|
kind: ClusterPolicy
|
|
metadata:
|
|
name: {{ $name }}
|
|
annotations:
|
|
policies.kyverno.io/category: Pod Security Standards (Default)
|
|
{{- if .Values.podSecuritySeverity }}
|
|
policies.kyverno.io/severity: {{ .Values.podSecuritySeverity | quote }}
|
|
{{- end }}
|
|
policies.kyverno.io/description: >-
|
|
Privileged mode disables most security mechanisms and must not be allowed.
|
|
labels: {{ include "kyverno-policies.labels" . | nindent 4 }}
|
|
app: kyverno
|
|
spec:
|
|
validationFailureAction: {{ .Values.validationFailureAction }}
|
|
background: true
|
|
rules:
|
|
- name: priviledged-containers
|
|
match:
|
|
resources:
|
|
kinds:
|
|
- Pod
|
|
validate:
|
|
message: >-
|
|
Privileged mode is disallowed. The fields spec.containers[*].securityContext.privileged
|
|
and spec.initContainers[*].securityContext.privileged must not be set to true.
|
|
pattern:
|
|
spec:
|
|
=(initContainers):
|
|
- =(securityContext):
|
|
=(privileged): "false"
|
|
containers:
|
|
- =(securityContext):
|
|
=(privileged): "false"
|
|
{{- end -}}
|