Skip to content

Commit

Permalink
fix(policy chart): Skip DELETE requests on policies using deny statem…
Browse files Browse the repository at this point in the history
…ents (kyverno#7883)

Fixes kyverno#7456

Signed-off-by: Trey Dockendorf <tdockendorf@osc.edu>
Co-authored-by: shuting <shuting@nirmata.com>
  • Loading branch information
treydock and realshuting authored Jul 24, 2023
1 parent 295e98a commit 2273529
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
2 changes: 2 additions & 0 deletions charts/kyverno-policies/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ annotations:
description: Support for customLabels, they were ignored up to now
- kind: removed
description: "Walk back change in PSS policy to send to to_upper"
- kind: fixed
description: Skip DELETE requests on policies using deny statements
10 changes: 10 additions & 0 deletions charts/kyverno-policies/ci/test-preconditions-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,18 @@ policyPreconditions:
- key: "{{ request.object.metadata.name }}"
operator: NotEquals
value: "dcgm-exporter*"
disallow-capabilities:
all:
- key: "{{ request.object.metadata.name }}"
operator: NotEquals
value: "dcgm-exporter*"
adding-capabilities-strict:
all:
- key: "{{ request.object.metadata.name }}"
operator: NotEquals
value: "dcgm-exporter*"
restrict-volume-types:
all:
- key: "{{ request.object.metadata.name }}"
operator: NotEquals
value: "dcgm-exporter*"
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,26 @@ spec:
exclude:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with index .Values "policyPreconditions" $name }}
{{- $preconditions := index .Values "policyPreconditions" $name }}
{{- if $preconditions }}
{{- with $preconditions }}
preconditions:
{{- toYaml . | nindent 8 }}
{{- if .all }}
all:
- key: "{{`{{ request.operation || 'BACKGROUND' }}`}}"
operator: NotEquals
value: DELETE
{{- toYaml .all | nindent 8 }}
{{- else }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- else }}
preconditions:
all:
- key: "{{`{{ request.operation || 'BACKGROUND' }}`}}"
operator: NotEquals
value: DELETE
{{- end }}
validate:
message: >-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,26 @@ spec:
exclude:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with index .Values "policyPreconditions" $name }}
{{- $preconditions := index .Values "policyPreconditions" $name }}
{{- if $preconditions }}
{{- with $preconditions }}
preconditions:
{{- toYaml . | nindent 8 }}
{{- if .all }}
all:
- key: "{{`{{ request.operation || 'BACKGROUND' }}`}}"
operator: NotEquals
value: DELETE
{{- toYaml .all | nindent 8 }}
{{- else }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- else }}
preconditions:
all:
- key: "{{`{{ request.operation || 'BACKGROUND' }}`}}"
operator: NotEquals
value: DELETE
{{- end }}
validate:
message: >-
Expand Down

0 comments on commit 2273529

Please sign in to comment.