github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/aws/redshift/use_vpc.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 CheckUsesVPC = rules.Register( 12 scan.Rule{ 13 AVDID: "AVD-AWS-0127", 14 Provider: providers.AWSProvider, 15 Service: "redshift", 16 ShortCode: "use-vpc", 17 Summary: "Redshift cluster should be deployed into a specific VPC", 18 Impact: "Redshift cluster does not benefit from VPC security if it is deployed in EC2 classic mode", 19 Resolution: "Deploy Redshift cluster into a non default VPC", 20 Explanation: `Redshift clusters that are created without subnet details will be created in EC2 classic mode, meaning that they will be outside of a known VPC and running in tennant. 21 22 In order to benefit from the additional security features achieved with using an owned VPC, the subnet should be set.`, 23 Links: []string{ 24 "https://docs.aws.amazon.com/redshift/latest/mgmt/managing-clusters-vpc.html", 25 }, 26 Terraform: &scan.EngineMetadata{ 27 GoodExamples: terraformUseVpcGoodExamples, 28 BadExamples: terraformUseVpcBadExamples, 29 Links: terraformUseVpcLinks, 30 RemediationMarkdown: terraformUseVpcRemediationMarkdown, 31 }, 32 CloudFormation: &scan.EngineMetadata{ 33 GoodExamples: cloudFormationUseVpcGoodExamples, 34 BadExamples: cloudFormationUseVpcBadExamples, 35 Links: cloudFormationUseVpcLinks, 36 RemediationMarkdown: cloudFormationUseVpcRemediationMarkdown, 37 }, 38 Severity: severity.High, 39 }, 40 func(s *state.State) (results scan.Results) { 41 for _, cluster := range s.AWS.Redshift.Clusters { 42 if cluster.SubnetGroupName.IsEmpty() { 43 results.Add( 44 "Cluster is deployed outside of a VPC.", 45 cluster.SubnetGroupName, 46 ) 47 } else { 48 results.AddPassed(&cluster) 49 } 50 } 51 return 52 }, 53 )