Skip to content

Commit c104ea5

Browse files
committed
Removing old event types
1 parent 93d0cff commit c104ea5

File tree

7 files changed

+3
-116
lines changed

7 files changed

+3
-116
lines changed

src/ResourceManager/Sql/Commands.Sql/Properties/Resources.Designer.cs

Lines changed: 0 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/Sql/Commands.Sql/Properties/Resources.resx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,6 @@
210210
<data name="InvalidRetentionTypeSet" xml:space="preserve">
211211
<value>Cannot use audit table retention without specifying TableIdentifier. You may want to use '{0}'.</value>
212212
</data>
213-
<data name="InvalidDeprecatedEventTypeSet" xml:space="preserve">
214-
<value>Cannot use deprecated audit events with the current audit events in the same policy.</value>
215-
</data>
216213
<data name="ServerUpgradeExists" xml:space="preserve">
217214
<value>Request for upgrade of server '{0}' already exists.</value>
218215
</data>
@@ -225,9 +222,6 @@
225222
<data name="StandaloneDatabaseActivityNotSupported" xml:space="preserve">
226223
<value>Azure Sql Database Elastic Pool name is required for this operation</value>
227224
</data>
228-
<data name="DeprecatedEventTypeUsed" xml:space="preserve">
229-
<value>The use of any of these event types is deprecated: DataAccess, SchemaChanges, DataChanges, SecurityExceptions, RevokePermissions</value>
230-
</data>
231225
<data name="DeprecatedCmdletUsageWarning" xml:space="preserve">
232226
<value>The {0} cmdlet is deprecated and will be removed in a future release.</value>
233227
</data>

src/ResourceManager/Sql/Commands.Sql/Security/Cmdlet/Auditing/SetAzureSqlDatabaseAuditingPolicy.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class SetAzureSqlDatabaseAuditingPolicy : SqlDatabaseAuditingCmdletBase
3939
/// Gets or sets the names of the event types to use.
4040
/// </summary>
4141
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Event types to audit")]
42-
[ValidateSet(SecurityConstants.DeprecatedAuditEvents.DataAccess, SecurityConstants.DeprecatedAuditEvents.SchemaChanges, SecurityConstants.DeprecatedAuditEvents.DataChanges, SecurityConstants.DeprecatedAuditEvents.SecurityExceptions, SecurityConstants.DeprecatedAuditEvents.RevokePermissions, SecurityConstants.PlainSQL_Success, SecurityConstants.PlainSQL_Failure, SecurityConstants.ParameterizedSQL_Success, SecurityConstants.ParameterizedSQL_Failure, SecurityConstants.StoredProcedure_Success, SecurityConstants.StoredProcedure_Failure, SecurityConstants.Login_Success, SecurityConstants.Login_Failure, SecurityConstants.TransactionManagement_Success, SecurityConstants.TransactionManagement_Failure, SecurityConstants.All, SecurityConstants.None, IgnoreCase = false)]
42+
[ValidateSet(SecurityConstants.PlainSQL_Success, SecurityConstants.PlainSQL_Failure, SecurityConstants.ParameterizedSQL_Success, SecurityConstants.ParameterizedSQL_Failure, SecurityConstants.StoredProcedure_Success, SecurityConstants.StoredProcedure_Failure, SecurityConstants.Login_Success, SecurityConstants.Login_Failure, SecurityConstants.TransactionManagement_Success, SecurityConstants.TransactionManagement_Failure, SecurityConstants.All, SecurityConstants.None, IgnoreCase = false)]
4343
public string[] EventType { get; set; }
4444

4545
/// <summary>
@@ -120,11 +120,6 @@ protected override DatabaseAuditingPolicyModel ApplyUserInputToModel(DatabaseAud
120120
{
121121
model.TableIdentifier = TableIdentifier;
122122
}
123-
124-
if (Util.DeprecatedEventTypeFound(EventType))
125-
{
126-
WriteWarning(string.Format(Resources.DeprecatedEventTypeUsed));
127-
}
128123
return model;
129124
}
130125
}

