github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/nifcloud/network/http_not_used.go (about) 1 package network 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 CheckHttpNotUsed = rules.Register( 12 scan.Rule{ 13 AVDID: "AVD-NIF-0021", 14 Provider: providers.NifcloudProvider, 15 Service: "network", 16 ShortCode: "http-not-used", 17 Summary: "Use of plain HTTP.", 18 Impact: "Your traffic is not protected", 19 Resolution: "Switch to HTTPS to benefit from TLS security features", 20 Explanation: `Plain HTTP is unencrypted and human-readable. This means that if a malicious actor was to eavesdrop on your connection, they would be able to see all of your data flowing back and forth. 21 22 You should use HTTPS, which is HTTP over an encrypted (TLS) connection, meaning eavesdroppers cannot read your traffic.`, 23 Links: []string{ 24 "https://www.cloudflare.com/en-gb/learning/ssl/why-is-http-not-secure/", 25 }, 26 Terraform: &scan.EngineMetadata{ 27 GoodExamples: terraformHttpNotUsedGoodExamples, 28 BadExamples: terraformHttpNotUsedBadExamples, 29 Links: terraformHttpNotUsedLinks, 30 RemediationMarkdown: terraformHttpNotUsedRemediationMarkdown, 31 }, 32 Severity: severity.Critical, 33 }, 34 func(s *state.State) (results scan.Results) { 35 for _, lb := range s.Nifcloud.Network.LoadBalancers { 36 for _, listener := range lb.Listeners { 37 if !listener.Protocol.EqualTo("HTTP") { 38 results.AddPassed(&listener) 39 continue 40 } 41 42 results.Add( 43 "Listener for l4 load balancer does not use HTTPS.", 44 listener.Protocol, 45 ) 46 } 47 } 48 for _, elb := range s.Nifcloud.Network.ElasticLoadBalancers { 49 var publicLB bool 50 for _, ni := range elb.NetworkInterfaces { 51 if ni.NetworkID.EqualTo("net-COMMON_GLOBAL") && ni.IsVipNetwork.IsTrue() { 52 publicLB = true 53 } 54 } 55 56 if !publicLB { 57 continue 58 } 59 60 for _, listener := range elb.Listeners { 61 if !listener.Protocol.EqualTo("HTTP") { 62 results.AddPassed(&listener) 63 continue 64 } 65 66 results.Add( 67 "Listener for multi load balancer does not use HTTPS.", 68 listener.Protocol, 69 ) 70 } 71 } 72 73 return 74 }, 75 )