@@ -57,35 +57,30 @@ function Test-ThreatDetectionDatabaseUpdatePolicy
57
57
{
58
58
# Test
59
59
Set-AzureRmSqlDatabaseAuditingPolicy - ResourceGroupName $params.rgname - ServerName $params.serverName - DatabaseName $params.databaseName - StorageAccountName $params.storageAccount
60
- Set-AzureRmSqlDatabaseThreatDetectionPolicy - ResourceGroupName
$params.rgname - ServerName
$params.serverName - DatabaseName
$params.databaseName - NotificationRecipientsEmails
" [email protected] ;[email protected] " - EmailAdmins
$false - ExcludedDetectionType
" Successful_SQLi " , " Attempted_SQLi "
60
+ Set-AzureRmSqlDatabaseThreatDetectionPolicy - ResourceGroupName
$params.rgname - ServerName
$params.serverName - DatabaseName
$params.databaseName - NotificationRecipientsEmails
" [email protected] ;[email protected] " - EmailAdmins
$false - ExcludedDetectionType
" Sql_Injection_Vulnerability "
61
61
$policy = Get-AzureRmSqlDatabaseThreatDetectionPolicy - ResourceGroupName $params.rgname - ServerName $params.serverName - DatabaseName $params.databaseName
62
62
63
63
# Assert
64
64
Assert-AreEqual $policy.ThreatDetectionState " Enabled"
65
65
Assert-AreEqual $policy.NotificationRecipientsEmails " [email protected] ;[email protected] "
66
66
Assert-False {$policy.EmailAdmins }
67
- Assert-AreEqual $policy.ExcludedDetectionTypes.Length 2
68
- Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Successful_SQLi)}
69
- Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Attempted_SQLi)}
67
+ Assert-AreEqual $policy.ExcludedDetectionTypes.Length 1
68
+ Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Sql_Injection_Vulnerability)}
70
69
71
70
72
71
# Test
73
- Set-AzureRmSqlDatabaseThreatDetectionPolicy - ResourceGroupName $params.rgname - ServerName $params.serverName - DatabaseName $params.databaseName - ExcludedDetectionType " Successful_SQLi " , " Attempted_SQLi " , " Client_GEO_Anomaly " , " Failed_Logins_Anomaly " , " Failed_Queries_Anomaly " , " Data_Extraction_Anomaly " , " Data_Alteration_Anomaly "
72
+ Set-AzureRmSqlDatabaseThreatDetectionPolicy - ResourceGroupName $params.rgname - ServerName $params.serverName - DatabaseName $params.databaseName - ExcludedDetectionType " Sql_Injection " , " Sql_Injection_Vulnerability " , " Access_Anomaly " , " Usage_Anomaly "
74
73
$policy = Get-AzureRmSqlDatabaseThreatDetectionPolicy - ResourceGroupName $params.rgname - ServerName $params.serverName - DatabaseName $params.databaseName
75
74
76
75
# Assert
77
76
Assert-AreEqual $policy.ThreatDetectionState " Enabled"
78
77
Assert-AreEqual $policy.NotificationRecipientsEmails " [email protected] ;[email protected] "
79
78
Assert-False {$policy.EmailAdmins }
80
- Assert-AreEqual $policy.ExcludedDetectionTypes.Length 7
81
- Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Successful_SQLi)}
82
- Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Attempted_SQLi)}
83
- Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Client_GEO_Anomaly)}
84
- Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Failed_Logins_Anomaly)}
85
- Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Failed_Queries_Anomaly)}
86
- Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Data_Extraction_Anomaly)}
87
- Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Data_Alteration_Anomaly)}
88
-
79
+ Assert-AreEqual $policy.ExcludedDetectionTypes.Length 4
80
+ Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Sql_Injection)}
81
+ Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Sql_Injection_Vulnerability)}
82
+ Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Access_Anomaly)}
83
+ Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Usage_Anomaly)}
89
84
90
85
# Test
91
86
Remove-AzureRmSqlDatabaseThreatDetectionPolicy - ResourceGroupName $params.rgname - ServerName $params.serverName - DatabaseName $params.databaseName
@@ -95,14 +90,21 @@ function Test-ThreatDetectionDatabaseUpdatePolicy
95
90
Assert-AreEqual $policy.ThreatDetectionState " Disabled"
96
91
Assert-AreEqual $policy.NotificationRecipientsEmails " [email protected] ;[email protected] "
97
92
Assert-False {$policy.EmailAdmins }
98
- Assert-AreEqual $policy.ExcludedDetectionTypes.Length 7
99
- Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Successful_SQLi)}
100
- Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Attempted_SQLi)}
101
- Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Client_GEO_Anomaly)}
102
- Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Failed_Logins_Anomaly)}
103
- Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Failed_Queries_Anomaly)}
104
- Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Data_Extraction_Anomaly)}
105
- Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Data_Alteration_Anomaly)}
93
+ Assert-AreEqual $policy.ExcludedDetectionTypes.Length 4
94
+ Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Sql_Injection)}
95
+ Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Sql_Injection_Vulnerability)}
96
+ Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Access_Anomaly)}
97
+ Assert-True {$policy.ExcludedDetectionTypes.Contains ([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType ]::Usage_Anomaly)}
98
+
99
+ # Test
100
+ Set-AzureRmSqlDatabaseThreatDetectionPolicy - ResourceGroupName $params.rgname - ServerName $params.serverName - DatabaseName $params.databaseName - ExcludedDetectionType " None"
101
+ $policy = Get-AzureRmSqlDatabaseThreatDetectionPolicy - ResourceGroupName $params.rgname - ServerName $params.serverName - DatabaseName $params.databaseName
102
+
103
+ # Assert
104
+ Assert-AreEqual $policy.ThreatDetectionState " Enabled"
105
+ Assert-AreEqual $policy.NotificationRecipientsEmails " [email protected] ;[email protected] "
106
+ Assert-False {$policy.EmailAdmins }
107
+ Assert-AreEqual $policy.ExcludedDetectionTypes.Length 0
106
108
}
107
109
finally
108
110
{
@@ -183,6 +185,9 @@ function Test-InvalidArgumentsThreatDetection
183
185
# Check that EmailAdmins is not False and NotificationRecipientsEmails is not empty
184
186
Assert-Throws {Set-AzureRmSqlDatabaseThreatDetectionPolicy - ResourceGroupName $params.rgname - ServerName $params.serverName - DatabaseName $params.databaseName - EmailAdmins $false }
185
187
Assert-Throws {Set-AzureRmSqlDatabaseThreatDetectionPolicy - ResourceGroupName $params.rgname - ServerName $params.serverName - DatabaseName $params.databaseName - EmailAdmins $false - NotificationRecipientsEmails " " }
188
+
189
+ # Check that ExcludedDetectionType doesn't hold None and any other type
190
+ Assert-Throws {Set-AzureRmSqlDatabaseThreatDetectionPolicy - ResourceGroupName $params.rgname - ServerName $params.serverName - DatabaseName $params.databaseName - EmailAdmins $true - ExcludedDetectionType " None" , " Sql_Injection_Vulnerability" }
186
191
}
187
192
finally
188
193
{
0 commit comments