src/ResourceManager/Sql/Commands.Sql/Security/Cmdlet/Auditing/SetAzureSqlServerAuditingPolicy.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ public class SetAzureSqlServerAuditingPolicy : SqlDatabaseServerAuditingCmdletBa
3838
/// Gets or sets the names of the event types to use.
3939
/// </summary>
4040
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Event types to audit")]
41-
[ValidateSet(SecurityConstants.DeprecatedAuditEvents.DataAccess,
42-
SecurityConstants.DeprecatedAuditEvents.SchemaChanges, SecurityConstants.DeprecatedAuditEvents.DataChanges,
43-
SecurityConstants.DeprecatedAuditEvents.SecurityExceptions,
44-
SecurityConstants.DeprecatedAuditEvents.RevokePermissions, SecurityConstants.PlainSQL_Success,
41+
[ValidateSet(SecurityConstants.PlainSQL_Success,
4542
SecurityConstants.PlainSQL_Failure, SecurityConstants.ParameterizedSQL_Success,
4643
SecurityConstants.ParameterizedSQL_Failure, SecurityConstants.StoredProcedure_Success,
4744
SecurityConstants.StoredProcedure_Failure, SecurityConstants.Login_Success, SecurityConstants.Login_Failure,
@@ -128,10 +125,6 @@ protected override ServerAuditingPolicyModel ApplyUserInputToModel(ServerAuditin
128125
{
129126
model.TableIdentifier = TableIdentifier;
130127
}
131-
if (Util.DeprecatedEventTypeFound(EventType))
132-
{
133-
WriteWarning(string.Format(Resources.DeprecatedEventTypeUsed));
134-
}
135128
return model;
136129
}
137130
}

src/ResourceManager/Sql/Commands.Sql/Security/Services/SecurityConstants.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ namespace Microsoft.Azure.Commands.Sql.Security.Services
2323
public class SecurityConstants
2424
{
2525
// Audit Events:
26-
public class DeprecatedAuditEvents
27-
{
28-
// DeprecatedAuditEvents from 04/2015
29-
public const string DataAccess = "DataAccess";
30-
public const string SchemaChanges = "SchemaChanges";
31-
public const string DataChanges = "DataChanges";
32-
public const string SecurityExceptions = "SecurityExceptions";
33-
public const string RevokePermissions = "RevokePermissions";
34-
}
35-
3626
public const string PlainSQL_Success = "PlainSQL_Success";
3727
public const string PlainSQL_Failure = "PlainSQL_Failure";
3828
public const string ParameterizedSQL_Success = "ParameterizedSQL_Success";
@@ -50,11 +40,6 @@ public class DeprecatedAuditEvents
5040
public static readonly Dictionary<string, AuditEventType> AuditEventsToAuditEventType = new Dictionary
5141
<string, AuditEventType>
5242
{
53-
{DeprecatedAuditEvents.DataAccess, AuditEventType.DataAccess},
54-
{DeprecatedAuditEvents.DataChanges, AuditEventType.DataChanges},
55-
{DeprecatedAuditEvents.SecurityExceptions, AuditEventType.SecurityExceptions},
56-
{DeprecatedAuditEvents.RevokePermissions, AuditEventType.RevokePermissions},
57-
{DeprecatedAuditEvents.SchemaChanges, AuditEventType.SchemaChanges},
5843
{PlainSQL_Success, AuditEventType.PlainSQL_Success},
5944
{PlainSQL_Failure, AuditEventType.PlainSQL_Failure},
6045
{ParameterizedSQL_Success, AuditEventType.ParameterizedSQL_Success},
@@ -91,7 +76,6 @@ public class DeprecatedAuditEvents
9176
public static string ReplacementStringDefaultValue = string.Empty;
9277
public static uint SuffixSizeDefaultValue = 0;
9378

94-
9579
/// <summary>
9680
/// The values that are sent and received by the auditing endpoint
9781
/// </summary>
@@ -102,11 +86,6 @@ public class AuditingEndpoint
10286
public const string Disabled = "Disabled";
10387

10488
// Event types
105-
public const string DataAccess = "DataAccess";
106-
public const string SchemaChanges = "SchemaChanges";
107-
public const string DataChanges = "DataChanges";
108-
public const string SecurityExceptions = "SecurityExceptions";
109-
public const string RevokePermissions = "RevokePermissions";
11089
public const string PlainSQL_Success = "PlainSQL_Success";
11190
public const string PlainSQL_Failure = "PlainSQL_Failure";
11291
public const string ParameterizedSQL_Success = "ParameterizedSQL_Success";

src/ResourceManager/Sql/Commands.Sql/Security/Services/SqlAuditAdapter.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,6 @@ private string PolicizeAuditState(AuditStateType auditState)
212212
private void ModelizeEventTypesInfo(BaseAuditingPolicyModel model, string eventTypesToAudit)
213213
{
214214
HashSet<AuditEventType> events = new HashSet<AuditEventType>();
215-
if (eventTypesToAudit.IndexOf(SecurityConstants.DeprecatedAuditEvents.DataAccess) != -1) events.Add(AuditEventType.DataAccess);
216-
if (eventTypesToAudit.IndexOf(SecurityConstants.DeprecatedAuditEvents.DataChanges) != -1) events.Add(AuditEventType.DataChanges);
217-
if (eventTypesToAudit.IndexOf(SecurityConstants.DeprecatedAuditEvents.RevokePermissions) != -1) events.Add(AuditEventType.RevokePermissions);
218-
if (eventTypesToAudit.IndexOf(SecurityConstants.DeprecatedAuditEvents.SchemaChanges) != -1) events.Add(AuditEventType.SchemaChanges);
219-
if (eventTypesToAudit.IndexOf(SecurityConstants.DeprecatedAuditEvents.SecurityExceptions) != -1) events.Add(AuditEventType.SecurityExceptions);
220215
if (eventTypesToAudit.IndexOf(SecurityConstants.PlainSQL_Success) != -1) events.Add(AuditEventType.PlainSQL_Success);
221216
if (eventTypesToAudit.IndexOf(SecurityConstants.PlainSQL_Failure) != -1) events.Add(AuditEventType.PlainSQL_Failure);
222217
if (eventTypesToAudit.IndexOf(SecurityConstants.ParameterizedSQL_Success) != -1) events.Add(AuditEventType.ParameterizedSQL_Success);
@@ -363,26 +358,6 @@ private string ExtractEventTypes(BaseAuditingPolicyModel model)
363358
}
364359

365360
StringBuilder events = new StringBuilder();
366-
if (IsEventTypeOn(AuditEventType.DataAccess, model.EventType))
367-
{
368-
events.Append(SecurityConstants.AuditingEndpoint.DataAccess).Append(",");
369-
}
370-
if (IsEventTypeOn(AuditEventType.DataChanges, model.EventType))
371-
{
372-
events.Append(SecurityConstants.AuditingEndpoint.DataChanges).Append(",");
373-
}
374-
if (IsEventTypeOn(AuditEventType.RevokePermissions, model.EventType))
375-
{
376-
events.Append(SecurityConstants.AuditingEndpoint.RevokePermissions).Append(",");
377-
}
378-
if (IsEventTypeOn(AuditEventType.SchemaChanges, model.EventType))
379-
{
380-
events.Append(SecurityConstants.AuditingEndpoint.SchemaChanges).Append(",");
381-
}
382-
if (IsEventTypeOn(AuditEventType.SecurityExceptions, model.EventType))
383-
{
384-
events.Append(SecurityConstants.AuditingEndpoint.SecurityExceptions).Append(",");
385-
}
386361
if (IsEventTypeOn(AuditEventType.PlainSQL_Success, model.EventType))
387362
{
388363
events.Append(SecurityConstants.AuditingEndpoint.PlainSQL_Success).Append(",");

src/ResourceManager/Sql/Commands.Sql/Services/Util.cs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -84,39 +84,8 @@ internal static string[] ProcessAuditEvents(string[] eventTypes)
8484
{
8585
throw new Exception(string.Format(Resources.InvalidEventTypeSet, SecurityConstants.None));
8686
}
87-
88-
if (DeprecatedEventTypeFound(eventTypes))
89-
{
90-
if(eventTypes.Intersect(auditEvents).Any())
91-
{
92-
// If the event types includes new events and deprecated events we throw error
93-
throw new Exception(Resources.InvalidDeprecatedEventTypeSet);
94-
}
95-
}
96-
9787
}
9888
return eventTypes;
99-
}
100-
101-
/// <summary>
102-
/// Checks whether a deprected event type is found in the received array of event types
103-
/// </summary>
104-
internal static bool DeprecatedEventTypeFound(string[] eventType)
105-
{
106-
if(eventType == null)
107-
{
108-
return false;
109-
}
110-
111-
string[] deprecatedAuditEvents =
112-
{
113-
SecurityConstants.DeprecatedAuditEvents.DataAccess,
114-
SecurityConstants.DeprecatedAuditEvents.DataChanges,
115-
SecurityConstants.DeprecatedAuditEvents.SecurityExceptions,
116-
SecurityConstants.DeprecatedAuditEvents.RevokePermissions,
117-
SecurityConstants.DeprecatedAuditEvents.SchemaChanges
118-
};
119-
return eventType.Intersect(deprecatedAuditEvents).Any();
120-
}
89+
}
12190
}
12291
}

0 commit comments

Comments
 (0)