Skip to content

CMP-4432: Add secondary-network CEL rules for CIS OCP-Virt 4.1/4.2 (SR-IOV + NAD split) - #14919

Open
Vincent056 wants to merge 2 commits into
ComplianceAsCode:masterfrom
Vincent056:cmp-4432-network-cel-rules
Open

CMP-4432: Add secondary-network CEL rules for CIS OCP-Virt 4.1/4.2 (SR-IOV + NAD split)#14919
Vincent056 wants to merge 2 commits into
ComplianceAsCode:masterfrom
Vincent056:cmp-4432-network-cel-rules

Conversation

@Vincent056

@Vincent056 Vincent056 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds four CEL rules for the CIS OCP-Virt secondary-network controls — each control split into an SR-IOV rule and a NAD rule so applicability is clean:

Commit CIS Rules
CMP-4432 4.1 kubevirt-sriov-vlan-required (SriovNetwork .spec.vlan > 0), kubevirt-localnet-vlan-required (localnet NAD vlanID)
CMP-4433 4.2 kubevirt-sriov-spoofchk-on (SriovNetwork spoofChk: "on"), kubevirt-bridge-mac-spoof-filtering (bridge NAD macspoofchk: true)

Why split: a combined rule ERRORs wholesale on clusters without the SR-IOV Network Operator — one failed input fetch (sriovnetworks type not registered) prevents binding for the whole expression. Verified via an operator scan on a stock AWS cluster. With the split, the NAD rules work on every cluster (the NAD CRD ships with multus); only the two SR-IOV rules depend on the operator and will be marked Not Applicable by the CEL CPE work (CMP-4483) — documented in each rule.

All parsed-JSON key access is guarded with in (configs without topology/type keys are ignored, never a no-such-key FAIL). Scanner RBAC merged in ComplianceAsCode/compliance-operator#1293. Rules added to the cis-vm-extension profile selections.

CIS 4.3 (multi-network policies, CMP-4434) ships as a Manual rule in the Manual-rules PR (MultiNetworkPolicy CRD disabled by default cluster-wide).

Testing

  • celctl cac lint + cac test: 19/19 fixture cases across the 4 rules
  • Operator scan on OCP 4.21 + CNV (fresh install): kubevirt-localnet-vlan-required PASS; kubevirt-bridge-mac-spoof-filtering correctly FAILs when a bridge NAD without macspoofchk is present and PASSes when only compliant NADs exist; the two SR-IOV rules report the documented not-applicable ERROR on a cluster without the SR-IOV operator
  • Strict-semantics check on a separate OCP 4.22 + CNV cluster with a real SriovNetwork lacking vlan/spoofChk: SR-IOV rules correctly report non-compliant

🤖 Generated with Claude Code

@openshift-ci

openshift-ci Bot commented Jul 23, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Jul 23, 2026
Vincent056 and others added 2 commits July 23, 2026 23:28
Two rules, split by resource so applicability is clean:
- kubevirt-sriov-vlan-required: every SriovNetwork declares .spec.vlan > 0.
  Requires the SR-IOV Network Operator; on clusters without it the resource
  type does not exist and the check errors - CPE applicability for CEL
  (CMP-4483) will mark it Not Applicable. Documented in the rule.
- kubevirt-localnet-vlan-required: every OVN localnet
  NetworkAttachmentDefinition declares vlanID in its CNI config. Works on
  every cluster (NAD CRD ships with multus). Parsed-JSON key access guarded
  with 'in' so configs without a topology key are ignored, never a
  no-such-key FAIL.

An earlier combined rule ERRORed wholesale on clusters without the SR-IOV
operator (verified via an operator scan on a stock AWS cluster) because one
failed input fetch prevents binding for the whole expression - hence the
split.

Fixtures: 9 cases via celctl - all pass. Verified via operator scan on OCP
4.21 + CNV: localnet rule evaluates and passes; sriov rule errors without
the SR-IOV operator as documented. RBAC ships with
compliance-operator#1293 (merged). Added to cis-vm-extension profile.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Two rules, split by resource (same rationale as CMP-4432):
- kubevirt-sriov-spoofchk-on: every SriovNetwork sets spoofChk "on"
  (explicit, per the benchmark). Requires the SR-IOV Network Operator;
  Not Applicable handling via CMP-4483 where absent.
- kubevirt-bridge-mac-spoof-filtering: every bridge-type
  NetworkAttachmentDefinition sets macspoofchk: true. Works on every
  cluster; parsed-JSON access guarded with 'in'.

Fixtures: 10 cases via celctl - all pass. Verified via operator scan on
OCP 4.21 + CNV: bridge rule evaluates against real NADs. Added to
cis-vm-extension profile.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Vincent056
Vincent056 force-pushed the cmp-4432-network-cel-rules branch from da67e07 to f99655d Compare July 24, 2026 06:28
@Vincent056 Vincent056 changed the title CMP-4432: Add secondary-network CEL rules for CIS OCP-Virt 4.1/4.2 CMP-4432: Add secondary-network CEL rules for CIS OCP-Virt 4.1/4.2 (SR-IOV + NAD split) Jul 24, 2026
@Vincent056
Vincent056 marked this pull request as ready for review July 24, 2026 06:29
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Jul 24, 2026
@openshift-ci

openshift-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown

@Vincent056: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-openshift-platform-compliance f99655d link true /test e2e-aws-openshift-platform-compliance
ci/prow/e2e-aws-openshift-node-compliance f99655d link true /test e2e-aws-openshift-node-compliance

Full PR test history. Your PR dashboard.

Details

Instructions 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.

@jan-cerny jan-cerny added the OpenShift OpenShift product related. label Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OpenShift OpenShift product related.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants