CMP-4447: Fix the five shipped CIS OCP-Virt CEL rules (false positives and eval errors) - #14916
Conversation
|
Skipping CI for Draft Pull Request. |
da7c3e3 to
b1f1977
Compare
|
/test e2e-aws-openshift-platform-compliance |
rhmdnd
left a comment
There was a problem hiding this comment.
I really like the overall structure of the test cases, and that we're adding CEL test coverage support here.
Some recommendations inline.
…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>
Rename all CEL test cases to plain prose without Jira tickets or parenthetical qualifiers, simplify the provenance fetched_with note, and unwrap the parenthetical failure-reason sentences in the nonroot and persistentReservation rules. Requested by rhmdnd in review. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
b1f1977 to
944237a
Compare
|
@Vincent056: The following test 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. |
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