fix(score): use related object in RegoResponseVector scoring loop#171
Conversation
Signed-off-by: Sanchit2662 <sanchit2662@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe ChangesRelated Object Scoring Correction
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hey @matthyx , any update? |
So I was going through the score/score.go file in the opa-utils codebase and found a bug in the GetScore function. Basically, when a finding comes in as a RegoResponseVector (which is how a lot of Kubescape rules report results when multiple K8s resources are involved), the code loops over the related objects but never actually uses them. It was building the workload from the outer vector map v every single time, not from related[i]. So no matter how many replicas a Deployment had, or how many nodes a DaemonSet was running on, the score came out the same flat value. The replica multiplier and the DaemonSet node count logic were just... never firing for these findings.
I fixed it by making the loop actually use related[i].GetObject() to build the workload, and seeding processWorkload with defaultScore instead of the running accumulator. Small change, three lines basically, but now the scoring actually reflects the real blast radius of a finding instead of just returning 1.0 every time.
Summary by CodeRabbit