github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/azure/container/configured_network_policy.go (about) 1 package container 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 CheckConfiguredNetworkPolicy = rules.Register( 12 scan.Rule{ 13 AVDID: "AVD-AZU-0043", 14 Provider: providers.AzureProvider, 15 Service: "container", 16 ShortCode: "configured-network-policy", 17 Summary: "Ensure AKS cluster has Network Policy configured", 18 Impact: "No network policy is protecting the AKS cluster", 19 Resolution: "Configure a network policy", 20 Explanation: `The Kubernetes object type NetworkPolicy should be defined to have opportunity allow or block traffic to pods, as in a Kubernetes cluster configured with default settings, all pods can discover and communicate with each other without any restrictions.`, 21 Links: []string{ 22 "https://kubernetes.io/docs/concepts/services-networking/network-policies", 23 }, 24 Terraform: &scan.EngineMetadata{ 25 GoodExamples: terraformConfiguredNetworkPolicyGoodExamples, 26 BadExamples: terraformConfiguredNetworkPolicyBadExamples, 27 Links: terraformConfiguredNetworkPolicyLinks, 28 RemediationMarkdown: terraformConfiguredNetworkPolicyRemediationMarkdown, 29 }, 30 Severity: severity.High, 31 }, 32 func(s *state.State) (results scan.Results) { 33 for _, cluster := range s.Azure.Container.KubernetesClusters { 34 if cluster.NetworkProfile.NetworkPolicy.IsEmpty() { 35 results.Add( 36 "Kubernetes cluster does not have a network policy set.", 37 cluster.NetworkProfile.NetworkPolicy, 38 ) 39 } else { 40 results.AddPassed(&cluster) 41 } 42 } 43 return 44 }, 45 )