Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NDEV-17894: correct mutate resource for disallow-previliged containers #111

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: remediate-disallow-privileged-containers
annotations:
policies.kyverno.io/title: Remediate Disallow Privileged Containers
policies.kyverno.io/category: Pod Security Standards (Baseline)
policies.kyverno.io/description: >-
This policy remediates the disallow-privileged-containers violation
spec:
background: false
rules:
- name: remove-privileged-containers
match:
any:
- resources:
kinds:
- Deployment
- StatefulSet
- Job
- DaemonSet
mutate:
foreach:
- list: request.object.spec.template.spec.containers[]
order: Descending
preconditions:
all:
- key: "{{ element.securityContext && element.securityContext.privileged || 'false' }}"
operator: Equals
value: true
patchesJson6902: |-
- path: /spec/template/spec/containers/{{elementIndex}}/securityContext/privileged
op: replace
value: false
- list: request.object.spec.template.spec.initContainers[]
order: Descending
preconditions:
all:
- key: "{{ element.securityContext && element.securityContext.privileged || 'false' }}"
operator: Equals
value: true
patchesJson6902: |-
- path: /spec/template/spec/initContainers/{{elementIndex}}/securityContext/privileged
op: replace
value: false
- list: request.object.spec.template.spec.ephemeralContainers[]
order: Descending
preconditions:
all:
- key: "{{ element.securityContext && element.securityContext.privileged || 'false' }}"
operator: Equals
value: true
patchesJson6902: |-
- path: /spec/template/spec/ephemeralContainers/{{elementIndex}}/securityContext/privileged
op: replace
value: false
Loading