github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/pkg/scanners/cloudformation/parser/fn_join.go (about) 1 package parser 2 3 import ( 4 "strings" 5 6 "github.com/khulnasoft-lab/defsec/pkg/scanners/cloudformation/cftypes" 7 ) 8 9 func ResolveJoin(property *Property) (resolved *Property, success bool) { 10 if !property.isFunction() { 11 return property, true 12 } 13 14 refValue := property.AsMap()["Fn::Join"].AsList() 15 16 if len(refValue) != 2 { 17 return abortIntrinsic(property, "Fn::Join should have exactly 2 values, returning original Property") 18 } 19 20 joiner := refValue[0].AsString() 21 items := refValue[1].AsList() 22 23 var itemValues []string 24 for _, item := range items { 25 resolved, success := item.resolveValue() 26 if success { 27 itemValues = append(itemValues, resolved.AsString()) 28 } 29 } 30 31 joined := strings.Join(itemValues, joiner) 32 33 return property.deriveResolved(cftypes.String, joined), true 34 }