github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/aws/rds/enable_performance_insights_encryption.go (about) 1 package rds 2 3 import ( 4 "github.com/khulnasoft-lab/defsec/internal/rules" 5 "github.com/khulnasoft-lab/defsec/pkg/providers" 6 "github.com/khulnasoft-lab/defsec/pkg/scan" 7 "github.com/khulnasoft-lab/defsec/pkg/severity" 8 "github.com/khulnasoft-lab/defsec/pkg/state" 9 ) 10 11 var CheckEnablePerformanceInsightsEncryption = rules.Register( 12 scan.Rule{ 13 AVDID: "AVD-AWS-0078", 14 Provider: providers.AWSProvider, 15 Service: "rds", 16 ShortCode: "enable-performance-insights-encryption", 17 Summary: "Encryption for RDS Performance Insights should be enabled.", 18 Impact: "Data can be read from the RDS Performance Insights if it is compromised", 19 Resolution: "Enable encryption for RDS clusters and instances", 20 Explanation: `When enabling Performance Insights on an RDS cluster or RDS DB Instance, and encryption key should be provided. 21 22 The encryption key specified in ` + "`" + `performance_insights_kms_key_id` + "`" + ` references a KMS ARN`, 23 Links: []string{ 24 "https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.Encryption.htm", 25 }, 26 Terraform: &scan.EngineMetadata{ 27 GoodExamples: terraformEnablePerformanceInsightsEncryptionGoodExamples, 28 BadExamples: terraformEnablePerformanceInsightsEncryptionBadExamples, 29 Links: terraformEnablePerformanceInsightsEncryptionLinks, 30 RemediationMarkdown: terraformEnablePerformanceInsightsEncryptionRemediationMarkdown, 31 }, 32 CloudFormation: &scan.EngineMetadata{ 33 GoodExamples: cloudFormationEnablePerformanceInsightsEncryptionGoodExamples, 34 BadExamples: cloudFormationEnablePerformanceInsightsEncryptionBadExamples, 35 Links: cloudFormationEnablePerformanceInsightsEncryptionLinks, 36 RemediationMarkdown: cloudFormationEnablePerformanceInsightsEncryptionRemediationMarkdown, 37 }, 38 Severity: severity.High, 39 }, 40 func(s *state.State) (results scan.Results) { 41 for _, cluster := range s.AWS.RDS.Clusters { 42 for _, instance := range cluster.Instances { 43 if instance.Metadata.IsUnmanaged() { 44 continue 45 } 46 if instance.PerformanceInsights.Enabled.IsFalse() { 47 continue 48 } else if instance.PerformanceInsights.KMSKeyID.IsEmpty() { 49 results.Add( 50 "Instance has performance insights enabled without encryption.", 51 instance.PerformanceInsights.KMSKeyID, 52 ) 53 } else { 54 results.AddPassed(&instance) 55 } 56 } 57 } 58 for _, instance := range s.AWS.RDS.Instances { 59 if instance.Metadata.IsUnmanaged() { 60 continue 61 } 62 if instance.PerformanceInsights.Enabled.IsFalse() { 63 continue 64 } else if instance.PerformanceInsights.KMSKeyID.IsEmpty() { 65 results.Add( 66 "Instance has performance insights enabled without encryption.", 67 instance.PerformanceInsights.KMSKeyID, 68 ) 69 } else { 70 results.AddPassed(&instance) 71 } 72 } 73 74 return 75 }, 76 )