github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/internal/adapters/cloudformation/aws/sam/tables.go (about) 1 package sam 2 3 import ( 4 "github.com/khulnasoft-lab/defsec/pkg/providers/aws/sam" 5 "github.com/khulnasoft-lab/defsec/pkg/scanners/cloudformation/parser" 6 defsecTypes "github.com/khulnasoft-lab/defsec/pkg/types" 7 ) 8 9 func getSimpleTables(cfFile parser.FileContext) (tables []sam.SimpleTable) { 10 11 tableResources := cfFile.GetResourcesByType("AWS::Serverless::SimpleTable") 12 for _, r := range tableResources { 13 table := sam.SimpleTable{ 14 Metadata: r.Metadata(), 15 TableName: r.GetStringProperty("TableName"), 16 SSESpecification: getSSESpecification(r), 17 } 18 19 tables = append(tables, table) 20 } 21 22 return tables 23 } 24 25 func getSSESpecification(r *parser.Resource) sam.SSESpecification { 26 27 spec := sam.SSESpecification{ 28 Metadata: r.Metadata(), 29 Enabled: defsecTypes.BoolDefault(false, r.Metadata()), 30 KMSMasterKeyID: defsecTypes.StringDefault("", r.Metadata()), 31 } 32 33 if sse := r.GetProperty("SSESpecification"); sse.IsNotNil() { 34 spec = sam.SSESpecification{ 35 Metadata: sse.Metadata(), 36 Enabled: sse.GetBoolProperty("SSEEnabled"), 37 KMSMasterKeyID: sse.GetStringProperty("KMSMasterKeyID"), 38 } 39 } 40 41 return spec 42 }