Azure / azure-policy

Repository for Azure Resource Policy built-in definitions and samples
MIT License
1.49k stars 1.08k forks source link

Creating a complex policy to cross-reference two array fields #1270

Open mbrijun opened 7 months ago

mbrijun commented 7 months ago

Hi,

I am looking for some advice on creating a complex policy which involves cross-referencing two fields of the same resource, each field being an array. A practical example I have in mind is checking if an Azure App Gateway has any public IP address that is tied to an HTTP Listener. This means we have to compare "properties.frontendIPConfigurations" with "properties.httpListeners" and the bond between the two is "properties.frontendIPConfigurations.id" -> "properties.httpListeners.properties.frontendIPConfiguration.id".

I was able to create a similar policy with Rego in Wiz, which compares two lists of frontendIPConfiguration IDs, one from "properties.frontendIPConfigurations" and the other from "properties.httpListeners". Any overlap between these two sets indicates an exposure on the public internet.

I hope the above makes sense. Thank you.