headscale/hscontrol/policy/v2
Kristoffer Dalby f172dba0e3 policy/v2: validate tests block at parse boundary
A `tests` entry describes one connection attempt to one specific
host on one specific port over a connection-oriented protocol, and
asserts whether it is allowed or denied. Five shape rules follow —
single-port dst, proto in {tcp, udp, sctp, ""}, no
autogroup:internet dst, no CIDR-typed dst (raw `/N` or hosts:-alias
to a multi-host prefix), at least one of accept/deny — and every
one was previously silently accepted by headscale even though
Tailscale SaaS rejects them as "test(s) failed".

Enforce them in one pass over `pol.Tests` from `Policy.validate()`,
reusing the existing parse-time multierr aggregation. The same
shapes remain valid inside ACL or Grant destinations where the rule
does not apply; the validator only walks the tests array.

The compat runner now treats parse-time errors equivalently to
SetPolicy errors so the captured Tailscale body still matches via
substring regardless of which step surfaces the rejection. Nine
divergences resolved by this validation pass drop out of
knownPolicyTesterDivergences.

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: validate tests block at parse boundary 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: add policytester compat test runner 2026-05-12 11:54:54 +01:00
test_test.go policy/v2: validate tests block at parse boundary 2026-05-12 11:54:54 +01:00
types.go policy/v2: validate tests block at parse boundary 2026-05-12 11:54:54 +01:00
types_test.go policy/v2: validate tests block at parse boundary 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