Skip to content

Commit 2898d19

Browse files
author
yaakoviyun
committed
Support backward compatibility for old audit event + renaming of "Constants" class to "SecurityConstants" + spellchecks
Support backward compatibility for old audit event + renaming of "Constants" class to "SecurityConstants" + spellchecks
1 parent 5ebf7e7 commit 2898d19

23 files changed

+284
-197
lines changed

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/SecurityTests.ps1

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,17 @@ function Test-DatabaseUpdatePolicyWithEventTypes
153153
$policy = Get-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName
154154

155155
# Assert
156-
Assert-AreEqual $policy.EventType.Length 10
156+
Assert-AreEqual $policy.EventType.Length 15
157157

158158
# Test
159-
Set-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount -EventType "PlainSQL_Success","ParameterizedSQL_Success","ParameterizedSQL_Failure"
159+
Set-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount -EventType "PlainSQL_Success","ParameterizedSQL_Success","ParameterizedSQL_Failure","DataAccess","DataChanges","RevokePermissions"
160160
$policy = Get-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName
161161

162162
# Assert
163-
Assert-AreEqual $policy.EventType.Length 3
163+
Assert-AreEqual $policy.EventType.Length 6
164+
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::DataAccess)}
165+
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::DataChanges)}
166+
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::RevokePermissions)}
164167
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::PlainSQL_Success)}
165168
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::ParameterizedSQL_Success)}
166169
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::ParameterizedSQL_Failure)}
@@ -197,15 +200,17 @@ function Test-ServerUpdatePolicyWithEventTypes
197200
$policy = Get-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName
198201

199202
# Assert
200-
Assert-AreEqual $policy.EventType.Length 10
203+
Assert-AreEqual $policy.EventType.Length 15
201204

202205
# Test
203-
Set-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount -EventType "PlainSQL_Success","ParameterizedSQL_Success","ParameterizedSQL_Failure"
206+
Set-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount -EventType "DataAccess","DataChanges","RevokePermissions","PlainSQL_Success","ParameterizedSQL_Success","ParameterizedSQL_Failure"
204207
$policy = Get-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName
205208

206209
# Assert
207-
Assert-AreEqual $policy.EventType.Length 3
208-
210+
Assert-AreEqual $policy.EventType.Length 6
211+
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::DataAccess)}
212+
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::DataChanges)}
213+
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::RevokePermissions)}
209214
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::PlainSQL_Success)}
210215
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::ParameterizedSQL_Success)}
211216
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::ParameterizedSQL_Failure)}
@@ -226,7 +231,7 @@ function Test-ServerUpdatePolicyWithEventTypes
226231

