github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/aws/redshift/encryption_customer_key.go (about)

     1  package redshift
     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 CheckEncryptionCustomerKey = rules.Register(
    12  	scan.Rule{
    13  		AVDID:       "AVD-AWS-0084",
    14  		Provider:    providers.AWSProvider,
    15  		Service:     "redshift",
    16  		ShortCode:   "encryption-customer-key",
    17  		Summary:     "Redshift clusters should use at rest encryption",
    18  		Impact:      "Data may be leaked if infrastructure is compromised",
    19  		Resolution:  "Enable encryption using CMK",
    20  		Explanation: `Redshift clusters that contain sensitive data or are subject to regulation should be encrypted at rest to prevent data leakage should the infrastructure be compromised.`,
    21  		Links: []string{
    22  			"https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-db-encryption.html",
    23  		},
    24  		Terraform: &scan.EngineMetadata{
    25  			GoodExamples:        terraformEncryptionCustomerKeyGoodExamples,
    26  			BadExamples:         terraformEncryptionCustomerKeyBadExamples,
    27  			Links:               terraformEncryptionCustomerKeyLinks,
    28  			RemediationMarkdown: terraformEncryptionCustomerKeyRemediationMarkdown,
    29  		},
    30  		CloudFormation: &scan.EngineMetadata{
    31  			GoodExamples:        cloudFormationEncryptionCustomerKeyGoodExamples,
    32  			BadExamples:         cloudFormationEncryptionCustomerKeyBadExamples,
    33  			Links:               cloudFormationEncryptionCustomerKeyLinks,
    34  			RemediationMarkdown: cloudFormationEncryptionCustomerKeyRemediationMarkdown,
    35  		},
    36  		Severity: severity.High,
    37  	},
    38  	func(s *state.State) (results scan.Results) {
    39  		for _, cluster := range s.AWS.Redshift.Clusters {
    40  			if cluster.Encryption.Enabled.IsFalse() {
    41  				results.Add(
    42  					"Cluster does not have encryption enabled.",
    43  					cluster.Encryption.Enabled,
    44  				)
    45  			} else if cluster.Encryption.KMSKeyID.IsEmpty() {
    46  				results.Add(
    47  					"Cluster does not use a customer managed encryption key.",
    48  					cluster.Encryption.KMSKeyID,
    49  				)
    50  			} else {
    51  				results.AddPassed(&cluster)
    52  			}
    53  		}
    54  		return
    55  	},
    56  )