Prevent posture checks field update from nmui#4070
Conversation
|
Review Complete Files Reviewed: 1 By Severity:
The PR adds new PostureCheck fields (violations, severity level, evaluation timestamp/ID) to the Node model's Fill method with two data-model issues: the zero-value integer enum SeverityUnknown is conflated with 'unset', and the violations slice is aliased rather than deep-copied. Files Reviewed (1 files) |
There was a problem hiding this comment.
Risk: 🟡 Medium (42/100) — 2 medium findings · 12 LOC across 1 file
PR #4070 Review Summary
This single-file PR (models/node.go) extends the Fill method on the Node struct to merge three new PostureCheck-related fields when in-network node updates are received.
Key Findings
- finding-001: The guard
newNode.PostureCheckViolationSeverityLevel == 0at line 266 treats the iota enum memberSeverityUnknown(value 0) as 'unset', conflating a legitimate domain value with the absent/initialized state. Future callers that intentionally setSeverityUnknownwould have their value silently overwritten. - finding-002: At line 270, the slice assignment shares the backing array between
currentNodeandnewNode— any subsequent append, re-slice, or sort on either node'sPostureChecksViolationswill mutate the other's data, creating an alias bug.
Assessment
Both issues are medium severity with moderate fix complexity. Neither is a crash or security vulnerability, but they create latent data-integrity bugs that could manifest as stale or incorrect posture-check state propagation in multi-node deployments.
Describe your changes
Provide Issue ticket number if applicable/not in title
Provide testing steps
Checklist before requesting a review