-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
ExtendedDatabaseBlobAuditingPolicyData.cs
297 lines (290 loc) · 17.8 KB
/
ExtendedDatabaseBlobAuditingPolicyData.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Collections.Generic;
using Azure.Core;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Sql.Models;
namespace Azure.ResourceManager.Sql
{
/// <summary>
/// A class representing the ExtendedDatabaseBlobAuditingPolicy data model.
/// An extended database blob auditing policy.
/// </summary>
public partial class ExtendedDatabaseBlobAuditingPolicyData : ResourceData
{
/// <summary>
/// Keeps track of any properties unknown to the library.
/// <para>
/// To assign an object to the value of this property use <see cref="BinaryData.FromObjectAsJson{T}(T, System.Text.Json.JsonSerializerOptions?)"/>.
/// </para>
/// <para>
/// To assign an already formatted json string to this property use <see cref="BinaryData.FromString(string)"/>.
/// </para>
/// <para>
/// Examples:
/// <list type="bullet">
/// <item>
/// <term>BinaryData.FromObjectAsJson("foo")</term>
/// <description>Creates a payload of "foo".</description>
/// </item>
/// <item>
/// <term>BinaryData.FromString("\"foo\"")</term>
/// <description>Creates a payload of "foo".</description>
/// </item>
/// <item>
/// <term>BinaryData.FromObjectAsJson(new { key = "value" })</term>
/// <description>Creates a payload of { "key": "value" }.</description>
/// </item>
/// <item>
/// <term>BinaryData.FromString("{\"key\": \"value\"}")</term>
/// <description>Creates a payload of { "key": "value" }.</description>
/// </item>
/// </list>
/// </para>
/// </summary>
private IDictionary<string, BinaryData> _serializedAdditionalRawData;
/// <summary> Initializes a new instance of <see cref="ExtendedDatabaseBlobAuditingPolicyData"/>. </summary>
public ExtendedDatabaseBlobAuditingPolicyData()
{
AuditActionsAndGroups = new ChangeTrackingList<string>();
}
/// <summary> Initializes a new instance of <see cref="ExtendedDatabaseBlobAuditingPolicyData"/>. </summary>
/// <param name="id"> The id. </param>
/// <param name="name"> The name. </param>
/// <param name="resourceType"> The resourceType. </param>
/// <param name="systemData"> The systemData. </param>
/// <param name="predicateExpression"> Specifies condition of where clause when creating an audit. </param>
/// <param name="retentionDays"> Specifies the number of days to keep in the audit logs in the storage account. </param>
/// <param name="auditActionsAndGroups">
/// Specifies the Actions-Groups and Actions to audit.
///
/// The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins:
///
/// BATCH_COMPLETED_GROUP,
/// SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP,
/// FAILED_DATABASE_AUTHENTICATION_GROUP.
///
/// This above combination is also the set that is configured by default when enabling auditing from the Azure portal.
///
/// The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records):
///
/// APPLICATION_ROLE_CHANGE_PASSWORD_GROUP
/// BACKUP_RESTORE_GROUP
/// DATABASE_LOGOUT_GROUP
/// DATABASE_OBJECT_CHANGE_GROUP
/// DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP
/// DATABASE_OBJECT_PERMISSION_CHANGE_GROUP
/// DATABASE_OPERATION_GROUP
/// DATABASE_PERMISSION_CHANGE_GROUP
/// DATABASE_PRINCIPAL_CHANGE_GROUP
/// DATABASE_PRINCIPAL_IMPERSONATION_GROUP
/// DATABASE_ROLE_MEMBER_CHANGE_GROUP
/// FAILED_DATABASE_AUTHENTICATION_GROUP
/// SCHEMA_OBJECT_ACCESS_GROUP
/// SCHEMA_OBJECT_CHANGE_GROUP
/// SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP
/// SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP
/// SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP
/// USER_CHANGE_PASSWORD_GROUP
/// BATCH_STARTED_GROUP
/// BATCH_COMPLETED_GROUP
/// DBCC_GROUP
/// DATABASE_OWNERSHIP_CHANGE_GROUP
/// DATABASE_CHANGE_GROUP
/// LEDGER_OPERATION_GROUP
///
/// These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs.
///
/// For more information, see [Database-Level Audit Action Groups](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-action-groups).
///
/// For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are:
/// SELECT
/// UPDATE
/// INSERT
/// DELETE
/// EXECUTE
/// RECEIVE
/// REFERENCES
///
/// The general form for defining an action to be audited is:
/// {action} ON {object} BY {principal}
///
/// Note that <object> in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively.
///
/// For example:
/// SELECT on dbo.myTable by public
/// SELECT on DATABASE::myDatabase by public
/// SELECT on SCHEMA::mySchema by public
///
/// For more information, see [Database-Level Audit Actions](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-actions)
/// </param>
/// <param name="isStorageSecondaryKeyInUse"> Specifies whether storageAccountAccessKey value is the storage's secondary key. </param>
/// <param name="isAzureMonitorTargetEnabled">
/// Specifies whether audit events are sent to Azure Monitor.
/// In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and 'IsAzureMonitorTargetEnabled' as true.
///
/// When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created.
/// Note that for server level audit you should use the 'master' database as {databaseName}.
///
/// Diagnostic Settings URI format:
/// PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview
///
/// For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207)
/// or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043)
///
/// </param>
/// <param name="queueDelayMs">
/// Specifies the amount of time in milliseconds that can elapse before audit actions are forced to be processed.
/// The default minimum value is 1000 (1 second). The maximum is 2,147,483,647.
/// </param>
/// <param name="isManagedIdentityInUse"> Specifies whether Managed Identity is used to access blob storage. </param>
/// <param name="state"> Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. </param>
/// <param name="storageEndpoint"> Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. </param>
/// <param name="storageAccountAccessKey">
/// Specifies the identifier key of the auditing storage account.
/// If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage.
/// Prerequisites for using managed identity authentication:
/// 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD).
/// 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity.
/// For more information, see [Auditing to storage using Managed Identity authentication](https://go.microsoft.com/fwlink/?linkid=2114355)
/// </param>
/// <param name="storageAccountSubscriptionId"> Specifies the blob storage subscription Id. </param>
/// <param name="serializedAdditionalRawData"> Keeps track of any properties unknown to the library. </param>
internal ExtendedDatabaseBlobAuditingPolicyData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string predicateExpression, int? retentionDays, IList<string> auditActionsAndGroups, bool? isStorageSecondaryKeyInUse, bool? isAzureMonitorTargetEnabled, int? queueDelayMs, bool? isManagedIdentityInUse, BlobAuditingPolicyState? state, string storageEndpoint, string storageAccountAccessKey, Guid? storageAccountSubscriptionId, IDictionary<string, BinaryData> serializedAdditionalRawData) : base(id, name, resourceType, systemData)
{
PredicateExpression = predicateExpression;
RetentionDays = retentionDays;
AuditActionsAndGroups = auditActionsAndGroups;
IsStorageSecondaryKeyInUse = isStorageSecondaryKeyInUse;
IsAzureMonitorTargetEnabled = isAzureMonitorTargetEnabled;
QueueDelayMs = queueDelayMs;
IsManagedIdentityInUse = isManagedIdentityInUse;
State = state;
StorageEndpoint = storageEndpoint;
StorageAccountAccessKey = storageAccountAccessKey;
StorageAccountSubscriptionId = storageAccountSubscriptionId;
_serializedAdditionalRawData = serializedAdditionalRawData;
}
/// <summary> Specifies condition of where clause when creating an audit. </summary>
[WirePath("properties.predicateExpression")]
public string PredicateExpression { get; set; }
/// <summary> Specifies the number of days to keep in the audit logs in the storage account. </summary>
[WirePath("properties.retentionDays")]
public int? RetentionDays { get; set; }
/// <summary>
/// Specifies the Actions-Groups and Actions to audit.
///
/// The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins:
///
/// BATCH_COMPLETED_GROUP,
/// SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP,
/// FAILED_DATABASE_AUTHENTICATION_GROUP.
///
/// This above combination is also the set that is configured by default when enabling auditing from the Azure portal.
///
/// The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records):
///
/// APPLICATION_ROLE_CHANGE_PASSWORD_GROUP
/// BACKUP_RESTORE_GROUP
/// DATABASE_LOGOUT_GROUP
/// DATABASE_OBJECT_CHANGE_GROUP
/// DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP
/// DATABASE_OBJECT_PERMISSION_CHANGE_GROUP
/// DATABASE_OPERATION_GROUP
/// DATABASE_PERMISSION_CHANGE_GROUP
/// DATABASE_PRINCIPAL_CHANGE_GROUP
/// DATABASE_PRINCIPAL_IMPERSONATION_GROUP
/// DATABASE_ROLE_MEMBER_CHANGE_GROUP
/// FAILED_DATABASE_AUTHENTICATION_GROUP
/// SCHEMA_OBJECT_ACCESS_GROUP
/// SCHEMA_OBJECT_CHANGE_GROUP
/// SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP
/// SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP
/// SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP
/// USER_CHANGE_PASSWORD_GROUP
/// BATCH_STARTED_GROUP
/// BATCH_COMPLETED_GROUP
/// DBCC_GROUP
/// DATABASE_OWNERSHIP_CHANGE_GROUP
/// DATABASE_CHANGE_GROUP
/// LEDGER_OPERATION_GROUP
///
/// These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs.
///
/// For more information, see [Database-Level Audit Action Groups](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-action-groups).
///
/// For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are:
/// SELECT
/// UPDATE
/// INSERT
/// DELETE
/// EXECUTE
/// RECEIVE
/// REFERENCES
///
/// The general form for defining an action to be audited is:
/// {action} ON {object} BY {principal}
///
/// Note that <object> in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively.
///
/// For example:
/// SELECT on dbo.myTable by public
/// SELECT on DATABASE::myDatabase by public
/// SELECT on SCHEMA::mySchema by public
///
/// For more information, see [Database-Level Audit Actions](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-actions)
/// </summary>
[WirePath("properties.auditActionsAndGroups")]
public IList<string> AuditActionsAndGroups { get; }
/// <summary> Specifies whether storageAccountAccessKey value is the storage's secondary key. </summary>
[WirePath("properties.isStorageSecondaryKeyInUse")]
public bool? IsStorageSecondaryKeyInUse { get; set; }
/// <summary>
/// Specifies whether audit events are sent to Azure Monitor.
/// In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and 'IsAzureMonitorTargetEnabled' as true.
///
/// When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created.
/// Note that for server level audit you should use the 'master' database as {databaseName}.
///
/// Diagnostic Settings URI format:
/// PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview
///
/// For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207)
/// or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043)
///
/// </summary>
[WirePath("properties.isAzureMonitorTargetEnabled")]
public bool? IsAzureMonitorTargetEnabled { get; set; }
/// <summary>
/// Specifies the amount of time in milliseconds that can elapse before audit actions are forced to be processed.
/// The default minimum value is 1000 (1 second). The maximum is 2,147,483,647.
/// </summary>
[WirePath("properties.queueDelayMs")]
public int? QueueDelayMs { get; set; }
/// <summary> Specifies whether Managed Identity is used to access blob storage. </summary>
[WirePath("properties.isManagedIdentityInUse")]
public bool? IsManagedIdentityInUse { get; set; }
/// <summary> Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. </summary>
[WirePath("properties.state")]
public BlobAuditingPolicyState? State { get; set; }
/// <summary> Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. </summary>
[WirePath("properties.storageEndpoint")]
public string StorageEndpoint { get; set; }
/// <summary>
/// Specifies the identifier key of the auditing storage account.
/// If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage.
/// Prerequisites for using managed identity authentication:
/// 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD).
/// 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity.
/// For more information, see [Auditing to storage using Managed Identity authentication](https://go.microsoft.com/fwlink/?linkid=2114355)
/// </summary>
[WirePath("properties.storageAccountAccessKey")]
public string StorageAccountAccessKey { get; set; }
/// <summary> Specifies the blob storage subscription Id. </summary>
[WirePath("properties.storageAccountSubscriptionId")]
public Guid? StorageAccountSubscriptionId { get; set; }
}
}