1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00
kyverno/charts/kyverno/templates/policies/default/disallow-host-path.yaml
Frank Jogeleit 56183cc73d
Add severity to pod security policies (#1797)
Signed-off-by: Frank Jogeleit <fj@move-elevator.de>
2021-04-16 17:41:30 -07:00

32 lines
No EOL
1 KiB
YAML

{{ $name := "disallow-host-path" -}}
{{- if eq (include "kyverno.podSecurityDefault" (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: >-
HostPath volumes let pods use host directories and volumes in containers.
Using host resources can be used to access shared data or escalate privileges
and should not be allowed.
spec:
validationFailureAction: {{ .Values.validationFailureAction }}
background: true
rules:
- name: host-path
match:
resources:
kinds:
- Pod
validate:
message: >-
HostPath volumes are forbidden. The fields spec.volumes[*].hostPath must not be set.
pattern:
spec:
=(volumes):
- X(hostPath): "null"
{{- end -}}