github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/pkg/providers/google/sql/sql.go (about) 1 package sql 2 3 import ( 4 "strings" 5 6 defsecTypes "github.com/khulnasoft-lab/defsec/pkg/types" 7 ) 8 9 type SQL struct { 10 Instances []DatabaseInstance 11 } 12 13 const ( 14 DatabaseFamilyMySQL = "MYSQL" 15 DatabaseFamilyPostgres = "POSTGRES" 16 DatabaseFamilySQLServer = "SQLSERVER" 17 ) 18 19 const ( 20 DatabaseVersionMySQL_5_6 = "MYSQL_5_6" 21 DatabaseVersionMySQL_5_7 = "MYSQL_5_7" 22 DatabaseVersionMySQL_8_0 = "MYSQL_8_0" 23 DatabaseVersionPostgres_9_6 = "POSTGRES_9_6" 24 DatabaseVersionPostgres_10 = "POSTGRES_10" 25 DatabaseVersionPostgres_11 = "POSTGRES_11" 26 DatabaseVersionPostgres_12 = "POSTGRES_12" 27 DatabaseVersionPostgres_13 = "POSTGRES_13" 28 DatabaseVersionSQLServer_2017_STANDARD = "SQLSERVER_2017_STANDARD" 29 DatabaseVersionSQLServer_2017_ENTERPRISE = "SQLSERVER_2017_ENTERPRISE" 30 DatabaseVersionSQLServer_2017_EXPRESS = "SQLSERVER_2017_EXPRESS" 31 DatabaseVersionSQLServer_2017_WEB = "SQLSERVER_2017_WEB" 32 ) 33 34 type DatabaseInstance struct { 35 Metadata defsecTypes.Metadata 36 DatabaseVersion defsecTypes.StringValue 37 Settings Settings 38 IsReplica defsecTypes.BoolValue 39 } 40 41 type Settings struct { 42 Metadata defsecTypes.Metadata 43 Flags Flags 44 Backups Backups 45 IPConfiguration IPConfiguration 46 } 47 type Flags struct { 48 Metadata defsecTypes.Metadata 49 LogTempFileSize defsecTypes.IntValue 50 LocalInFile defsecTypes.BoolValue 51 ContainedDatabaseAuthentication defsecTypes.BoolValue 52 CrossDBOwnershipChaining defsecTypes.BoolValue 53 LogCheckpoints defsecTypes.BoolValue 54 LogConnections defsecTypes.BoolValue 55 LogDisconnections defsecTypes.BoolValue 56 LogLockWaits defsecTypes.BoolValue 57 LogMinMessages defsecTypes.StringValue // FATAL, PANIC, LOG, ERROR, WARN 58 LogMinDurationStatement defsecTypes.IntValue 59 } 60 61 type Backups struct { 62 Metadata defsecTypes.Metadata 63 Enabled defsecTypes.BoolValue 64 } 65 66 type IPConfiguration struct { 67 Metadata defsecTypes.Metadata 68 RequireTLS defsecTypes.BoolValue 69 EnableIPv4 defsecTypes.BoolValue 70 AuthorizedNetworks []struct { 71 Name defsecTypes.StringValue 72 CIDR defsecTypes.StringValue 73 } 74 } 75 76 func (i *DatabaseInstance) DatabaseFamily() string { 77 return strings.Split(i.DatabaseVersion.Value(), "_")[0] 78 }