Repository navigation
fix(exceptions): don't ignore label constraints on non-workload objects - #201
Conversation
metadataHasException compared a designator's labels (and containerName)
only for workload objects. For a RegoResponseVector base object, a
host-sensor object or a cloud-provider object the constraint was skipped,
so an exception scoped only by labels (attributes: {app: nginx}) matched
every RBAC subject, host and cloud finding of the control. Such objects
have no labels or containers to compare, so a designator that constrains
them now doesn't match; a related object of a vector that carries the
label still does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: itsvishalyadav <vishalyadav87695@gmail.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
matthyx
left a comment
There was a problem hiding this comment.
Reviewed head 1b0ffd3 against main 2284a07. The fix is needed: label/containerName constraints previously bypassed workload metadata comparisons on non-workload objects, allowing label-scoped exceptions to match unrelated vector/host/cloud findings. The new guard rejects those constrained base objects while preserving matches on related labeled objects and name-only cases; the regression tests cover both vector paths and host-sensor behavior. No blockers found. Related history: #149 introduced vector iteration and was merged; #200 documents the still-reproducible fall-through. Searches surfaced adjacent #169 (containerName), #171 (vector scoring), #176 (objectSelector), and #189 (empty resources), but no superseding fix or explicit rejected approach. GitHub search was rate-limited during broader alternate-term issue queries, so absence of other matches is not conclusive. CI run 43123813746 passed, including race tests, full tests, build, and golangci-lint; DCO and GitGuardian passed; CodeRabbit was skipped. I did not run repository code locally; review was static plus isolated CI. Verdict: approve.
Overview
Fixes #200.
metadataHasExceptioncompared a designator's labels, and itscontainerName, only for workload objects. For a RegoResponseVector base object, a host-sensor object or a cloud-provider object, it skipped the constraint and returnedtrue. So an exception scoped only by labels matched every RBAC subject, host and cloud finding of the control.Those objects have no labels, annotations or containers to compare. So a designator that constrains labels or
containerNamenow doesn't match them. Other cases behave as before:How to Test
go test ./exceptions/ -run TestGetResourceExceptions_LabelDesignatorOnNonWorkloads -count=1 -vTestGetResourceExceptions_LabelDesignatorOnNonWorkloadshas four cases:main;main;With the fix all four pass, and
go test ./...passes.🤖 Generated with Claude Code