简体   繁体   English

网络安全组规则审核 (Azure)

[英]Network Security Group Rule Audit (Azure)

I wondered if anyone has found a way to audit network security groups in Azure, other than trawl through them all in the Azure UI.我想知道是否有人找到了一种方法来审核 Azure 中的网络安全组,而不是在 Azure UI 中对它们进行全面搜索。 I have managed to extract info as json, but still its not terribly easy to decipher as its nested quite deeply.我已经设法将信息提取为 json,但它仍然不是很容易破译,因为它嵌套得很深。 Im looking for NSG's with default any/any rules and other poorly applied rules.我正在寻找具有默认任何/任何规则和其他应用不佳的规则的 NSG。

We have several hundred Network Security Groups (to give context).我们有数百个网络安全组(提供上下文)。

Anyone have any views how best to go about this?任何人有任何意见如何最好地 go 关于这个?

Depending on what you would like to audit in your NSG security rules, the Azure Resource Graph may be more friendly than exporting the the JSON and parsing.根据您希望在 NSG 安全规则中审核的内容,Azure 资源图可能比导出 JSON 和解析更友好。 It can be called via the REST API, for example from a Logic App, for regular audits.它可以通过 REST API(例如从逻辑应用程序)调用,以进行定期审计。

A simple query for NSGs with security rules allowing traffic to port 22 is below:下面是对具有允许流量到端口 22 的安全规则的 NSG 的简单查询:

az graph query -q "where type == 'microsoft.network/networksecuritygroups' | extend rules = properties.securityRules | mv-expand rules | where rules.properties.destinationPortRanges contains '22' | summarize count() by id" 

Another approach to consider would be to use Azure Policy to audit security rules for specific exceptions.要考虑的另一种方法是使用 Azure 策略来审核特定异常的安全规则。

Lastly, if you are more interested in monitoring changes made to your NSGs than specific exceptions, the Resource Change History feature may be what you are looking for.最后,如果您对监视对 NSG 所做的更改比对特定例外更感兴趣,那么您可能正在寻找资源更改历史记录功能。 You can target specific resources and review changes over a time window.您可以针对特定资源并查看一段时间内的更改 window。 Doing so would require some automation on your part, calling the Rest API, etc. See: https://docs.microsoft.com/en-us/azure/governance/resource-graph/how-to/get-resource-changes这样做需要您进行一些自动化,调用 Rest API 等。请参阅: https/docs.microsoft.com/ en-graphs/how-to-to

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM