[Bug] [CLI] Kyverno CLI test command ignores CONNECT operation and fails validation
Kyverno CLI Version
1.16.4
Description
Kubernetes Admission Webhooks and Kyverno's policy engine support CONNECT operations (e.g. for pods/exec, pods/attach, pods/portforward).
However, in kubectl-kyverno:
NormalizeOperationincmd/cli/kubectl-kyverno/processor/operation.gorejects"CONNECT"with an error:invalid operation "CONNECT", must be one of CREATE, UPDATE, DELETEmakePolicyContextincmd/cli/kubectl-kyverno/processor/policy_processor.gois missingcase "CONNECT":in its operation switch statements. Whenrequest.operation: CONNECTis set in values files,policy_processor.gosilently falls back tokyvernov1.Create.
As a result, offline CLI policy evaluations against CONNECT operations fail or skip rule execution.
Steps to reproduce
- Create
policy.yaml:`yaml apiVersion: kyverno.io/v1 kind: ClusterPolicy metadata: name: block-connect spec: validationFailureAction: Enforce rules:
- name: check-connect
match:
any:
- resources:
kinds:
- Pod operations:
- CONNECT
validate:
message: "CONNECT operation blocked"
deny: {}
`
- resources:
kinds:
- Create
values.yaml:`yaml policies:
- name: block-connect
rules:
- name: check-connect values: request.operation: CONNECT
`
Create
pod.yaml:yaml apiVersion: v1 kind: Pod metadata: name: test-pod namespace: defaultRun
kubectl-kyverno apply:bash kubectl-kyverno apply policy.yaml --resource pod.yaml --values values.yaml
Expected behavior
The CLI should recognize CONNECT as a valid admission operation, map it to kyvernov1.Connect in the policy context, and evaluate rules matching operations: ["CONNECT"] (returning fail: 1 / pass: 1 rather than silently skipping as CREATE).
Screenshots
No response
Kyverno logs
Slack discussion
No response
Troubleshooting
- I have read and followed the troubleshooting guide.
- I have searched other issues in this repository and mine is not recorded.
Source: kyverno/kyverno