github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/azure/database/postgres_configuration_log_checkpoints.go (about) 1 package database 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 CheckPostgresConfigurationLogCheckpoints = rules.Register( 12 scan.Rule{ 13 AVDID: "AVD-AZU-0024", 14 Provider: providers.AzureProvider, 15 Service: "database", 16 ShortCode: "postgres-configuration-log-checkpoints", 17 Summary: "Ensure server parameter 'log_checkpoints' is set to 'ON' for PostgreSQL Database Server", 18 Impact: "No error and query logs generated on checkpoint", 19 Resolution: "Enable checkpoint logging", 20 Explanation: `Postgresql can generate logs for checkpoints to improve visibility for audit and configuration issue resolution.`, 21 Links: []string{ 22 "https://docs.microsoft.com/en-us/azure/postgresql/concepts-server-logs#configure-logging", 23 }, 24 Terraform: &scan.EngineMetadata{ 25 GoodExamples: terraformPostgresConfigurationLogCheckpointsGoodExamples, 26 BadExamples: terraformPostgresConfigurationLogCheckpointsBadExamples, 27 Links: terraformPostgresConfigurationLogCheckpointsLinks, 28 RemediationMarkdown: terraformPostgresConfigurationLogCheckpointsRemediationMarkdown, 29 }, 30 Severity: severity.Medium, 31 }, 32 func(s *state.State) (results scan.Results) { 33 for _, server := range s.Azure.Database.PostgreSQLServers { 34 if server.Metadata.IsUnmanaged() { 35 continue 36 } 37 if server.Config.LogCheckpoints.IsFalse() { 38 results.Add( 39 "Database server is not configured to log checkpoints.", 40 server.Config.LogCheckpoints, 41 ) 42 } else { 43 results.AddPassed(&server.Config) 44 } 45 } 46 return 47 }, 48 )