mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-12 07:40:48 -08:00
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:
@@ -176,8 +176,10 @@ func adaptAccount(resource *terraform.Block) storage.Account {
|
|||||||
account.NetworkRules = append(account.NetworkRules, adaptNetworkRule(networkBlock))
|
account.NetworkRules = append(account.NetworkRules, adaptNetworkRule(networkBlock))
|
||||||
}
|
}
|
||||||
|
|
||||||
httpsOnlyAttr := resource.GetAttribute("enable_https_traffic_only")
|
account.EnforceHTTPS = resource.GetFirstAttributeOf(
|
||||||
account.EnforceHTTPS = httpsOnlyAttr.AsBoolValueOrDefault(true, resource)
|
"enable_https_traffic_only",
|
||||||
|
"https_traffic_only_enabled", // provider above version 4
|
||||||
|
).AsBoolValueOrDefault(true, resource)
|
||||||
|
|
||||||
// Adapt blob properties
|
// Adapt blob properties
|
||||||
blobPropertiesBlock := resource.GetBlock("blob_properties")
|
blobPropertiesBlock := resource.GetBlock("blob_properties")
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import (
|
|||||||
|
|
||||||
"github.com/aquasecurity/trivy/pkg/iac/terraform/context"
|
"github.com/aquasecurity/trivy/pkg/iac/terraform/context"
|
||||||
iacTypes "github.com/aquasecurity/trivy/pkg/iac/types"
|
iacTypes "github.com/aquasecurity/trivy/pkg/iac/types"
|
||||||
|
"github.com/aquasecurity/trivy/pkg/set"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Block struct {
|
type Block struct {
|
||||||
@@ -303,11 +304,18 @@ func (b *Block) GetAttributes() []*Attribute {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Block) GetAttribute(name string) *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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nameSet := set.New(names...)
|
||||||
|
|
||||||
for _, attr := range b.attributes {
|
for _, attr := range b.attributes {
|
||||||
if attr.Name() == name {
|
if ok := nameSet.Contains(attr.Name()); ok {
|
||||||
return attr
|
return attr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user