mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-09 17:37:12 +00:00
49 lines
1.7 KiB
YAML
49 lines
1.7 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/title: Disallow Privileged Containers
|
||
|
policies.kyverno.io/category: Pod Security Standards (Baseline)
|
||
|
{{- if .Values.podSecuritySeverity }}
|
||
|
policies.kyverno.io/severity: {{ .Values.podSecuritySeverity }}
|
||
|
{{- end }}
|
||
|
policies.kyverno.io/subject: Pod
|
||
|
kyverno.io/kyverno-version: 1.6.0
|
||
|
kyverno.io/kubernetes-version: "1.22-1.23"
|
||
|
policies.kyverno.io/description: >-
|
||
|
Privileged mode disables most security mechanisms and must not be allowed. This policy
|
||
|
ensures Pods do not call for privileged mode.
|
||
|
spec:
|
||
|
validationFailureAction: {{ .Values.validationFailureAction }}
|
||
|
background: true
|
||
|
rules:
|
||
|
- name: privileged-containers
|
||
|
match:
|
||
|
any:
|
||
|
- resources:
|
||
|
kinds:
|
||
|
- Pod
|
||
|
{{- with index .Values "policyExclude" $name }}
|
||
|
exclude:
|
||
|
{{- toYaml . | nindent 8 }}
|
||
|
{{- end }}
|
||
|
validate:
|
||
|
message: >-
|
||
|
Privileged mode is disallowed. The fields spec.containers[*].securityContext.privileged
|
||
|
and spec.initContainers[*].securityContext.privileged must be unset or set to `false`.
|
||
|
pattern:
|
||
|
spec:
|
||
|
=(ephemeralContainers):
|
||
|
- =(securityContext):
|
||
|
=(privileged): "false"
|
||
|
=(initContainers):
|
||
|
- =(securityContext):
|
||
|
=(privileged): "false"
|
||
|
containers:
|
||
|
- =(securityContext):
|
||
|
=(privileged): "false"
|
||
|
{{- end }}
|