Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Auditing: Remove AUDIT_CHANGE_GROUP from available AuditActionGroups #4990

Merged
merged 10 commits into from
Dec 5, 2017

Conversation

ranisha2
Copy link
Contributor

@ranisha2 ranisha2 commented Nov 15, 2017

Description


This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.

General Guidelines

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.
  • The pull request does not introduce breaking changes (unless a major version change occurs in the assembly and module).

Testing Guidelines

  • Pull request includes test coverage for the included changes.
  • PowerShell scripts used in tests should do any necessary setup as part of the test or suite setup, and should not use hard-coded values for locations or existing resources.

Cmdlet Signature Guidelines

  • New cmdlets that make changes or have side effects should implement ShouldProcess and have SupportShouldProcess=true specified in the cmdlet attribute. You can find more information on ShouldProcess here.
  • Cmdlet specifies OutputType attribute if any output is produced - if the cmdlet produces no output, it should implement a PassThru parameter.

Cmdlet Parameter Guidelines

  • Parameter types should not expose types from the management library - complex parameter types should be defined in the module.
  • Complex parameter types are discouraged - a parameter type should be simple types as often as possible. If complex types are used, they should be shallow and easily creatable from a constructor or another cmdlet.
  • Cmdlet parameter sets should be mutually exclusive - each parameter set must have at least one mandatory parameter not in other parameter sets.

Remove AUDIT_CHANGE_GROUP from available AuditActionGroups and update markdown files.
jaredmoo
jaredmoo previously approved these changes Nov 15, 2017
@@ -18,8 +18,7 @@ public enum AuditActionGroups
{
BATCH_STARTED_GROUP,
BATCH_COMPLETED_GROUP,
APPLICATION_ROLE_CHANGE_PASSWORD_GROUP,
AUDIT_CHANGE_GROUP,
APPLICATION_ROLE_CHANGE_PASSWORD_GROUP,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this is a breaking change, right? You will need to deprecate these values, and, if provided by the user, map them into other values. Otherwise, users with scripts that already use these values will be broken.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markcowl AUDIT_CHANGE_GROUP was never supported. This action group was mistakenly added, and when provided the backend throws an exception anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it cannot be mapped to anything, it should just be removed, as it shouldn't have been there in the first place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranisha2 just to be 100% sure (☺️), if a user provided the AUDIT_CHANGE_GROUP value for any parameter that accepts an AuditActionGroup enum, then it would have never worked and always thrown an exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cormacpayne When enabling a policy with AUDIT_CHANGE_GROUP value, our backend will always throw an exception. The only way to provide this value with no exception to be thrown is when disabling the policy, which does not make any sense as this value does not take effect when the policy is disabled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranisha2 But could there be a customer script that used this value when disabling a policy? As long as there can be no working script that uses this value, then this change is OK, otherwise, it is a breaking change, and the proper thing is to deprecate the value rather than removing it. If possible, for enable scenarios, the value would be mapped to anohter (default) value, although throwing would be OK, if that is what the service does now.

@cormacpayne
Copy link
Member

@ranisha2 would you mind updating the Sql change log with a snippet about this change? Something along the lines of

* Fixed issue https://github.com/Azure/azure-powershell/issues/4974
    - Removed invalid AUDIT_CHANGED_GROUP value from auditing cmdlets

cormacpayne
cormacpayne previously approved these changes Nov 28, 2017
@cormacpayne
Copy link
Member

@@ -18,8 +18,7 @@ public enum AuditActionGroups
{
BATCH_STARTED_GROUP,
BATCH_COMPLETED_GROUP,
APPLICATION_ROLE_CHANGE_PASSWORD_GROUP,
AUDIT_CHANGE_GROUP,
APPLICATION_ROLE_CHANGE_PASSWORD_GROUP,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranisha2 But could there be a customer script that used this value when disabling a policy? As long as there can be no working script that uses this value, then this change is OK, otherwise, it is a breaking change, and the proper thing is to deprecate the value rather than removing it. If possible, for enable scenarios, the value would be mapped to anohter (default) value, although throwing would be OK, if that is what the service does now.

@ranisha2
Copy link
Contributor Author

@markcowl @cormacpayne
I added a warning message when using this action group, and removed it from the list when provided.
If it's provided alone, the default value will take effect (As non providing action groups). If not, it will be simply removed (There's no mapping for default value as the user can provide a list of action groups)

@@ -19,6 +19,8 @@
-->
## Current Release
* Added ability to rename database using Set-AzureRmSqlDatabase
* Fixed issue https://github.com/Azure/azure-powershell/issues/4974
- Removed invalid AUDIT_CHANGED_GROUP value from auditing cmdlets
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cormacpayne, @markcowl Do I still need to include this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranisha2 I would change the second line to say "Providing invalid AUDIT_CHANGED_GROUP value for auditing cmdlets no longer throws an error and will be removed in an upcoming release."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markcowl markcowl assigned ranisha2 and unassigned markcowl Dec 1, 2017
@@ -54,6 +56,15 @@ protected override SqlAuditAdapter InitModelAdapter(IAzureSubscription subscript
/// <param name="model">The model object with the data to be sent to the REST endpoints</param>
protected override DatabaseBlobAuditingSettingsModel PersistChanges(DatabaseBlobAuditingSettingsModel model)
{
if (Array.IndexOf(model.AuditActionGroup, AuditActionGroups.AUDIT_CHANGE_GROUP) > -1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranisha2 is model.AuditActionGroup always going to be an initialized array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cormacpayne We perform a GetPolicy request in order to override only the provided parameters.
When not provided, we'll use the saved AuditActionGroup value, which is always initialized.

@@ -61,6 +64,15 @@ protected override SqlAuditAdapter InitModelAdapter(IAzureSubscription subscript
/// <param name="baseModel">The model object with the data to be sent to the REST endpoints</param>
protected override ServerBlobAuditingSettingsModel PersistChanges(ServerBlobAuditingSettingsModel baseModel)
{
if (Array.IndexOf(baseModel.AuditActionGroup, AuditActionGroups.AUDIT_CHANGE_GROUP) > -1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranisha2 same comment here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@cormacpayne cormacpayne dismissed markcowl’s stale review December 5, 2017 15:59

Approved offline

@cormacpayne
Copy link
Member

@markcowl
Copy link
Member

markcowl commented Dec 5, 2017

@cormacpayne cormacpayne merged commit 78d3aae into Azure:preview Dec 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants