mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-28 18:38:40 +00:00
[Feature] Add posibility to set validationFailureAction by Policy (#4400)
* Implement validationFailureActionByPolicy * Update README.md * Add artifacthub.io/changes entry * Add Test Case Signed-off-by: dschunack <dschunack@web.de>
This commit is contained in:
parent
cf0ee93de8
commit
7b31f456c9
22 changed files with 90 additions and 6 deletions
charts/kyverno-policies
Chart.yamlREADME.mdvalues.yaml
ci
templates
baseline
disallow-capabilities.yamldisallow-host-namespaces.yamldisallow-host-path.yamldisallow-host-ports.yamldisallow-host-process.yamldisallow-privileged-containers.yamldisallow-proc-mount.yamldisallow-selinux.yamlrestrict-apparmor-profiles.yamlrestrict-seccomp.yamlrestrict-sysctls.yaml
other
restricted
|
@ -1,7 +1,7 @@
|
|||
apiVersion: v2
|
||||
type: application
|
||||
name: kyverno-policies
|
||||
version: v2.5.3
|
||||
version: v2.5.4
|
||||
appVersion: v1.7.3
|
||||
icon: https://github.com/kyverno/kyverno/raw/main/img/logo.png
|
||||
description: Kubernetes Pod Security Standards implemented as Kyverno policies
|
||||
|
@ -31,3 +31,5 @@ annotations:
|
|||
description: Ensure preconditions are present with default values
|
||||
- kind: added
|
||||
description: Support for failurePolicy setting in kyverno-policies helm chart
|
||||
- kind: added
|
||||
description: Add posibility to set validationFailureAction by Policy
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
Kubernetes Pod Security Standards implemented as Kyverno policies
|
||||
|
||||
  
|
||||
  
|
||||
|
||||
## About
|
||||
|
||||
|
@ -67,8 +67,9 @@ The command removes all the Kubernetes components associated with the chart and
|
|||
| podSecuritySeverity | string | `"medium"` | Pod Security Standard (`low`, `medium`, `high`). |
|
||||
| podSecurityPolicies | list | `[]` | Policies to include when `podSecurityStandard` is `custom`. |
|
||||
| includeOtherPolicies | list | `[]` | Additional policies to include from `other`. |
|
||||
| validationFailureAction | string | `"audit"` | Validation failure action (`audit`, `enforce`). For more info https://kyverno.io/docs/writing-policies/validate. |
|
||||
| failurePolicy | string | `"Fail"` | API server behavior if the webhook fails to respond ('Ignore', 'Fail') For more info: https://kyverno.io/docs/writing-policies/policy-settings/ |
|
||||
| validationFailureAction | string | `"audit"` | Validation failure action (`audit`, `enforce`). For more info https://kyverno.io/docs/writing-policies/validate. |
|
||||
| validationFailureActionByPolicy | object | `{}` | Define validationFailureActionByPolicy for specific policies. Override the defined `validationFailureAction` with a individual validationFailureAction for individual Policies. |
|
||||
| validationFailureActionOverrides | object | `{"all":[]}` | Define validationFailureActionOverrides for specific policies. The overrides for `all` will apply to all policies. |
|
||||
| policyExclude | object | `{}` | Exclude resources from individual policies. Policies with multiple rules can have individual rules excluded by using the name of the rule as the key in the `policyExclude` map. |
|
||||
| policyPreconditions | object | `{}` | Add preconditions to individual policies. Policies with multiple rules can have individual rules excluded by using the name of the rule as the key in the `policyPreconditions` map. |
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
podSecurityStandard: restricted
|
||||
includeOtherPolicies:
|
||||
- require-non-root-groups
|
||||
validationFailureActionByPolicy:
|
||||
require-non-root-groups: enforce
|
||||
validationFailureActionOverrides:
|
||||
all:
|
||||
- action: audit
|
||||
|
|
|
@ -18,7 +18,11 @@ metadata:
|
|||
policies.kyverno.io/description: >-
|
||||
Adding capabilities beyond those listed in the policy must be disallowed.
|
||||
spec:
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -19,7 +19,11 @@ metadata:
|
|||
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`.
|
||||
spec:
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -18,7 +18,11 @@ metadata:
|
|||
Using host resources can be used to access shared data or escalate privileges
|
||||
and should not be allowed. This policy ensures no hostPath volumes are in use.
|
||||
spec:
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -18,7 +18,11 @@ metadata:
|
|||
allowed, or at minimum restricted to a known list. This policy ensures the `hostPort`
|
||||
field is unset or set to `0`.
|
||||
spec:
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -19,7 +19,11 @@ metadata:
|
|||
policy. HostProcess pods are an alpha feature as of Kubernetes v1.22. This policy ensures
|
||||
the `hostProcess` field, if present, is set to `false`.
|
||||
spec:
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -17,7 +17,11 @@ metadata:
|
|||
Privileged mode disables most security mechanisms and must not be allowed. This policy
|
||||
ensures Pods do not call for privileged mode.
|
||||
spec:
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -19,7 +19,11 @@ metadata:
|
|||
to deviate from the `Default` procMount requires setting a feature gate at the API
|
||||
server.
|
||||
spec:
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -17,7 +17,11 @@ metadata:
|
|||
SELinux options can be used to escalate privileges and should not be allowed. This policy
|
||||
ensures that the `seLinuxOptions` field is undefined.
|
||||
spec:
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -20,7 +20,11 @@ metadata:
|
|||
overrides to an allowed set of profiles. This policy ensures Pods do not
|
||||
specify any other AppArmor profiles than `runtime/default` or `localhost/*`.
|
||||
spec:
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -19,7 +19,11 @@ metadata:
|
|||
set to `RuntimeDefault` or `Localhost`.
|
||||
spec:
|
||||
background: {{ .Values.background }}
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -21,7 +21,11 @@ metadata:
|
|||
This policy ensures that only those "safe" subsets can be specified in
|
||||
a Pod.
|
||||
spec:
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -19,7 +19,11 @@ metadata:
|
|||
greater than zero (i.e., non root). A known issue prevents a policy such as this
|
||||
using `anyPattern` from being persisted properly in Kubernetes 1.23.0-1.23.2.
|
||||
spec:
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -19,7 +19,11 @@ metadata:
|
|||
Adding capabilities other than `NET_BIND_SERVICE` is disallowed. In addition,
|
||||
all containers must explicitly drop `ALL` capabilities.
|
||||
spec:
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -17,7 +17,11 @@ metadata:
|
|||
Privilege escalation, such as via set-user-ID or set-group-ID file mode, should not be allowed.
|
||||
This policy ensures the `allowPrivilegeEscalation` field is set to `false`.
|
||||
spec:
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -17,7 +17,11 @@ metadata:
|
|||
Containers must be required to run as non-root users. This policy ensures
|
||||
`runAsUser` is either unset or set to a number greater than zero.
|
||||
spec:
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -18,7 +18,11 @@ metadata:
|
|||
`runAsNonRoot` is set to `true`. A known issue prevents a policy such as this
|
||||
using `anyPattern` from being persisted properly in Kubernetes 1.23.0-1.23.2.
|
||||
spec:
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -20,7 +20,11 @@ metadata:
|
|||
set to `RuntimeDefault` or `Localhost`. A known issue prevents a policy such as this
|
||||
using `anyPattern` from being persisted properly in Kubernetes 1.23.0-1.23.2.
|
||||
spec:
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -20,7 +20,11 @@ metadata:
|
|||
limits usage of non-core volume types to those defined through PersistentVolumes.
|
||||
This policy blocks any other type of volume other than those in the allow list.
|
||||
spec:
|
||||
{{- with index .Values "validationFailureActionByPolicy" $name }}
|
||||
validationFailureAction: {{ toYaml . }}
|
||||
{{- else }}
|
||||
validationFailureAction: {{ .Values.validationFailureAction }}
|
||||
{{- end }}
|
||||
{{- with concat (index .Values "validationFailureActionOverrides" "all") (default list (index .Values "validationFailureActionOverrides" $name)) }}
|
||||
validationFailureActionOverrides: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -12,13 +12,20 @@ podSecurityPolicies: []
|
|||
includeOtherPolicies: []
|
||||
# - require-non-root-groups
|
||||
|
||||
# -- API server behavior if the webhook fails to respond ('Ignore', 'Fail')
|
||||
# For more info: https://kyverno.io/docs/writing-policies/policy-settings/
|
||||
failurePolicy: Fail
|
||||
|
||||
# -- Validation failure action (`audit`, `enforce`).
|
||||
# For more info https://kyverno.io/docs/writing-policies/validate.
|
||||
validationFailureAction: audit
|
||||
|
||||
# -- API server behavior if the webhook fails to respond ('Ignore', 'Fail')
|
||||
# For more info: https://kyverno.io/docs/writing-policies/policy-settings/
|
||||
failurePolicy: Fail
|
||||
# -- Define validationFailureActionByPolicy for specific policies.
|
||||
# Override the defined `validationFailureAction` with a individual validationFailureAction for individual Policies.
|
||||
validationFailureActionByPolicy: {}
|
||||
# disallow-capabilities-strict: enforce
|
||||
# disallow-host-path: enforce
|
||||
# disallow-host-ports: enforce
|
||||
|
||||
# -- Define validationFailureActionOverrides for specific policies.
|
||||
# The overrides for `all` will apply to all policies.
|
||||
|
|
Loading…
Add table
Reference in a new issue