Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
martinhny committed Feb 6, 2025
1 parent 7bb4598 commit 8ceafbf
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkg/resourcegenerator/networkpolicy/dynamic/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"regexp"
"net"
"slices"
"strings"
)
Expand All @@ -19,8 +19,6 @@ func init() {
multiGenerator.Register(reconciliation.JobType, generateForCommon)
}

var ipAddress = regexp.MustCompile("^((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$")

// TODO fix mess
func generateForCommon(r reconciliation.Reconciliation) error {
ctxLog := r.GetLogger()
Expand Down Expand Up @@ -98,7 +96,7 @@ func getEgressRules(accessPolicy *podtypes.AccessPolicy, appNamespace string) []
}

for _, externalRule := range accessPolicy.Outbound.External {
if externalRule.Ports == nil || externalRule.Ip == "" || !ipAddress.MatchString(externalRule.Ip) {
if externalRule.Ports == nil || externalRule.Ip == "" || net.ParseIP(externalRule.Ip) == nil {
continue
}
egressRules = append(egressRules, getIPExternalRule(externalRule))
Expand Down

0 comments on commit 8ceafbf

Please sign in to comment.