feat(misconf): support https_traffic_only_enabled in Az storage account (#9784)

Signed-off-by: nikpivkin <nikita.pivkin@smartforce.io>
This commit is contained in:
Nikita Pivkin
2025-11-19 08:03:10 +06:00
committed by GitHub
parent 9da33b5aed
commit c8d5ab7690
2 changed files with 14 additions and 4 deletions

View File

@@ -176,8 +176,10 @@ func adaptAccount(resource *terraform.Block) storage.Account {
account.NetworkRules = append(account.NetworkRules, adaptNetworkRule(networkBlock))
}
httpsOnlyAttr := resource.GetAttribute("enable_https_traffic_only")
account.EnforceHTTPS = httpsOnlyAttr.AsBoolValueOrDefault(true, resource)
account.EnforceHTTPS = resource.GetFirstAttributeOf(
"enable_https_traffic_only",
"https_traffic_only_enabled", // provider above version 4
).AsBoolValueOrDefault(true, resource)
// Adapt blob properties
blobPropertiesBlock := resource.GetBlock("blob_properties")

View File

@@ -16,6 +16,7 @@ import (
"github.com/aquasecurity/trivy/pkg/iac/terraform/context"
iacTypes "github.com/aquasecurity/trivy/pkg/iac/types"
"github.com/aquasecurity/trivy/pkg/set"
)
type Block struct {
@@ -303,11 +304,18 @@ func (b *Block) GetAttributes() []*Attribute {
}
func (b *Block) GetAttribute(name string) *Attribute {
if b == nil || b.hclBlock == nil {
return b.GetFirstAttributeOf(name)
}
func (b *Block) GetFirstAttributeOf(names ...string) *Attribute {
if b == nil || b.hclBlock == nil || len(names) == 0 {
return nil
}
nameSet := set.New(names...)
for _, attr := range b.attributes {
if attr.Name() == name {
if ok := nameSet.Contains(attr.Name()); ok {
return attr
}
}