Skip to content

Commit bbe17e6

Browse files
committed
simplified logic
1 parent 894da23 commit bbe17e6

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

tools/azure-npm-to-cilium-validator/azure-npm-to-cilium-validator.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,8 @@ func checkServiceRisk(service *corev1.Service, policiesListAtNamespace []*networ
224224
for _, ingress := range policy.Spec.Ingress {
225225
// Check if there is an allow all ingress policy that matches labels the service is safe
226226
if len(ingress.From) == 0 && len(ingress.Ports) == 0 {
227-
// Check if there is an allow all ingress policy with empty selectors return true as the policy allows all services in the namespace
228-
if checkPolicySelectorsAreEmpty(&policy.Spec.PodSelector) {
229-
return true
230-
}
231-
// Check if there is an allow all ingress policy that matches the service labels
232-
if checkPolicyMatchServiceLabels(service.Spec.Selector, policy.Spec.PodSelector.MatchLabels) {
233-
// TODO add this to above logic and check in one if statement after i am done printing the logs
227+
// Check if there is an allow all ingress policy with empty selectors or matching service labels as the policy allows all services in the namespace
228+
if checkPolicySelectorsAreEmpty(&policy.Spec.PodSelector) || checkPolicyMatchServiceLabels(service.Spec.Selector, policy.Spec.PodSelector.MatchLabels) {
234229
return true
235230
}
236231
}

0 commit comments

Comments
 (0)