github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/azure/appservice/authentication_enabled.go (about) 1 package appservice 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 CheckAuthenticationEnabled = rules.Register( 12 scan.Rule{ 13 AVDID: "AVD-AZU-0003", 14 Provider: providers.AzureProvider, 15 Service: "appservice", 16 ShortCode: "authentication-enabled", 17 Summary: "App Service authentication is activated", 18 Impact: "Anonymous HTTP requests will be accepted", 19 Resolution: "Enable authentication to prevent anonymous request being accepted", 20 Explanation: `Enabling authentication ensures that all communications in the application are authenticated. The auth_settings block needs to be filled out with the appropriate auth backend settings`, 21 Links: []string{}, 22 Terraform: &scan.EngineMetadata{ 23 GoodExamples: terraformAuthenticationEnabledGoodExamples, 24 BadExamples: terraformAuthenticationEnabledBadExamples, 25 Links: terraformAuthenticationEnabledLinks, 26 RemediationMarkdown: terraformAuthenticationEnabledRemediationMarkdown, 27 }, 28 Severity: severity.Medium, 29 }, 30 func(s *state.State) (results scan.Results) { 31 for _, service := range s.Azure.AppService.Services { 32 if service.Metadata.IsUnmanaged() { 33 continue 34 } 35 if service.Authentication.Enabled.IsFalse() { 36 results.Add( 37 "App service does not have authentication enabled.", 38 service.Authentication.Enabled, 39 ) 40 } else { 41 results.AddPassed(&service) 42 } 43 } 44 return 45 }, 46 )