All Policies
Check supplementalGroups
Supplemental groups control which group IDs containers add and can coincide with restricted groups on the host. Pod Security Policies (PSP) allowed a range of these group IDs to be specified which were allowed. This policy ensures any Pod may only specify supplementalGroup IDs between 100-200 or 500-600.
Policy Definition
/psp-migration/check_supplemental_groups/check-supplemental-groups.yaml
1apiVersion: kyverno.io/v1
2kind: ClusterPolicy
3metadata:
4 name: psp-check-supplemental-groups
5 annotations:
6 policies.kyverno.io/title: Check supplementalGroups
7 policies.kyverno.io/category: PSP Migration
8 policies.kyverno.io/severity: medium
9 kyverno.io/kyverno-version: 1.6.0
10 policies.kyverno.io/minversion: 1.6.0
11 kyverno.io/kubernetes-version: "1.23"
12 policies.kyverno.io/subject: Pod
13 policies.kyverno.io/description: >-
14 Supplemental groups control which group IDs containers add and can coincide with
15 restricted groups on the host. Pod Security Policies (PSP) allowed a range of
16 these group IDs to be specified which were allowed. This policy ensures any Pod
17 may only specify supplementalGroup IDs between 100-200 or 500-600.
18spec:
19 background: false
20 validationFailureAction: audit
21 rules:
22 - name: supplementalgroup-ranges
23 match:
24 any:
25 - resources:
26 kinds:
27 - Pod
28 preconditions:
29 all:
30 - key: "{{ request.operation || 'BACKGROUND' }}"
31 operator: AnyIn
32 value:
33 - CREATE
34 - UPDATE
35 validate:
36 message: Any supplementalGroup ID must be within the range 100-200 or 500-600.
37 pattern:
38 spec:
39 =(securityContext):
40 =(supplementalGroups): 100-200 | 500-600