Skip to content

Commit

Permalink
Add explanation for any
Browse files Browse the repository at this point in the history
  • Loading branch information
Satyam Sinha committed Feb 10, 2022
1 parent c49d335 commit b1ea7ff
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apoxfrm/libs/networkpolicies/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 257,10 @@ func intersect(a []string, b []string) []string {
set1 = append(set1, pp "/1:65535")
} else if !strings.EqualFold(pp, protocols.ANY) {
set1 = append(set1, pp)
} else {
// If we find any, just reset the set
set1 = make([]string, 0)
break
}
}
set2 := make([]string, 0)
Expand All @@ -265,6 269,10 @@ func intersect(a []string, b []string) []string {
set2 = append(set2, pp "/1:65535")
} else if !strings.EqualFold(pp, protocols.ANY) {
set2 = append(set2, pp)
} else {
// If we find any, just reset the set
set2 = make([]string, 0)
break
}
}

Expand Down
16 changes: 16 additions & 0 deletions apoxfrm/libs/networkpolicies/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 128,14 @@ func Test_intersect(t *testing.T) {
args args
want []string
}{
{
name: "any with something",
args: args{
a: []string{"any", "udp/53"},
b: []string{},
},
want: []string{},
},
{
name: "any and udp",
args: args{
Expand All @@ -144,6 152,14 @@ func Test_intersect(t *testing.T) {
},
want: []string{"TCP/22"},
},
{
name: "any with something and udp",
args: args{
a: []string{"any", "udp/1:65535"},
b: []string{"udp/53"},
},
want: []string{"UDP/53"},
},
{
name: "any in external-network",
args: args{
Expand Down

0 comments on commit b1ea7ff

Please sign in to comment.