Skip to content

Commit 47823fd

Browse files
Add parametrs names to SecurityConstants
1 parent 9613482 commit 47823fd

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,25 +129,25 @@ private void ApplyUserInputToBlobAuditingModel(DatabaseBlobAuditingPolicyModel m
129129
model.StorageAccountName = StorageAccountName;
130130
}
131131

132-
if (MyInvocation.BoundParameters.ContainsKey("StorageKeyType"))
132+
if (MyInvocation.BoundParameters.ContainsKey(SecurityConstants.StorageKeyType))
133133
{
134134
// the user enter a key type - we use it (and override the previously defined key type)
135135
model.StorageKeyType = (StorageKeyType == SecurityConstants.Primary)
136136
? StorageKeyKind.Primary
137137
: StorageKeyKind.Secondary;
138138
}
139139

140-
if (AuditActionGroup != null && AuditActionGroup.Length != 0)
140+
if (MyInvocation.BoundParameters.ContainsKey(SecurityConstants.AuditActionGroup))
141141
{
142142
model.AuditActionGroup = AuditActionGroup;
143143
}
144144

145-
if (AuditAction != null && AuditAction.Length != 0)
145+
if (MyInvocation.BoundParameters.ContainsKey(SecurityConstants.AuditAction))
146146
{
147147
model.AuditAction = AuditAction;
148148
}
149149

