github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/google/gke/enable_ip_aliasing.go (about) 1 package gke 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 CheckEnableIpAliasing = rules.Register( 12 scan.Rule{ 13 AVDID: "AVD-GCP-0049", 14 Provider: providers.GoogleProvider, 15 Service: "gke", 16 ShortCode: "enable-ip-aliasing", 17 Summary: "Clusters should have IP aliasing enabled", 18 Impact: "Nodes need a NAT gateway to access local services", 19 Resolution: "Enable IP aliasing", 20 Explanation: `IP aliasing allows the reuse of public IPs internally, removing the need for a NAT gateway.`, 21 Links: []string{}, 22 Terraform: &scan.EngineMetadata{ 23 GoodExamples: terraformEnableIpAliasingGoodExamples, 24 BadExamples: terraformEnableIpAliasingBadExamples, 25 Links: terraformEnableIpAliasingLinks, 26 RemediationMarkdown: terraformEnableIpAliasingRemediationMarkdown, 27 }, 28 Severity: severity.Low, 29 }, 30 func(s *state.State) (results scan.Results) { 31 for _, cluster := range s.Google.GKE.Clusters { 32 if cluster.Metadata.IsUnmanaged() { 33 continue 34 } 35 if cluster.IPAllocationPolicy.Enabled.IsFalse() { 36 results.Add( 37 "Cluster has IP aliasing disabled.", 38 cluster.IPAllocationPolicy.Enabled, 39 ) 40 } else { 41 results.AddPassed(&cluster) 42 } 43 44 } 45 return 46 }, 47 )