github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/google/gke/enable_auto_repair.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 CheckEnableAutoRepair = rules.Register( 12 scan.Rule{ 13 AVDID: "AVD-GCP-0063", 14 Provider: providers.GoogleProvider, 15 Service: "gke", 16 ShortCode: "enable-auto-repair", 17 Summary: "Kubernetes should have 'Automatic repair' enabled", 18 Impact: "Failing nodes will require manual repair.", 19 Resolution: "Enable automatic repair", 20 Explanation: `Automatic repair will monitor nodes and attempt repair when a node fails multiple subsequent health checks`, 21 Links: []string{}, 22 Terraform: &scan.EngineMetadata{ 23 GoodExamples: terraformEnableAutoRepairGoodExamples, 24 BadExamples: terraformEnableAutoRepairBadExamples, 25 Links: terraformEnableAutoRepairLinks, 26 RemediationMarkdown: terraformEnableAutoRepairRemediationMarkdown, 27 }, 28 Severity: severity.Low, 29 }, 30 func(s *state.State) (results scan.Results) { 31 for _, cluster := range s.Google.GKE.Clusters { 32 for _, nodePool := range cluster.NodePools { 33 if nodePool.Management.EnableAutoRepair.IsFalse() { 34 results.Add( 35 "Node pool does not have auto-repair enabled.", 36 nodePool.Management.EnableAutoRepair, 37 ) 38 } else { 39 results.AddPassed(&nodePool) 40 } 41 } 42 } 43 return 44 }, 45 )