227232
<#
228233
.SYNOPSIS
229-
Tests the modification of a database's auting policy event types with the 'All' or 'None' shortcuts
234+
Tests the modification of a database's auditing policy event types with the 'All' or 'None' shortcuts
230235
#>
231236
function Test-DatabaseUpdatePolicyWithEventTypeShortcuts
232237
{
@@ -242,14 +247,14 @@ function Test-DatabaseUpdatePolicyWithEventTypeShortcuts
242247
$policy = Get-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName
243248

244249
# Assert
245-
Assert-AreEqual $policy.EventType.Length 10
250+
Assert-AreEqual $policy.EventType.Length 15
246251

247252
# Test
248253
Set-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount -EventType "All"
249254
$policy = Get-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName
250255

251256
# Assert
252-
Assert-AreEqual $policy.EventType.Length 10
257+
Assert-AreEqual $policy.EventType.Length 15
253258

254259

255260
# Test
@@ -297,14 +302,14 @@ function Test-ServerUpdatePolicyWithEventTypeShortcuts
297302
$policy = Get-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName
298303

299304
# Assert
300-
Assert-AreEqual $policy.EventType.Length 10
305+
Assert-AreEqual $policy.EventType.Length 15
301306

302307
# Test
303308
Set-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount -EventType "All"
304309
$policy = Get-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName
305310

306311
# Assert
307-
Assert-AreEqual $policy.EventType.Length 10
312+
Assert-AreEqual $policy.EventType.Length 15
308313

309314

310315
# Test
@@ -485,7 +490,7 @@ function Test-UseServerDefault
485490

486491
<#
487492
.SYNOPSIS
488-
Tests that a failure occurs when trying to set a policy to a database, and that database does not have a polic as well as the policy does not have a storage account
493+
Tests that a failure occurs when trying to set a policy to a database, and that database does not have a policy as well as the policy does not have a storage account
489494
#>
490495
function Test-FailedDatabaseUpdatePolicyWithNoStorage
491496
{
@@ -648,7 +653,7 @@ function Test-DatabaseDirectAccess
648653

649654
<#
650655
.SYNOPSIS
651-
Tests that storage key rotatation process for a policy of a Sql database server is managed properly
656+
Tests that storage key rotation process for a policy of a Sql database server is managed properly
652657
#>
653658
function Test-ServerStorageKeyRotation
654659
{
@@ -689,7 +694,7 @@ function Test-ServerStorageKeyRotation
689694

690695
<#
691696
.SYNOPSIS
692-
Tests that storage key rotatation process for a policy of a Sql database is managed properly
697+
Tests that storage key rotation process for a policy of a Sql database is managed properly
693698
#>
694699
function Test-DatabaseStorageKeyRotation
695700
{
@@ -726,4 +731,4 @@ function Test-DatabaseStorageKeyRotation
726731
# Cleanup
727732
Remove-TestEnvironment $testSuffix
728733
}
729-
}
734+
}

src/ResourceManager/Sql/Commands.Sql/Commands.Sql.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<Compile Include="Security\Services\DataMaskingEndpointsCommunicator.cs" />
9797
<Compile Include="Security\Services\SecureConnectionEndpointsCommunicator.cs" />
9898
<Compile Include="Security\Services\AzureEndpointsCommunicator.cs" />
99-
<Compile Include="Security\Services\Constants.cs" />
99+
<Compile Include="Security\Services\SecurityConstants.cs" />
100100
<Compile Include="Security\Services\SqlDataMaskingAdapter.cs" />
101101
<Compile Include="Security\Services\SqlSecureConnectionAdapter.cs" />
102102
<Compile Include="Security\Services\SqlAuditAdapter.cs" />

src/ResourceManager/Sql/Commands.Sql/Microsoft.Azure.Commands.Sql.dll-Help.xml

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,13 @@
536536
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
537537
<maml:name>EventType</maml:name>
538538
<maml:description>
539-
<maml:para>Specifies the event types to audit
539+
<maml:para>Specifies the events to audit
540540
Valid values are:
541+
-- DataAccess (Deprecated)
542+
-- DataChanges (Deprecated)
543+
-- SchemaChanges (Deprecated)
544+
-- SecurityExceptions (Deprecated)
545+
-- RevokePermissions (Deprecated)
541546
-- PlainSQL_Success
542547
-- PlainSQL_Failure
543548
-- ParameterizedSQL_Success
@@ -550,7 +555,9 @@
550555
-- TransactionManagement_Failure
551556
-- All
552557
-- None
553-
Note that is possible to specify several event types. You can specify &#39;All&#39; to audit all of the event types or &#39;None&#39; to specify that none of the events will be audited. Specifying &#39;All&#39; or &#39;None&#39; alongside other event types would result in failure to execute the cmdlet.
558+
Note that is possible to specify several events. You can specify &#39;All&#39; to audit all of the event or &#39;None&#39; to specify that none of the events will be audited. Specifying &#39;All&#39; or &#39;None&#39; alongside other events would result in failure to execute the cmdlet.
559+
Do not mix deprecated events with other events in same policy.
560+
Avoid using deprecated events in new projects.
554561
</maml:para>
555562
</maml:description>
556563
<command:parameterValue required="true" variableLength="true">String[]</command:parameterValue>
@@ -622,8 +629,13 @@
622629
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
623630
<maml:name>EventType</maml:name>
624631
<maml:description>
625-
<maml:para>Specifies the event types to audit
632+
<maml:para>Specifies the events to audit
626633
Valid values are:
634+
-- DataAccess (Deprecated)
635+
-- DataChanges (Deprecated)
636+
-- SchemaChanges (Deprecated)
637+
-- SecurityExceptions (Deprecated)
638+
-- RevokePermissions (Deprecated)
627639
-- PlainSQL_Success
628640
-- PlainSQL_Failure
629641
-- ParameterizedSQL_Success
@@ -636,8 +648,11 @@
636648
-- TransactionManagement_Failure
637649
-- All
638650
-- None
639-
Note that is possible to specify several event types. You can specify &#39;All&#39; to audit all of the event types or &#39;None&#39; to specify that none of the events will be audited. Specifying &#39;All&#39; or &#39;None&#39; alongside other event types would result in failure to execute the cmdlet.</maml:para>
640-
</maml:description>
651+
Note that is possible to specify several events. You can specify &#39;All&#39; to audit all of the event or &#39;None&#39; to specify that none of the events will be audited. Specifying &#39;All&#39; or &#39;None&#39; alongside other events would result in failure to execute the cmdlet.
652+
Do not mix deprecated events with other events in same policy.
653+
Avoid using deprecated events in new projects.
654+
</maml:para>
655+
</maml:description>
641656
<command:parameterValue required="true" variableLength="true">String[]</command:parameterValue>
642657
<dev:type>
643658
<maml:name>String[]</maml:name>
@@ -697,7 +712,7 @@
697712
<command:terminatingErrors></command:terminatingErrors>
698713
<command:nonTerminatingErrors></command:nonTerminatingErrors>
699714
<maml:alertSet>
700-
<maml:title></maml:title>
715+
<maml:tiltle></maml:tiltle>
701716
<maml:alert>
702717
<maml:para></maml:para>
703718
</maml:alert>
@@ -746,8 +761,13 @@
746761
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
747762
<maml:name>EventType</maml:name>
748763
<maml:description>
749-
<maml:para>Specifies the event types to audit
764+
<maml:para>Specifies the events to audit
750765
Valid values are:
766+
-- DataAccess (Deprecated)
767+
-- DataChanges (Deprecated)
768+
-- SchemaChanges (Deprecated)
769+
-- SecurityExceptions (Deprecated)
770+
-- RevokePermissions (Deprecated)
751771
-- PlainSQL_Success
752772
-- PlainSQL_Failure
753773
-- ParameterizedSQL_Success
@@ -760,8 +780,11 @@
760780
-- TransactionManagement_Failure
761781
-- All
762782
-- None
763-
Note that is possible to specify several event types. You can specify &#39;All&#39; to audit all of the event types or &#39;None&#39; to specify that none of the events will be audited. Specifying &#39;All&#39; or &#39;None&#39; alongside other event types would result in failure to execute the cmdlet.</maml:para>
764-
</maml:description>
783+
Note that is possible to specify several events. You can specify &#39;All&#39; to audit all of the event or &#39;None&#39; to specify that none of the events will be audited. Specifying &#39;All&#39; or &#39;None&#39; alongside other events would result in failure to execute the cmdlet.
784+
Do not mix deprecated events with other events in same policy.
785+
Avoid using deprecated events in new projects.
786+
</maml:para>
787+
</maml:description>
765788
<command:parameterValue required="true" variableLength="true">String[]</command:parameterValue>
766789
</command:parameter>
767790
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
@@ -808,8 +831,13 @@
808831
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
809832
<maml:name>EventType</maml:name>
810833
<maml:description>
811-
<maml:para>Specifies the event types to audit
834+
<maml:para>Specifies the events to audit
812835
Valid values are:
836+
-- DataAccess (Deprecated)
837+
-- DataChanges (Deprecated)
838+
-- SchemaChanges (Deprecated)
839+
-- SecurityExceptions (Deprecated)
840+
-- RevokePermissions (Deprecated)
813841
-- PlainSQL_Success
814842
-- PlainSQL_Failure
815843
-- ParameterizedSQL_Success
@@ -822,8 +850,11 @@
822850
-- TransactionManagement_Failure
823851
-- All
824852
-- None
825-
Note that is possible to specify several event types. You can specify &#39;All&#39; to audit all of the event types or &#39;None&#39; to specify that none of the events will be audited. Specifying &#39;All&#39; or &#39;None&#39; alongside other event types would result in failure to execute the cmdlet.</maml:para>
826-
</maml:description>
853+
Note that is possible to specify several events. You can specify &#39;All&#39; to audit all of the event or &#39;None&#39; to specify that none of the events will be audited. Specifying &#39;All&#39; or &#39;None&#39; alongside other events would result in failure to execute the cmdlet.
854+
Do not mix deprecated events with other events in same policy.
855+
Avoid using deprecated events in new projects.
856+
</maml:para>
857+
</maml:description>
827858
<command:parameterValue required="true" variableLength="true">String[]</command:parameterValue>
828859
<dev:type>
829860
<maml:name>String[]</maml:name>

0 commit comments

Comments
 (0)