github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/aws/rds/encrypt_cluster_storage_data.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 CheckEncryptClusterStorageData = rules.Register( 12 scan.Rule{ 13 AVDID: "AVD-AWS-0079", 14 Provider: providers.AWSProvider, 15 Service: "rds", 16 ShortCode: "encrypt-cluster-storage-data", 17 Summary: "There is no encryption specified or encryption is disabled on the RDS Cluster.", 18 Impact: "Data can be read from the RDS cluster if it is compromised", 19 Resolution: "Enable encryption for RDS clusters", 20 Explanation: `Encryption should be enabled for an RDS Aurora cluster. 21 22 When enabling encryption by setting the kms_key_id, the storage_encrypted must also be set to true.`, 23 Links: []string{ 24 "https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.Encryption.html", 25 }, 26 Terraform: &scan.EngineMetadata{ 27 GoodExamples: terraformEncryptClusterStorageDataGoodExamples, 28 BadExamples: terraformEncryptClusterStorageDataBadExamples, 29 Links: terraformEncryptClusterStorageDataLinks, 30 RemediationMarkdown: terraformEncryptClusterStorageDataRemediationMarkdown, 31 }, 32 CloudFormation: &scan.EngineMetadata{ 33 GoodExamples: cloudFormationEncryptClusterStorageDataGoodExamples, 34 BadExamples: cloudFormationEncryptClusterStorageDataBadExamples, 35 Links: cloudFormationEncryptClusterStorageDataLinks, 36 RemediationMarkdown: cloudFormationEncryptClusterStorageDataRemediationMarkdown, 37 }, 38 Severity: severity.High, 39 }, 40 func(s *state.State) (results scan.Results) { 41 for _, cluster := range s.AWS.RDS.Clusters { 42 if cluster.Metadata.IsUnmanaged() { 43 continue 44 } 45 if cluster.Encryption.EncryptStorage.IsFalse() { 46 results.Add( 47 "Cluster does not have storage encryption enabled.", 48 cluster.Encryption.EncryptStorage, 49 ) 50 } else if cluster.Encryption.KMSKeyID.IsEmpty() { 51 results.Add( 52 "Cluster does not specify a customer managed key for storage encryption.", 53 cluster.Encryption.KMSKeyID, 54 ) 55 } else { 56 results.AddPassed(&cluster) 57 } 58 } 59 return 60 }, 61 )