2022-02-04 01:47:36 -05:00
|
|
|
{{- $name := "disallow-host-namespaces" }}
|
|
|
|
{{- if eq (include "kyverno-policies.podSecurityBaseline" (merge (dict "name" $name) .)) "true" }}
|
|
|
|
apiVersion: kyverno.io/v1
|
2023-11-16 04:32:38 -05:00
|
|
|
kind: {{ .Values.policyKind }}
|
2022-02-04 01:47:36 -05:00
|
|
|
metadata:
|
|
|
|
name: {{ $name }}
|
|
|
|
annotations:
|
2022-12-01 11:05:56 +01:00
|
|
|
{{- with .Values.autogenControllers }}
|
|
|
|
pod-policies.kyverno.io/autogen-controllers: {{ . }}
|
|
|
|
{{- end }}
|
2022-02-04 01:47:36 -05:00
|
|
|
policies.kyverno.io/title: Disallow Host Namespaces
|
|
|
|
policies.kyverno.io/category: Pod Security Standards (Baseline)
|
|
|
|
{{- if .Values.podSecuritySeverity }}
|
|
|
|
policies.kyverno.io/severity: {{ .Values.podSecuritySeverity }}
|
|
|
|
{{- end }}
|
2024-11-20 11:15:03 +01:00
|
|
|
kyverno.io/kyverno-version: {{ default .Chart.AppVersion (include "kyverno-policies.kyvernoVersion" .) }}
|
|
|
|
kyverno.io/kubernetes-version: "{{ default .Chart.KubeVersion .Values.kubeVersionOverride }}"
|
2022-02-04 01:47:36 -05:00
|
|
|
policies.kyverno.io/subject: Pod
|
|
|
|
policies.kyverno.io/description: >-
|
|
|
|
Host namespaces (Process ID namespace, Inter-Process Communication namespace, and
|
|
|
|
network namespace) allow access to shared information and can be used to elevate
|
|
|
|
privileges. Pods should not be allowed access to host namespaces. This policy ensures
|
|
|
|
fields which make use of these host namespaces are unset or set to `false`.
|
2022-12-01 11:05:56 +01:00
|
|
|
labels: {{ include "kyverno-policies.labels" . | nindent 4 }}
|
2022-02-04 01:47:36 -05:00
|
|
|
spec:
|
2022-02-24 17:31:51 +01:00
|
|
|
background: {{ .Values.background }}
|
2022-08-09 17:12:27 -04:00
|
|
|
failurePolicy: {{ .Values.failurePolicy }}
|
2022-02-04 01:47:36 -05:00
|
|
|
rules:
|
|
|
|
- name: host-namespaces
|
|
|
|
match:
|
|
|
|
any:
|
|
|
|
- resources:
|
|
|
|
kinds:
|
|
|
|
- Pod
|
2024-11-25 08:48:18 -03:00
|
|
|
{{- with merge (index .Values "policyExclude" "host-namespaces") (index .Values "policyExclude" $name) }}
|
2022-02-04 01:47:36 -05:00
|
|
|
exclude:
|
|
|
|
{{- toYaml . | nindent 8 }}
|
|
|
|
{{- end }}
|
2022-04-18 13:59:47 -04:00
|
|
|
{{- with index .Values "policyPreconditions" $name }}
|
|
|
|
preconditions:
|
|
|
|
{{- toYaml . | nindent 8 }}
|
|
|
|
{{- end }}
|
2024-01-27 18:42:22 +01:00
|
|
|
{{- if not (quote .Values.skipBackgroundRequests | empty) }}
|
|
|
|
skipBackgroundRequests: {{ .Values.skipBackgroundRequests }}
|
|
|
|
{{- end }}
|
2022-02-04 01:47:36 -05:00
|
|
|
validate:
|
2024-09-03 13:04:19 +03:00
|
|
|
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
|
|
|
failureAction: {{ toYaml . }}
|
|
|
|
{{- else }}
|
|
|
|
failureAction: {{ .Values.validationFailureAction }}
|
|
|
|
{{- end }}
|
|
|
|
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
|
|
|
failureActionOverrides: {{ toYaml . | nindent 8 }}
|
|
|
|
{{- end }}
|
2024-12-02 04:50:26 +01:00
|
|
|
allowExistingViolations: {{ .Values.validationAllowExistingViolations }}
|
2022-02-04 01:47:36 -05:00
|
|
|
message: >-
|
|
|
|
Sharing the host namespaces is disallowed. The fields spec.hostNetwork,
|
|
|
|
spec.hostIPC, and spec.hostPID must be unset or set to `false`.
|
|
|
|
pattern:
|
|
|
|
spec:
|
|
|
|
=(hostPID): "false"
|
|
|
|
=(hostIPC): "false"
|
|
|
|
=(hostNetwork): "false"
|
|
|
|
{{- end }}
|