Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
fix(kyverno): fixing the kyverno pod security policies (#285)
Browse files Browse the repository at this point in the history
* update the rules for RunAsRoot/Any
* cosmetic updates

Signed-off-by: shubham chaudhary <[email protected]>
  • Loading branch information
Shubham Chaudhary authored Oct 8, 2021
1 parent 15ad1cc commit f9f4b1f
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 25 deletions.
4 changes: 2 additions & 2 deletions charts/openebs/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
version: 3.0.0
version: 3.0.1
name: openebs
appVersion: 3.0.0
appVersion: 3.0.1
description: Containerized Attached Storage for Kubernetes
icon: https://raw.githubusercontent.com/cncf/artwork/HEAD/projects/openebs/icon/color/openebs-icon-color.png
home: http://www.openebs.io/
Expand Down
2 changes: 1 addition & 1 deletion charts/openebs/templates/kyverno/allow-capabilities.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: Pod
policies.kyverno.io/description: >-
Provides a list of capabilities that are allowed to be added to a container.
Provides a list of capabilities that are allowed to be added to a container.
spec:
validationFailureAction: enforce
background: true
Expand Down
8 changes: 4 additions & 4 deletions charts/openebs/templates/kyverno/allow-host-ports.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ spec:
validate:
message: >-
Use of host ports is allowed. The fields spec.containers[*].ports[*].hostPort
and spec.initContainers[*].ports[*].hostPort must be empty.
should contain value in range [1,65535).
pattern:
spec:
=(hostPort):
=(min): ">0"
=(max): "<65535"
containers:
- =(ports):
- =(hostPort): ">0 & <65535"
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ spec:
- Pod
validate:
message: >-
Privilege escalation is allowed. The fields spec.containers[*].securityContext.allowPrivilegeEscalation,
and spec.initContainers[*].securityContext.allowPrivilegeEscalation must be defined or set to `true`.
Privilege escalation is allowed. The fields spec.containers[*].securityContext.allowPrivilegeEscalation
must be defined or set to `true`.
pattern:
spec:
containers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ spec:
- Pod
validate:
message: >-
Privileged mode is allowed. The fields spec.containers[*].securityContext.privileged
and spec.initContainers[*].securityContext.privileged must not set to be false.
Privileged mode is allowed. The fields spec.containers[*].securityContext.privileged
must be defined or set to true.
pattern:
spec:
containers:
Expand Down
7 changes: 3 additions & 4 deletions charts/openebs/templates/kyverno/allow-proc-mount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: Pod
policies.kyverno.io/description: >-
The default /proc masks are set up to reduce attack surface and should be required.
The default /proc masks are set up to reduce attack surface and should be required.
spec:
validationFailureAction: enforce
background: true
Expand All @@ -21,9 +21,8 @@ spec:
validate:
message: >-
Changing the proc mount from the default is not allowed. The fields
spec.containers[*].securityContext.procMount and
spec.initContainers[*].securityContext.procMount must not be changed
from `Default`.
spec.containers[*].securityContext.procMount should be defined or set
to Default
pattern:
spec:
containers:
Expand Down
17 changes: 7 additions & 10 deletions charts/openebs/templates/kyverno/require-user-groups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ spec:
validationFailureAction: enforce
background: true
rules:
- name: user-groups
- name: check-runasuser
match:
resources:
name: check-runasuser
kinds:
- Pod
validate:
Expand All @@ -25,14 +24,13 @@ spec:
pattern:
spec:
=(securityContext):
=(runAsUser): 'RunAsAny'
=(runAsUser): ">=0"
containers:
- =(securityContext):
=(runAsUser): 'RunAsAny'

=(runAsUser): ">=0"
- name: check-supplementalGroups
match:
resources:
name: check-supplementalGroups
kinds:
- Pod
validate:
Expand All @@ -42,11 +40,10 @@ spec:
spec:
=(securityContext):
=(supplementalGroups):
- 'RunAsAny'

- ">=0"
- name: check-fsGroup
match:
resources:
name: check-fsGroup
kinds:
- Pod
validate:
Expand All @@ -55,5 +52,5 @@ spec:
pattern:
spec:
=(securityContext):
=(fsGroup): 'RunAsAny'
=(fsGroup): ">=0"
{{- end }}

0 comments on commit f9f4b1f

Please sign in to comment.