github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/pkg/providers/aws/cloudwatch/cloudwatch.go (about) 1 package cloudwatch 2 3 import ( 4 defsecTypes "github.com/khulnasoft-lab/defsec/pkg/types" 5 ) 6 7 type CloudWatch struct { 8 LogGroups []LogGroup 9 Alarms []Alarm 10 } 11 12 func (w CloudWatch) GetLogGroupByArn(arn string) (logGroup *LogGroup) { 13 for _, logGroup := range w.LogGroups { 14 if logGroup.Arn.EqualTo(arn) { 15 return &logGroup 16 } 17 } 18 return nil 19 } 20 21 func (w CloudWatch) GetAlarmByMetricName(metricName string) (alarm *Alarm) { 22 for _, alarm := range w.Alarms { 23 if alarm.MetricName.EqualTo(metricName) { 24 return &alarm 25 } 26 } 27 return nil 28 } 29 30 type Alarm struct { 31 Metadata defsecTypes.Metadata 32 AlarmName defsecTypes.StringValue 33 MetricName defsecTypes.StringValue 34 Dimensions []AlarmDimension 35 Metrics []MetricDataQuery 36 } 37 38 type AlarmDimension struct { 39 Metadata defsecTypes.Metadata 40 Name defsecTypes.StringValue 41 Value defsecTypes.StringValue 42 } 43 44 type MetricFilter struct { 45 Metadata defsecTypes.Metadata 46 FilterName defsecTypes.StringValue 47 FilterPattern defsecTypes.StringValue 48 } 49 50 type MetricDataQuery struct { 51 Metadata defsecTypes.Metadata 52 Expression defsecTypes.StringValue 53 ID defsecTypes.StringValue 54 } 55 56 type LogGroup struct { 57 Metadata defsecTypes.Metadata 58 Arn defsecTypes.StringValue 59 Name defsecTypes.StringValue 60 KMSKeyID defsecTypes.StringValue 61 RetentionInDays defsecTypes.IntValue 62 MetricFilters []MetricFilter 63 }