CMP-4447: Fix the five shipped CIS OCP-Virt CEL rules (false positives and eval errors) - #14916
Open
Vincent056 wants to merge 5 commits into
Open
CMP-4447: Fix the five shipped CIS OCP-Virt CEL rules (false positives and eval errors)#14916Vincent056 wants to merge 5 commits into
Vincent056 wants to merge 5 commits into
Conversation
|
Skipping CI for Draft Pull Request. |
Vincent056
marked this pull request as ready for review
July 24, 2026 06:29
…l allowlist CIS OCP-Virt 1.1. The expression required BOTH pciHostDevices and mediatedDevices to be present-and-empty, so an HCO with only 'pciHostDevices: []' (no devices permitted - compliant) reported FAIL. Treat a missing sub-key as empty, and also cover usbHostDevices, which the benchmark remediation lists. Fixtures: 7 cases (absent/all-empty/partial-empty compliant; pci/usb/mediated device configured non-compliant; missing HCO non-compliant). celctl cac lint/test 7/7; live on OCP 4.22 + CNV: PASS. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
CIS OCP-Virt 1.2. The benchmark scopes this control to 'prior to 4.18': from 4.18 the nonRoot field is removed from HyperConverged featureGates and non-root execution is always enforced, so requiring the field made the rule FAIL on every 4.18+ cluster. Treat an absent field as compliant; only FAIL when nonRoot is present and not true. rule.yml ocil updated to match. Fixtures: 5 cases (true/absent/no-featureGates compliant; false and missing HCO non-compliant). celctl cac test 5/5; live on OCP 4.22 + CNV: PASS (was FAIL before this fix). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…d as compliant CIS OCP-Virt 1.3. Persistent reservations are disabled by default; the rule required featureGates.persistentReservation to be present AND false, so the semantic default (key absent) reported a false FAIL. Absent now passes; only an explicit 'true' fails. Fixtures: 5 cases. celctl cac test 5/5; live on OCP 4.22 + CNV: PASS. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…cureRegistries key CIS OCP-Virt 1.5. When storageImport exists without an insecureRegistries key, the expression raised 'no such key: insecureRegistries', which the scanner maps to FAIL - a false non-compliant for a compliant configuration. Guard the nested key so absence passes. Fixtures: 4 cases (no storageImport / missing key / empty list compliant; populated list non-compliant). celctl cac test 4/4; live on OCP 4.22 + CNV: PASS. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
CIS OCP-Virt 2.2. The input 'vms' has no resource_name, so the scanner binds it as a List wrapper - but the expression iterated 'vms.all(...)' instead of 'vms.items.all(...)', walking the wrapper's map keys and erroring with 'no such key: spec' on any cluster with VMs. Also normalize the input resource to the plural 'virtualmachines' for consistency. Scanner RBAC for virtualmachines.kubevirt.io ships with compliance-operator#1293 (merged). Fixtures: 5 cases (no VMs / plain VM / explicit false / no resources block compliant; overcommit true non-compliant). celctl cac lint passes (failed before); cac test 5/5; live on OCP 4.22 + CNV with running VMs: PASS (was ERROR before this fix). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Vincent056
force-pushed
the
cmp-4447-fix-cel-rules
branch
from
July 24, 2026 06:48
da7c3e3 to
b1f1977
Compare
Vincent056
requested review from
Mab879,
jan-cerny,
matusmarhefka and
vojtapolasek
as code owners
July 24, 2026 06:48
|
@Vincent056: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes all five shipped CIS OCP-Virt (
cis-vm-extension) CEL rules — one commit per Jira:usbHostDevices)nonRootfield removed; absence is compliant)persistentReservationis absent (the semantic default "disabled")no such key: insecureRegistries) whenstorageImportlacks the keyvms.allon a List wrapper instead ofvms.items.all) + plural resource nameTesting
Every rule ships
cel/tests/cases.yamlfixtures (26 cases total, each rule with compliant AND non-compliant cases) evaluated throughcelctl— the compliance-operator scanner engine (cel-go). All validated three ways:celctl cac lint— passes for all 5 (2.2 failed before this PR)celctl cac test— 26/26 cases passcelctl cac liveon an OCP 4.22 + CNV cluster with running VMs — all 5 rules PASS; before this PR the same cluster reported 1.2 FAIL (false positive) and 2.2 ERRORNotes
virtualmachines.kubevirt.io(needed by 2.2 at scan time) merged in CMP-4425: Grant scanner RBAC for OpenShift Virtualization resources compliance-operator#1293.🤖 Generated with Claude Code