@@ -19,14 +19,12 @@ deny[msga] {
19
19
gateway.metadata.name == vs_gw.name
20
20
get_namespace (gateway) == vs_gw.namespace
21
21
22
- # Find the connected Istio Ingress Gateway that should be a LoadBalancer if it is exposed to the internet
23
- istioingressgateway := input[_]
24
- istioingressgateway.kind == " Service"
25
- istioingressgateway.metadata.namespace == " istio-system"
26
- gateway.spec.selector[_] == istioingressgateway.metadata.labels[_]
22
+ # print("Found the gateway that the virtualservice is connected to", gateway)
27
23
28
- # Check if the Istio Ingress Gateway is exposed to the internet
29
- is_exposed_service (istioingressgateway)
24
+ # Either the gateway is exposed via LoadBalancer/n service OR has "public" suffix
25
+ is_gateway_public (gateway, input)
26
+
27
+ # print("Gateway is public", gateway)
30
28
31
29
# Check if the VirtualService is connected to an workload
32
30
# First, find the service that the VirtualService is connected to
@@ -40,15 +38,21 @@ deny[msga] {
40
38
# Check if the service is the target of the VirtualService
41
39
connected_service.metadata.name == target_name
42
40
41
+ # print("Found the service that the virtualservice is connected to", connected_service)
42
+
43
43
# Check if the service is connected to a workload
44
44
wl := input[_]
45
45
is_same_namespace (connected_service, wl)
46
46
spec_template_spec_patterns := {" Deployment" , " ReplicaSet" , " DaemonSet" , " StatefulSet" , " Pod" , " Job" , " CronJob" }
47
47
spec_template_spec_patterns[wl.kind]
48
48
wl_connected_to_service (wl, connected_service)
49
49
50
+ # print("Found the workload that the service is connected to", wl)
51
+
50
52
failedPaths := [sprintf (" spec.http[%d].routes[%d].destination.host" , [i,j])]
51
53
54
+ # print("Found the failed paths", failedPaths)
55
+
52
56
msga := {
53
57
" alertMessage" : sprintf (" workload '%v' is exposed through virtualservice '%v'" , [wl.metadata.name, virtualservice.metadata.name]),
54
58
" packagename" : " armo_builtins" ,
@@ -73,6 +77,18 @@ deny[msga] {
73
77
74
78
# ====================================================================================
75
79
80
+ is_gateway_public (gateway, inputs) {
81
+ endswith (gateway.metadata.name, " public" )
82
+ }
83
+
84
+ is_gateway_public (gateway, inputs) {
85
+ inputs[_].kind == " Service"
86
+ inputs[_].metadata.namespace == " istio-system"
87
+ gateway.spec.selector[_] == inputs[_].metadata.labels[_]
88
+ is_exposed_service (inputs[_])
89
+ }
90
+
91
+
76
92
get_namespace (obj) = namespace {
77
93
obj.metadata
78
94
obj.metadata.namespace
0 commit comments