Skip to content

fix(misconf): evaluate Azure storage queue logging flags - #11747

Open
Adham-Kiwan wants to merge 2 commits into
aquasecurity:mainfrom
Adham-Kiwan:fix/azure-queue-logging
Open

Adham-Kiwan wants to merge 2 commits into
aquasecurity:mainfrom
Adham-Kiwan:fix/azure-queue-logging

Conversation

@Adham-Kiwan

@Adham-Kiwan Adham-Kiwan commented Nov 25, 2026 •

Copy link
Copy Markdown

Description

Fixes two problems with Azure storage queue logging in the Terraform adapter. Both affect AZU-0009 and AZU-0057.

  1. False negative: EnableLogging was true whenever an inline queue_properties.logging block existed, even with read, write and delete all false. It is now true only when at least one of them is true. When all three are false, it is false, so the checks report a finding. This differs from the ARM adapter, which leaves EnableLogging unresolvable in that case. If none is known to be true but one is unknown (for example a variable without a value), the result is unresolvable rather than false.
  2. False positive: the azurerm_storage_account_queue_properties resource was ignored. It is now read when the account has no inline queue_properties.logging block, using storage_account_id, in the same way the adapter already handles azurerm_storage_account_customer_managed_key.

The inline block and the standalone resource now share one function, adaptQueueProperties.

Before and after

Running trivy config (built from main and from this branch, with the embedded checks) on the two configurations in #11738:

Configuration Before: failing checks After: failing checks
Inline block, all flags false none AZU-0009, AZU-0057
Standalone resource, logging enabled AZU-0009, AZU-0057 none

Testing

  • Added six cases to Test_Adapt for the inline block and the standalone resource, including no logging block and a resource that belongs to another account. TestQueuePropertiesResourceLines checks that the values and their line ranges come from the standalone resource, and Test_AdaptUnresolvableQueueLogging covers an unknown flag. Without the fix, three of the new Test_Adapt cases and both new test functions fail.
  • go test ./pkg/iac/adapters/... ./pkg/iac/providers/... passes, and golangci-lint v2.14.0 reports no issues for the changed package.

I did not run the full unit or integration suites.

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). Not needed.
  • I've added usage information (if the PR introduces new options). No 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

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Nov 25, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

The description says the new logic matches the ARM adapter. ARM keeps EnableLogging unresolvable when all three flags are false, so the checks pass there. With this PR, Terraform gives an explicit false and a finding. Fix this sentence in the description.

}
account.Queues = append(account.Queues, queue)
}
// Adapt queue properties resource

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.

Nit. The loop with break can be a simple index check, and the first comment line only repeats the code:

// Only use the resource if the inline block did not set logging (they are mutually exclusive in Terraform)
if resource.GetBlock("queue_properties").GetBlock("logging").IsNil() {
	if res := module.GetReferencingResources(resource, "azurerm_storage_account_queue_properties", "storage_account_id"); len(res) > 0 {
		account.QueueProperties = adaptQueueProperties(res[0])
	}
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Applied, thanks.


}

func Test_AdaptQueueLogging(t *testing.T) {

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.

This test checks only EnableLogging, so it does not show that Logging and its metadata come from azurerm_storage_account_queue_properties. Move these cases into Test_Adapt with the full expected storage.Storage, like the other cases in this file.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Moved the cases into Test_Adapt with the full expected structs. Since AssertDefsecEqual ignores metadata, I added TestQueuePropertiesResourceLines to check the line ranges, and kept a separate test for the unknown value.

}
for _, flag := range flags {
if !flag.GetMetadata().IsResolvable() {
return iacTypes.BoolUnresolvable(logging.Metadata)

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.

AZU-0009 currently treats an unresolvable value as false and fails. This is fixed on the checks side in aquasecurity/trivy-checks#671, so nothing to change here.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Adham-Kiwan

Copy link
Copy Markdown
Author

@nikpivkin You're right. I corrected the description to explain how it differs from ARM when all flags are false.

This branch has not been deployed

No deployments
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(terraform): queue logging ignores logging flags and the azurerm_storage_account_queue_properties resource

3 participants