Skip to content

Commit

Permalink
Fix prefix length comparison bug in AutoApprovers route evaluation (j…
Browse files Browse the repository at this point in the history
  • Loading branch information
tsujamin authored Nov 1, 2022
1 parent 0cf9c4c commit 8a07381
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Add support for generating pre-auth keys with tags [#767](https://github.com/juanfont/headscale/pull/767)
- Add support for evaluating `autoApprovers` ACL entries when a machine is registered [#763](https://github.com/juanfont/headscale/pull/763)
- Add config flag to allow Headscale to start if OIDC provider is down [#829](https://github.com/juanfont/headscale/pull/829)
- Fix prefix length comparison bug in AutoApprovers route evaluation [#862](https://github.com/juanfont/headscale/pull/862)
- Random node DNS suffix only applied if names collide in namespace. [#766](https://github.com/juanfont/headscale/issues/766)
- Remove `ip_prefix` configuration option and warning [#899](https://github.com/juanfont/headscale/pull/899)
- Add `dns_config.override_local_dns` option [#905](https://github.com/juanfont/headscale/pull/905)
Expand Down
2 changes: 1 addition & 1 deletion acls_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (autoApprovers *AutoApprovers) GetRouteApprovers(
return nil, err
}

if autoApprovedPrefix.Bits() >= prefix.Bits() &&
if prefix.Bits() >= autoApprovedPrefix.Bits() &&
autoApprovedPrefix.Contains(prefix.Masked().Addr()) {
approverAliases = append(approverAliases, autoApproverAliases...)
}
Expand Down
3 changes: 2 additions & 1 deletion machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,8 @@ func (s *Suite) TestAutoApproveRoutes(c *check.C) {

defaultRoute := netip.MustParsePrefix("0.0.0.0/0")
route1 := netip.MustParsePrefix("10.10.0.0/16")
route2 := netip.MustParsePrefix("10.11.0.0/16")
// Check if a subprefix of an autoapproved route is approved
route2 := netip.MustParsePrefix("10.11.0.0/24")

machine := Machine{
ID: 0,
Expand Down

0 comments on commit 8a07381

Please sign in to comment.