Address CodeRabbit review on embedded VNC PR

This commit is contained in:
Viktor Liu
2026-05-24 18:52:57 +02:00
parent 4e3e3ce6d3
commit bf2fb2fd44
7 changed files with 58 additions and 14 deletions
@@ -243,7 +243,7 @@ func (c *NetworkMapComponents) resolveRuleEndpoint(
postureChecks []string,
) ([]*nbpeer.Peer, bool) {
if resource.Type == ResourceTypePeer && resource.ID != "" {
return c.getPeerFromResource(resource, peerID)
return c.getPeerFromResource(resource, peerID, postureChecks)
}
return c.getAllPeersFromGroups(groups, peerID, postureChecks)
}
@@ -385,8 +385,11 @@ func (c *NetworkMapComponents) getUniquePeerIDsFromGroupsIDs(groups []string) []
return ids
}
func (c *NetworkMapComponents) getPeerFromResource(resource Resource, peerID string) ([]*nbpeer.Peer, bool) {
func (c *NetworkMapComponents) getPeerFromResource(resource Resource, peerID string, postureChecks []string) ([]*nbpeer.Peer, bool) {
if resource.ID == peerID {
if len(postureChecks) > 0 && !c.ValidatePostureChecksOnPeer(peerID, postureChecks) {
return []*nbpeer.Peer{}, false
}
return []*nbpeer.Peer{}, true
}
@@ -394,6 +397,9 @@ func (c *NetworkMapComponents) getPeerFromResource(resource Resource, peerID str
if peerInfo == nil {
return []*nbpeer.Peer{}, false
}
if len(postureChecks) > 0 && !c.ValidatePostureChecksOnPeer(resource.ID, postureChecks) {
return []*nbpeer.Peer{}, false
}
return []*nbpeer.Peer{peerInfo}, false
}
@@ -59,9 +59,10 @@ func applyResolvedRuleToState(
) {
emitRuleDirections(rule, sourcePeers, destPeers, peerInSources, peerInDestinations, generateResources)
receivingPeer := peerInDestinations || (rule.Bidirectional && peerInSources)
switch {
case rule.Protocol == PolicyRuleProtocolNetbirdSSH:
if !peerInDestinations {
if !receivingPeer {
return
}
state.sshEnabled = true
@@ -69,7 +70,7 @@ func applyResolvedRuleToState(
case rule.Protocol == PolicyRuleProtocolNetbirdVNC:
cb.handleVNCRule(rule, peerInSources, peerInDestinations, state)
case policyRuleImpliesLegacySSH(rule) && targetPeerSSHEnabled:
if !peerInDestinations {
if !receivingPeer {
return
}
state.sshEnabled = true