-
Notifications
You must be signed in to change notification settings - Fork 817
CMP-4447: Fix the five shipped CIS OCP-Virt CEL rules (false positives and eval errors) #14916
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
Merged
Mab879
merged 6 commits into
ComplianceAsCode:master
from
Vincent056:cmp-4447-fix-cel-rules
Aug 7, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dd59582
CMP-4447: Fix kubevirt-no-permitted-host-devices false FAIL on partia…
Vincent056 c370153
CMP-4448: Fix kubevirt-nonroot-feature-gate false positive on OCP 4.18+
Vincent056 602bab1
CMP-4449: kubevirt-persistent-reservation-disabled: treat absent fiel…
Vincent056 790c076
CMP-4450: kubevirt-enforce-trusted-tls-registries: guard missing inse…
Vincent056 6273035
CMP-4451: Fix kubevirt-no-vms-overcommitting-guest-memory list iteration
Vincent056 944237a
Address review: prose test-case names, drop Jira refs and parentheticals
Vincent056 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 9 additions & 10 deletions
19
...tions/openshift-virtualization/kubevirt-no-vms-overcommitting-guest-memory/cel/shared.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,20 @@ | ||
| check_type: Platform | ||
|
|
||
| failure_reason: |- | ||
| The '.spec.template.spec.domain.resources.overcommitGuestOverhead' field exists and is | ||
| set to "true" in the 'VirtualMachine' resource, allowing VMs to | ||
| overcommit KubeVirt's memory which may lead to guests crashing and | ||
| interrupting workloads causing malfunctions. | ||
| One or more 'VirtualMachine' resources set | ||
| '.spec.template.spec.domain.resources.overcommitGuestOverhead' to "true", | ||
| allowing VMs to overcommit KubeVirt's memory which may lead to guests | ||
| crashing and interrupting workloads causing malfunctions. | ||
|
|
||
| inputs: | ||
| - name: vms | ||
| kubernetes_input_spec: | ||
| api_version: kubevirt.io/v1 | ||
| resource: VirtualMachine | ||
| resource: virtualmachines | ||
|
|
||
| expression: | | ||
| vms.all(h, | ||
| !has(h.spec.template.spec.domain.resources) || | ||
| !has(h.spec.template.spec.domain.resources.overcommitGuestOverhead) || | ||
| (has(h.spec.template.spec.domain.resources.overcommitGuestOverhead) && | ||
| h.spec.template.spec.domain.resources.overcommitGuestOverhead == false) | ||
| vms.items.all(v, | ||
| !has(v.spec.template.spec.domain.resources) || | ||
| !has(v.spec.template.spec.domain.resources.overcommitGuestOverhead) || | ||
| v.spec.template.spec.domain.resources.overcommitGuestOverhead == false | ||
| ) |
101 changes: 101 additions & 0 deletions
101
...openshift-virtualization/kubevirt-no-vms-overcommitting-guest-memory/cel/tests/cases.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| # CEL rule unit-test fixtures. Evaluated by tests/unit/kubernetes/test_cel_rules.py | ||
| # via celctl (cel-go, the Compliance Operator scanner engine). | ||
| # Seeded from real API objects; see provenance. Versions only, nothing cluster-identifiable. | ||
| provenance: | ||
| fetched_with: celctl cac scaffold --from-cluster | ||
| date: '2026-07-23' | ||
| openshift_version: 4.22.0 | ||
| kubernetes_version: v1.35.5 | ||
| source_api_versions: | ||
| vms: kubevirt.io/v1 | ||
| cases: | ||
| - name: no VirtualMachines present is compliant | ||
| expect: true | ||
| inputs: | ||
| vms: | ||
| apiVersion: v1 | ||
| kind: List | ||
| items: [] | ||
| - name: VM without overcommitGuestOverhead is compliant | ||
| expect: true | ||
| inputs: | ||
| vms: | ||
| apiVersion: v1 | ||
| kind: List | ||
| items: | ||
| - apiVersion: kubevirt.io/v1 | ||
| kind: VirtualMachine | ||
| metadata: | ||
| name: vm-plain | ||
| namespace: default | ||
| spec: | ||
| template: | ||
| spec: | ||
| domain: | ||
| resources: | ||
| requests: | ||
| memory: 2Gi | ||
| - name: VM with overcommitGuestOverhead disabled is compliant | ||
| expect: true | ||
| inputs: | ||
| vms: | ||
| apiVersion: v1 | ||
| kind: List | ||
| items: | ||
| - apiVersion: kubevirt.io/v1 | ||
| kind: VirtualMachine | ||
| metadata: | ||
| name: vm-explicit-false | ||
| namespace: default | ||
| spec: | ||
| template: | ||
| spec: | ||
| domain: | ||
| resources: | ||
| overcommitGuestOverhead: false | ||
| - name: VM with overcommitGuestOverhead enabled is not compliant | ||
| expect: false | ||
| inputs: | ||
| vms: | ||
| apiVersion: v1 | ||
| kind: List | ||
| items: | ||
| - apiVersion: kubevirt.io/v1 | ||
| kind: VirtualMachine | ||
| metadata: | ||
| name: vm-ok | ||
| namespace: default | ||
| spec: | ||
| template: | ||
| spec: | ||
| domain: | ||
| resources: | ||
| requests: | ||
| memory: 2Gi | ||
| - apiVersion: kubevirt.io/v1 | ||
| kind: VirtualMachine | ||
| metadata: | ||
| name: vm-overcommit | ||
| namespace: default | ||
| spec: | ||
| template: | ||
| spec: | ||
| domain: | ||
| resources: | ||
| overcommitGuestOverhead: true | ||
| - name: VM without a resources block is compliant | ||
| expect: true | ||
| inputs: | ||
| vms: | ||
| apiVersion: v1 | ||
| kind: List | ||
| items: | ||
| - apiVersion: kubevirt.io/v1 | ||
| kind: VirtualMachine | ||
| metadata: | ||
| name: vm-noresources | ||
| namespace: default | ||
| spec: | ||
| template: | ||
| spec: | ||
| domain: {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.