github.com/aquasecurity/trivy-iac@v0.8.1-0.20240127024015-3d8e412cf0ab/pkg/scanners/cloudformation/parser/fn_length.go (about)

     1  package parser
     2  
     3  import "github.com/aquasecurity/trivy-iac/pkg/scanners/cloudformation/cftypes"
     4  
     5  func ResolveLength(property *Property) (*Property, bool) {
     6  	if !property.isFunction() {
     7  		return property, true
     8  	}
     9  
    10  	val := property.AsMap()["Fn::Length"]
    11  	if val.IsList() {
    12  		return property.deriveResolved(cftypes.Int, val.Len()), true
    13  	} else if val.IsMap() {
    14  		resolved, _ := val.resolveValue()
    15  
    16  		if resolved.IsList() {
    17  			return property.deriveResolved(cftypes.Int, resolved.Len()), true
    18  		}
    19  		return resolved, false
    20  	}
    21  
    22  	return property, false
    23  
    24  }