github.com/aquasecurity/trivy-iac@v0.8.1-0.20240127024015-3d8e412cf0ab/pkg/scanners/cloudformation/parser/fn_and.go (about) 1 package parser 2 3 import "github.com/aquasecurity/trivy-iac/pkg/scanners/cloudformation/cftypes" 4 5 func ResolveAnd(property *Property) (resolved *Property, success bool) { 6 if !property.isFunction() { 7 return property, true 8 } 9 10 refValue := property.AsMap()["Fn::And"].AsList() 11 12 if len(refValue) < 2 { 13 return abortIntrinsic(property, "Fn::And should have at least 2 values, returning original Property") 14 } 15 16 results := make([]bool, len(refValue)) 17 for i := 0; i < len(refValue); i++ { 18 19 r := false 20 if refValue[i].IsBool() { 21 r = refValue[i].AsBool() 22 } 23 24 results[i] = r 25 } 26 27 theSame := allSameStrings(results) 28 return property.deriveResolved(cftypes.Bool, theSame), true 29 } 30 31 func allSameStrings(a []bool) bool { 32 for i := 1; i < len(a); i++ { 33 if a[i] != a[0] { 34 return false 35 } 36 } 37 return true 38 }