Repository navigation
fix(misconf): evaluate Azure storage queue logging flags - #11747
Adham-Kiwan wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
|
nikpivkin
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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])
}
}|
|
||
| } | ||
|
|
||
| func Test_AdaptQueueLogging(t *testing.T) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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>
|
@nikpivkin You're right. I corrected the description to explain how it differs from ARM when all flags are |
Description
Fixes two problems with Azure storage queue logging in the Terraform adapter. Both affect AZU-0009 and AZU-0057.
EnableLoggingwastruewhenever an inlinequeue_properties.loggingblock existed, even withread,writeanddeleteallfalse. It is nowtrueonly when at least one of them istrue. When all three arefalse, it isfalse, so the checks report a finding. This differs from the ARM adapter, which leavesEnableLoggingunresolvable in that case. If none is known to betruebut one is unknown (for example a variable without a value), the result is unresolvable rather thanfalse.azurerm_storage_account_queue_propertiesresource was ignored. It is now read when the account has no inlinequeue_properties.loggingblock, usingstorage_account_id, in the same way the adapter already handlesazurerm_storage_account_customer_managed_key.The inline block and the standalone resource now share one function,
adaptQueueProperties.Before and after
Running
trivy config(built frommainand from this branch, with the embedded checks) on the two configurations in #11738:falseTesting
Test_Adaptfor the inline block and the standalone resource, including nologgingblock and a resource that belongs to another account.TestQueuePropertiesResourceLineschecks that the values and their line ranges come from the standalone resource, andTest_AdaptUnresolvableQueueLoggingcovers an unknown flag. Without the fix, three of the newTest_Adaptcases 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
🤖 Generated with Claude Code