Skip to content

fix(arm): read NSG rules from the securityRules property and child resources - #11663

Merged
nikpivkin merged 3 commits into
aquasecurity:mainfrom
aneviaro:fix/arm-nsg-rules
Nov 23, 2026
Merged

nikpivkin merged 3 commits into
aquasecurity:mainfrom
aneviaro:fix/arm-nsg-rules

Conversation

@aneviaro

@aneviaro aneviaro commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

The network adapter read only top-level Microsoft.Network/networkSecurityGroups/securityRules resources, and gave each of them to every NSG in the template. Rules in the NSG's properties.securityRules (the most common form) and rules declared as child resources were ignored.

Now each NSG gets:

  • the rules in its properties.securityRules;
  • its securityRules children, nested or top-level with a <nsg name>/<rule name> name, through GetChildResources.

A top-level rule whose name or NSG name is an expression goes to an NSG with unmanaged metadata, like orphan rules in the Terraform adapter. The rule checks still report it.

The empty and complete test cases declared an NSG and a top-level rule without names, so the rule now goes to the orphan group. I gave them the names nsg and nsg/rule, so the cases still test how rule properties are mapped on a managed group.

Before and after, scanning the template from #11655 (trivy config --skip-check-update .):

main:      Failures: 10
this PR:   Failures: 12
+ AZU-0047 (CRITICAL): Security group rule allows unrestricted ingress from any IP address.
+ AZU-0050 (CRITICAL): Security group rule allows unrestricted ingress to SSH port from any IP address.

AZU-0048 (RDP from the internet) fires the same way for an inline rule on port 3389.

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

🤖 Generated with Claude Code

@aneviaro
aneviaro requested a review from nikpivkin as a code owner November 17, 2026 13:38
@aneviaro
aneviaro force-pushed the fix/arm-nsg-rules branch 4 times, most recently from 20386bc to 4efe4ed Compare November 18, 2026 13:31
@aneviaro

Copy link
Copy Markdown
Contributor Author

@nikpivkin could you please review this bugfix as well? 🙏

@nikpivkin

Copy link
Copy Markdown
Contributor

#11662 is merged, but this branch still has its commits, so the diff has extra changes. Please rebase onto main.

@nikpivkin nikpivkin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@nikpivkin
nikpivkin added this pull request to the merge queue Nov 23, 2026
Merged via the queue into aquasecurity:main with commit f320e69 Nov 23, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(arm): adapter ignores NSG rules declared in the security group

2 participants