github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/google/compute/use_secure_tls_policy.go (about) 1 package compute 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 CheckUseSecureTlsPolicy = rules.Register( 12 scan.Rule{ 13 AVDID: "AVD-GCP-0039", 14 Provider: providers.GoogleProvider, 15 Service: "compute", 16 ShortCode: "use-secure-tls-policy", 17 Summary: "SSL policies should enforce secure versions of TLS", 18 Impact: "Data in transit is not sufficiently secured", 19 Resolution: "Enforce a minimum TLS version of 1.2", 20 Explanation: `TLS versions prior to 1.2 are outdated and insecure. You should use 1.2 as aminimum version.`, 21 Links: []string{}, 22 Terraform: &scan.EngineMetadata{ 23 GoodExamples: terraformUseSecureTlsPolicyGoodExamples, 24 BadExamples: terraformUseSecureTlsPolicyBadExamples, 25 Links: terraformUseSecureTlsPolicyLinks, 26 RemediationMarkdown: terraformUseSecureTlsPolicyRemediationMarkdown, 27 }, 28 Severity: severity.Critical, 29 }, 30 func(s *state.State) (results scan.Results) { 31 for _, policy := range s.Google.Compute.SSLPolicies { 32 if policy.Metadata.IsUnmanaged() { 33 continue 34 } 35 if policy.MinimumTLSVersion.NotEqualTo("TLS_1_2") { 36 results.Add( 37 "TLS policy does not specify a minimum of TLS 1.2", 38 policy.MinimumTLSVersion, 39 ) 40 } else { 41 results.AddPassed(&policy) 42 } 43 } 44 return 45 }, 46 )