Skip to content

fix(arm): find blob containers and map their public access values - #11662

Merged
nikpivkin merged 8 commits into
aquasecurity:mainfrom
aneviaro:fix/arm-blob-containers
Nov 20, 2026
Merged

nikpivkin merged 8 commits into
aquasecurity:mainfrom
aneviaro:fix/arm-blob-containers

Conversation

@aneviaro

@aneviaro aneviaro commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

The storage adapter looked for the child type containerServices/containers, which isn't an Azure type, so it never found blob containers and AVD-AZU-0007 never fired.

This PR adds Deployment.GetChildResources and Deployment.GetOrphanResources, as suggested in #11655, and uses them for containers and queues:

  • GetChildResources(parent, childType) takes a full type or one relative to the parent (blobServices/containers). It walks the nested resources at any depth and builds the full type of each one from its parents, so short (containers under blobServices), multi-segment (blobServices/containers named default/<container> directly in the account) and full types all match. It also returns the top-level resources whose name starts with the parent name and /, and the children nested in them, such as containers nested in a top-level blobServices named sa/default. Types match case-insensitively.
  • When the child or parent name is an expression, the parser can't tell which parent the child belongs to. GetOrphanResources returns those top-level children, and the adapter puts them in a storage account with unmanaged metadata, as the Terraform adapter does. Checks on containers still report them, and checks on accounts skip that account.
  • ARM publicAccess (None, Blob, Container, any case) maps to the provider values (off, blob, container). A missing value defaults to off. Before, the adapter passed None through and also used it as the default, which AVD-AZU-0007 treats as public.
  • Queues (queueServices/queues) use the same lookup, so top-level queues are found too. A queue is named by the last segment of its name, top for sa/default/top, the same as a nested queue and the Terraform adapter.
  • Queue logging (EnableLogging) is now unresolvable instead of false. ARM configures it in a separate diagnostic settings resource, which the adapter doesn't read, so with false AVD-AZU-0009 would fire for every account with queues. AVD-AZU-0009 skips unresolvable values after fix(azu-0009): skip unresolvable queue logging trivy-checks#671.

Nested containers come first, then top-level ones in file order.

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

main:      Failures: 9
this PR:   Failures: 10
+ AZU-0007 (HIGH): Container allows public access.
+ AZU-0060 (MEDIUM): Storage account with blob containers should use customer-managed keys for encryption.
- AZU-0057 (MEDIUM): Storage account does not have logging enabled for any service.

The AZU-0057 change is expected: on main it fired for every ARM storage account, even one with logging configured, because the adapter set EnableLogging to false and never reads the diagnostic settings resource where ARM configures logging. With the field unresolvable, AZU-0057 skips it.

A private container ("publicAccess": "None") doesn't fire AZU-0007.

#11567 reads the blob soft delete policy from a nested blobServices resource and leaves the top-level form out. GetChildResources(account, "blobServices") would cover both, either there or in a follow-up.

Related issues

Related PRs

NSG rules and database firewall rules follow in the PRs above, on top of this one.

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

Comment thread pkg/iac/scanners/azure/deployment.go Resolved
Comment thread pkg/iac/scanners/azure/deployment.go Resolved
Comment thread pkg/iac/scanners/azure/deployment.go Resolved
Comment thread pkg/iac/scanners/azure/deployment.go Resolved
Comment thread pkg/iac/adapters/arm/storage/adapt.go Resolved
Comment thread pkg/iac/adapters/arm/storage/adapt.go Resolved
@aneviaro
aneviaro requested a review from nikpivkin November 18, 2026 12:49

@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.

With this change AVD-AZU-0009 fires for every ARM storage account that has queues in any form, because the adapter always sets EnableLogging to false. In ARM, queue logging is configured by a separate diagnostic settings resource, which the adapter does not read. EnableLogging could be created with types.BoolUnresolvable instead, and I'll update the check in trivy-checks to skip unresolvable values.

The description also says containers are returned in file order, but nested containers come first and top-level ones after them, so the order differs from the file when a top-level container is declared before its account.

Comment thread pkg/iac/adapters/arm/storage/adapt.go Resolved
Comment thread pkg/iac/adapters/arm/storage/adapt.go Resolved
Comment thread pkg/iac/scanners/azure/deployment.go Resolved
@aneviaro

Copy link
Copy Markdown
Contributor Author

Fixed in ae7151d: EnableLogging is now types.BoolUnresolvable, for accounts and the orphanage. One side effect: AZU-0057 no longer fires for an ARM account with no logging configured, since it reads the same field. I fixed the order sentence in the description.

@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 20, 2026
Merged via the queue into aquasecurity:main with commit c566097 Nov 20, 2026
16 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 does not find blob containers

2 participants