Skip to content

Commit

Permalink
Add namespace check for workload connection in gateway rules
Browse files Browse the repository at this point in the history
  • Loading branch information
kooomix committed Jan 14, 2025
1 parent 35e6dae commit 31c1dfb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rules/exposure-to-internet-via-gateway-api/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ is_exposed_service(svc) {
svc.spec.type == "LoadBalancer"
}


wl_connected_to_service(wl, svc) {
wl.metadata.namespace == svc.metadata.namespace
}

wl_connected_to_service(wl, svc) {
count({x | svc.spec.selector[x] == wl.metadata.labels[x]}) == count(svc.spec.selector)
}
Expand Down
5 changes: 5 additions & 0 deletions rules/exposure-to-internet-via-istio-ingress/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ is_exposed_service(svc) {
svc.spec.type == "LoadBalancer"
}


wl_connected_to_service(wl, svc) {
wl.metadata.namespace == svc.metadata.namespace
}

wl_connected_to_service(wl, svc) {
count({x | svc.spec.selector[x] == wl.metadata.labels[x]}) == count(svc.spec.selector)
}
Expand Down
5 changes: 5 additions & 0 deletions rules/unauthenticated-service/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ has_unauthenticated_service(service_name, namespace, service_scan_result) if {
service_scan_result.spec.ports[_].authenticated == false
}


wl_connected_to_service(wl, svc) {
wl.metadata.namespace == svc.metadata.namespace
}

wl_connected_to_service(wl, svc) if {
count({x | svc.spec.selector[x] == wl.metadata.labels[x]}) == count(svc.spec.selector)
}
Expand Down

0 comments on commit 31c1dfb

Please sign in to comment.