mirror of
https://github.com/kyverno/kyverno.git
synced 2025-04-13 15:57:31 +00:00
39 lines
1.4 KiB
YAML
39 lines
1.4 KiB
YAML
{{- $name := "deny-privilege-escalation" }}
|
|
{{- if eq (include "kyverno-policies.podSecurityRestricted" (merge (dict "name" $name) .)) "true" }}
|
|
apiVersion: kyverno.io/v1
|
|
kind: ClusterPolicy
|
|
metadata:
|
|
name: {{ $name }}
|
|
annotations:
|
|
policies.kyverno.io/category: Pod Security Standards (Restricted)
|
|
{{- if .Values.podSecuritySeverity }}
|
|
policies.kyverno.io/severity: {{ .Values.podSecuritySeverity | quote }}
|
|
{{- end }}
|
|
policies.kyverno.io/description: >-
|
|
Privilege escalation, such as via set-user-ID or set-group-ID file mode, should not be allowed.
|
|
labels: {{ include "kyverno-policies.labels" . | nindent 4 }}
|
|
app: kyverno
|
|
spec:
|
|
background: true
|
|
validationFailureAction: {{ .Values.validationFailureAction }}
|
|
rules:
|
|
- name: deny-privilege-escalation
|
|
match:
|
|
resources:
|
|
kinds:
|
|
- Pod
|
|
validate:
|
|
message: >-
|
|
Privilege escalation is disallowed. The fields
|
|
spec.containers[*].securityContext.allowPrivilegeEscalation, and
|
|
spec.initContainers[*].securityContext.allowPrivilegeEscalation must
|
|
be undefined or set to `false`.
|
|
pattern:
|
|
spec:
|
|
=(initContainers):
|
|
- =(securityContext):
|
|
=(allowPrivilegeEscalation): "false"
|
|
containers:
|
|
- =(securityContext):
|
|
=(allowPrivilegeEscalation): "false"
|
|
{{- end -}}
|