improvements to config parsing

This commit is contained in:
JackDoan committed 2026-10-01 10:18:30 -05:00
1 parent ed8ae57fee
commit 04e80f0dcf
6 files changed
+58 -7

No files matched your search

+4 -3
View File
@@ -223,8 +223,9 @@ func TestRulesBuilder_protoIndex(t *testing.T) {
require.NoError(t, rb.AddRule(true, iputil.IPProtocolTCP, PortFragment, PortFragment, nil, "fragment", "", "", "", ""))
// A range that includes port 0 is port `any`.
require.NoError(t, rb.AddRule(true, iputil.IPProtocolUDP, 0, 100, nil, "zero", "", "", "", ""))
// GRE has no ports, so a port rule on it never applies.
require.NoError(t, rb.AddRule(true, 47, 22, 22, nil, "gre", "", "", "", ""))
// GRE has no ports, so a port rule on it is rejected rather than never applying, and `any` and `fragment` apply
require.Error(t, rb.AddRule(true, 47, 22, 22, nil, "gre", "", "", "", ""))
require.NoError(t, rb.AddRule(true, 47, PortFragment, PortFragment, nil, "gre", "", "", "", ""))
rules := rb.Build(nil, nil)
hosts := func(proto uint8, key int32) []string {
@@ -252,7 +253,7 @@ func TestRulesBuilder_protoIndex(t *testing.T) {
assert.False(t, rules.In.protos[47].hasPorts)
assert.Equal(t, []string{"any"}, hosts(47, PortAny))
assert.Equal(t, []string{"any"}, hosts(47, 22))
assert.Equal(t, []string{"any"}, hosts(47, PortFragment))
assert.Equal(t, []string{"any", "gre"}, hosts(47, PortFragment))
assert.Equal(t, []string{"any"}, hosts(iputil.IPProtocolICMP, PortFragment))
// Protocols without rules of their own share an index of the proto `any` rules: one for protocols with