github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/google/gke/enable_stackdriver_logging.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 CheckEnableStackdriverLogging = rules.Register( 12 scan.Rule{ 13 AVDID: "AVD-GCP-0060", 14 Provider: providers.GoogleProvider, 15 Service: "gke", 16 ShortCode: "enable-stackdriver-logging", 17 Summary: "Stackdriver Logging should be enabled", 18 Impact: "Visibility will be reduced", 19 Resolution: "Enable StackDriver logging", 20 Explanation: `StackDriver logging provides a useful interface to all of stdout/stderr for each container and should be enabled for moitoring, debugging, etc.`, 21 Links: []string{}, 22 Terraform: &scan.EngineMetadata{ 23 GoodExamples: terraformEnableStackdriverLoggingGoodExamples, 24 BadExamples: terraformEnableStackdriverLoggingBadExamples, 25 Links: terraformEnableStackdriverLoggingLinks, 26 RemediationMarkdown: terraformEnableStackdriverLoggingRemediationMarkdown, 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.LoggingService.NotEqualTo("logging.googleapis.com/kubernetes") { 36 results.Add( 37 "Cluster does not use the logging.googleapis.com/kubernetes StackDriver logging service.", 38 cluster.LoggingService, 39 ) 40 } else { 41 results.AddPassed(&cluster) 42 } 43 44 } 45 return 46 }, 47 )