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

     1  package msk
     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 CheckEnableAtRestEncryption = rules.Register(
    12  	scan.Rule{
    13  		AVDID:       "AVD-AWS-0179",
    14  		Provider:    providers.AWSProvider,
    15  		Service:     "msk",
    16  		ShortCode:   "enable-at-rest-encryption",
    17  		Summary:     "A MSK cluster allows unencrypted data at rest.",
    18  		Impact:      "Intercepted data can be read at rest",
    19  		Resolution:  "Enable at rest encryption",
    20  		Explanation: `Encryption should be forced for Kafka clusters, including at rest. This ensures sensitive data is kept private.`,
    21  		Links: []string{
    22  			"https://docs.aws.amazon.com/msk/latest/developerguide/msk-encryption.html",
    23  		},
    24  		Terraform: &scan.EngineMetadata{
    25  			GoodExamples:        terraformEnableAtRestEncryptionGoodExamples,
    26  			BadExamples:         terraformEnableAtRestEncryptionBadExamples,
    27  			Links:               terraformEnableAtRestEncryptionLinks,
    28  			RemediationMarkdown: terraformEnableAtRestEncryptionRemediationMarkdown,
    29  		},
    30  		CloudFormation: &scan.EngineMetadata{
    31  			GoodExamples:        cloudFormationEnableAtRestEncryptionGoodExamples,
    32  			BadExamples:         cloudFormationEnableAtRestEncryptionBadExamples,
    33  			Links:               cloudFormationEnableAtRestEncryptionLinks,
    34  			RemediationMarkdown: cloudFormationEnableAtRestEncryptionRemediationMarkdown,
    35  		},
    36  		Severity: severity.High,
    37  	},
    38  	func(s *state.State) (results scan.Results) {
    39  		for _, cluster := range s.AWS.MSK.Clusters {
    40  			if cluster.EncryptionAtRest.Enabled.IsFalse() {
    41  				results.Add("The cluster is not encrypted at rest.", cluster.EncryptionAtRest.Enabled)
    42  			} else {
    43  				results.AddPassed(&cluster)
    44  			}
    45  		}
    46  		return
    47  	},
    48  )