150-
if (MyInvocation.BoundParameters.ContainsKey("EventType")) // Event types are relevant only for Table auditing
150+
if (MyInvocation.BoundParameters.ContainsKey(SecurityConstants.EventType)) // Event types are relevant only for Table auditing
151151
{
152152
throw new Exception(string.Format(Properties.Resources.EventTypeConfiguringIrrelevantForBlobAuditingPolicy));
153153
}
@@ -163,7 +163,7 @@ private void ApplyUserInputToTableAuditingModel(DatabaseAuditingPolicyModel mode
163163
model.StorageAccountName = StorageAccountName;
164164
ModelAdapter.ClearStorageDetailsCache();
165165
}
166-
if (!string.IsNullOrEmpty(StorageKeyType))
166+
if (MyInvocation.BoundParameters.ContainsKey(SecurityConstants.StorageKeyType))
167167
{
168168
// the user enter a key type - we use it (and override the previously defined key type)
169169
model.StorageKeyType = (StorageKeyType == SecurityConstants.Primary)
@@ -173,7 +173,7 @@ private void ApplyUserInputToTableAuditingModel(DatabaseAuditingPolicyModel mode
173173

174174
EventType = Util.ProcessAuditEvents(EventType);
175175

176-
if (MyInvocation.BoundParameters.ContainsKey("EventType")) // the user provided Table auditing event types
176+
if (MyInvocation.BoundParameters.ContainsKey(SecurityConstants.EventType)) // the user provided Table auditing event types
177177
{
178178
model.EventType = EventType.Select(s => SecurityConstants.AuditEventsToAuditEventType[s]).ToArray();
179179
}
@@ -196,12 +196,12 @@ private void ApplyUserInputToTableAuditingModel(DatabaseAuditingPolicyModel mode
196196
model.TableIdentifier = TableIdentifier;
197197
}
198198

199-
if (AuditAction != null) // Audit Actions are relevant only for Blob auditing
199+
if (MyInvocation.BoundParameters.ContainsKey(SecurityConstants.AuditAction)) // Audit Actions are relevant only for Blob auditing
200200
{
201201
throw new Exception(string.Format(Properties.Resources.AuditActionsConfiguringIrrelevantForTableAuditingPolicy));
202202
}
203203

204-
if (AuditActionGroup != null) // Audit Action Groups are relevant only for Blob auditing
204+
if (MyInvocation.BoundParameters.ContainsKey(SecurityConstants.AuditActionGroup)) // Audit Action Groups are relevant only for Blob auditing
205205
{
206206
throw new Exception(string.Format(Properties.Resources.AuditActionGroupsConfiguringIrrelevantForTableAuditingPolicy));
207207
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ private void ApplyUserInputToTableAuditingModel(ServerAuditingPolicyModel model)
124124
model.StorageAccountName = StorageAccountName;
125125
ModelAdapter.ClearStorageDetailsCache();
126126
}
127-
if (!string.IsNullOrEmpty(StorageKeyType)) // the user enter a key type - we use it (and running over the previously defined key type)
127+
if (MyInvocation.BoundParameters.ContainsKey(SecurityConstants.StorageKeyType)) // the user enter a key type - we use it (and running over the previously defined key type)
128128
{
129129
model.StorageKeyType = (StorageKeyType == SecurityConstants.Primary) ? StorageKeyKind.Primary : StorageKeyKind.Secondary;
130130
}
131131

132132
EventType = Util.ProcessAuditEvents(EventType);
133133

134-
if (MyInvocation.BoundParameters.ContainsKey("EventType")) // the user provided event types to audit
134+
if (MyInvocation.BoundParameters.ContainsKey(SecurityConstants.EventType)) // the user provided event types to audit
135135
{
136136
model.EventType = EventType.Select(s => SecurityConstants.AuditEventsToAuditEventType[s]).ToArray();
137137
}
@@ -154,7 +154,7 @@ private void ApplyUserInputToTableAuditingModel(ServerAuditingPolicyModel model)
154154
model.TableIdentifier = TableIdentifier;
155155
}
156156

157-
if (MyInvocation.BoundParameters.ContainsKey("AuditActionGroups")) //AuditActionGroup is relevant only for blob auditing
157+
if (MyInvocation.BoundParameters.ContainsKey(SecurityConstants.AuditActionGroup)) //AuditActionGroup is relevant only for blob auditing
158158
{
159159
throw new Exception(string.Format(Properties.Resources.AuditActionGroupsConfiguringIrrelevantForTableAuditingPolicy));
160160
}
@@ -173,17 +173,17 @@ private void ApplyUserInputToBlobAuditingModel(ServerBlobAuditingPolicyModel mod
173173
model.StorageAccountName = StorageAccountName;
174174
}
175175

176-
if (!string.IsNullOrEmpty(StorageKeyType)) // the user enter a key type - we use it (and running over the previously defined key type)
176+
if (MyInvocation.BoundParameters.ContainsKey(SecurityConstants.StorageKeyType)) // the user enter a key type - we use it (and running over the previously defined key type)
177177
{
178178
model.StorageKeyType = (StorageKeyType == SecurityConstants.Primary) ? StorageKeyKind.Primary : StorageKeyKind.Secondary;
179179
}
180180

181-
if (AuditActionGroup != null && AuditActionGroup.Length != 0)
181+
if (MyInvocation.BoundParameters.ContainsKey(SecurityConstants.AuditActionGroup))
182182
{
183183
model.AuditActionGroup = AuditActionGroup;
184184
}
185185

186-
if (MyInvocation.BoundParameters.ContainsKey("EventType")) // EventType is relevant only for table auditing
186+
if (MyInvocation.BoundParameters.ContainsKey(SecurityConstants.EventType)) // EventType is relevant only for table auditing
187187
{
188188
throw new Exception(string.Format(Properties.Resources.EventTypeConfiguringIrrelevantForBlobAuditingPolicy));
189189
}

src/ResourceManager/Sql/Commands.Sql/Common/SecurityConstants.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public class SecurityConstants
3434
public const string Login_Failure = "Login_Failure";
3535
public const string TransactionManagement_Success = "TransactionManagement_Success";
3636
public const string TransactionManagement_Failure = "TransactionManagement_Failure";
37+
public const string StorageKeyType = "StorageKeyType";
38+
public const string EventType = "EventType";
39+
public const string AuditActionGroup = "AuditActionGroup";
40+
public const string AuditAction = "AuditAction";
3741

3842
public const string All = "All";
3943
public const string None = "None";

0 commit comments

Comments
 (0)