headscale/hscontrol/policy/v2
Kristoffer Dalby d5b2837231 policy/v2: match default proto set for tests with no proto
The policy `tests` block lets entries omit `proto`. Tailscale's client
maps that to the default protocol set {TCP, UDP, ICMP, ICMPv6} — the
captured packet_filter_matches show all four IANA numbers explicitly
when no proto is set — and a rule restricted to any one of them
satisfies an empty-proto reachability test.

srcReachesDst was passing the empty Protocol through unchanged, which
landed an empty []int in ruleMatchesProto. The matcher then short-
circuited to "no match" for every rule with a non-empty IPProto
restriction, including TCP-only grants compiled from `ip: ["tcp:80"]`.
The bug surfaced in the captured allpass-acls-and-grants-mixed
scenario: the grant `tag:client → webserver:80` was reachable in the
compiled filter but the empty-proto test could not see it.

Expand the empty Protocol to the default set at the call site so
ruleMatchesProto's intersection check sees the right requested
protocols. Drop the now-dead empty-requestedProtos branch from the
matcher. The last divergence drops out of knownPolicyTesterDivergences
as a result.

Updates #1803
2026-05-12 11:54:54 +01:00
..
testdata policy/v2: add policytester captures recorded from Tailscale SaaS 2026-05-12 11:54:54 +01:00
compiled.go policy/v2: surface autogroup:internet via grants on exit nodes 2026-04-30 19:22:45 +01:00
filter.go policy: surface exit nodes via autogroup:internet (#3212) 2026-04-29 11:24:33 +01:00
filter_test.go policy/v2: surface autogroup:internet via grants on exit nodes 2026-04-30 19:22:45 +01:00
issue_3212_test.go policy: surface exit nodes via autogroup:internet (#3212) 2026-04-29 11:24:33 +01:00
issue_3233_test.go policy/v2: surface autogroup:internet via grants on exit nodes 2026-04-30 19:22:45 +01:00
main_test.go all: fix test flakiness and improve test infrastructure 2026-03-14 02:52:28 -07:00
policy.go policy/v2: evaluate the tests block on user-initiated writes 2026-05-12 11:54:54 +01:00
policy_test.go policy/matcher: include CapGrant.Dsts in match destinations 2026-05-11 14:55:06 +01:00
policytester_compat_test.go policy/v2: match default proto set for tests with no proto 2026-05-12 11:54:54 +01:00
tailscale_acl_data_compat_test.go all: rephrase prose to fit codebase voice 2026-04-29 16:22:19 +01:00
tailscale_grants_compat_test.go all: rephrase prose to fit codebase voice 2026-04-29 16:22:19 +01:00
tailscale_routes_data_compat_test.go all: rephrase prose to fit codebase voice 2026-04-29 16:22:19 +01:00
tailscale_ssh_data_compat_test.go testdata: drop unused uppercase SSH-*.hujson fixtures 2026-05-05 11:59:01 +01:00
test.go policy/v2: match default proto set for tests with no proto 2026-05-12 11:54:54 +01:00
test_test.go policy/v2: match default proto set for tests with no proto 2026-05-12 11:54:54 +01:00
types.go policy/v2: canonicalize Protocol form during unmarshal 2026-05-12 11:54:54 +01:00
types_test.go policy/v2: canonicalize Protocol form during unmarshal 2026-05-12 11:54:54 +01:00
utils.go policy/v2: exclude exit routes from ReduceFilterRules 2026-04-01 14:10:42 +01:00
utils_test.go policy/v2: exclude exit routes from ReduceFilterRules 2026-04-01 14:10:42 +01:00