mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-05 13:09:07 +02:00
fix(review): coderabbit follow-ups round 2
- status_test.go TestStatus_PeerStateByIP: replace require := assert.New(t) shadowing pattern with req := require.New(t) so setup assertions are fail-fast and the require package isn't shadowed. Add TestStatus_PeerStateByIP_MatchesIPv6 for the IPv6-only path. - status.go PeerStateByIP: match against both State.IP and State.IPv6 so IPv6-only peers are found by the private-service tunnel lookup. Empty input short-circuits before the loop and empty State.IP/State.IPv6 fields are treated as non-matches. - proxy.go ValidateTunnelPeer: call enforceAccountScope(ctx, service.AccountID) after the service lookup, mirroring ValidateSession. Without it, an account-scoped (BYOP) proxy token could mint session JWTs for another account's domain. - sql_store.go getClusterCapability: thread the caller's context into the GORM query via WithContext(ctx) so the lookup is cancellable and honours request deadlines. (Pre-existing on origin/main; included here because GetClusterSupportsPrivate added by this PR is now a caller.) Skipped: - proxyAcceptsMapping SupportsCustomPorts == true: the existing != nil check is intentional. The accompanying test in this PR (TestSendServiceUpdateToCluster_FiltersOnCapability) explicitly asserts "new proxy with SupportsCustomPorts=false should still receive mapping" — the non-nil check encodes "proxy is new enough to understand the protocol", not "proxy can bind custom ports". Tightening to *bool==true would break that design and the test.
This commit is contained in:
@@ -5929,7 +5929,7 @@ func (s *SqlStore) getClusterCapability(ctx context.Context, clusterAddr, column
|
||||
AnyTrue bool
|
||||
}
|
||||
|
||||
err := s.db.
|
||||
err := s.db.WithContext(ctx).
|
||||
Model(&proxy.Proxy{}).
|
||||
Select("COUNT(CASE WHEN "+column+" IS NOT NULL THEN 1 END) > 0 AS has_capability, "+
|
||||
"COALESCE(MAX(CASE WHEN "+column+" = true THEN 1 ELSE 0 END), 0) = 1 AS any_true").
|
||||
|
||||
Reference in New Issue
Block a user