Skip to content

Adding Advanced Threat Protection and Vulnerability Assessment cmdlets on Managed Instance #8227

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

Merged
merged 10 commits into from
Jan 23, 2019

Conversation

talhers
Copy link
Member

@talhers talhers commented Jan 3, 2019

Description

These cmdlets are meant for working with managed instance, and they are the same as the Advanced Threat Protection and Vulnerability Assessment cmdlets on regular Azure db.

Design review for Advanced Threat Protection and Vulnerability Assessment cmdlets on regular Azure db can be found at: https://github.com/Azure/azure-powershell-cmdlet-review-pr/issues/78

PR for Advanced Threat Protection and Vulnerability Assessment cmdlets on regular Azure db can be found at: #6653

Checklist

@talhers
Copy link
Member Author

talhers commented Jan 3, 2019

@yoavfr @yaakoviyun

@talhers
Copy link
Member Author

talhers commented Jan 3, 2019

@jaredmoo

/// <summary>
/// Gets or sets the managed instance name
/// </summary>
public string ManagedInstanceName { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

InstanceName

Copy link
Member Author

Choose a reason for hiding this comment

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

In AzureSqlManagedInstanceModel, the managed instance name property is also called ManagedInstanceName. Do you still want me to rename to InstanceName?


namespace Microsoft.Azure.Commands.Sql.ThreatDetection.Model
{
public class ManagedInstanceThreatDetectionPolicyModel : BaseThreatDetectionPolicyModel
Copy link
Contributor

Choose a reason for hiding this comment

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

InstanceThreatDetectionPolicyModel

Copy link
Member Author

Choose a reason for hiding this comment

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

The managed instance model name is AzureSqlManagedInstanceModel. Do you still want me to rename to InstanceThreatDetectionPolicyModel?

@jaredmoo
Copy link
Contributor

jaredmoo commented Jan 4, 2019

Please review the existing managed instance cmdlets and make yours consistent with those.

@@ -20,7 +20,7 @@ Clear-AzSqlDatabaseVulnerabilityAssessmentRuleBaseline [-InputObject <AzureSqlDa

## DESCRIPTION
The **Clear-AzSqlDatabaseVulnerabilityAssessmentRuleBaseline** cmdlet removes the vulnerability assessment rule baseline.
Note that you need to run *Enable-AzSqlServerAdvancedThreatProtection* and *Set-AzSqlDatabaseVulnerabilityAssessmentSettings* cmdlet as a prerequisite for using this cmdlets.
Note that you need to run *Enable-AzSqlServerAdvancedThreatProtection* and *Update-AzSqlDatabaseVulnerabilityAssessmentSettings* cmdlet as a prerequisite for using this cmdlets.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does Set-AzSqlDatabaseVulnerabilityAssessmentSettings still exist? Because we cannot remove it outside of a breaking change release. And, I didn't see a cmdlet alias on Update-AzSqlDatabaseVulnerabilityAssessmentSettings

Copy link
Member Author

Choose a reason for hiding this comment

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

Set-AzSqlDatabaseVulnerabilityAssessmentSettings never existed. It's an error in the documentation that I noticed and fixed

@MiYanni
Copy link
Contributor

MiYanni commented Jan 8, 2019

@talhers We have moved our projects to a shallower depth. You have merge conflicts. Basically, your changes to:

  • src/ResourceManager/Sql/Commands.Sql.Test/Commands.Sql.Test.Netcore.csproj
  • src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/Common.ps1
  • src/ResourceManager/Sql/Commands.Sql/AdvancedThreatProtection/Services/SqlAdvancedThreatProtectionAdapter.cs
  • src/ResourceManager/Sql/Commands.Sql/Az.Sql.psd1
  • src/ResourceManager/Sql/Commands.Sql/Commands.Sql.Netcore.csproj
  • src/ResourceManager/Sql/Commands.Sql/Properties/Resources.Designer.cs
  • src/ResourceManager/Sql/Commands.Sql/Properties/Resources.resx
  • src/ResourceManager/Sql/Commands.Sql/ThreatDetection/Services/SqlThreatDetectionAdapter.cs
  • src/ResourceManager/Sql/Commands.Sql/ThreatDetection/Services/ThreatDetectionEndpointsCommunicator.cs
  • src/ResourceManager/Sql/Commands.Sql/VulnerabilityAssessment/Cmdlet/SqlDatabaseVulnerabilityAssessmentAtpCmdletBase.cs
  • src/ResourceManager/Sql/Commands.Sql/VulnerabilityAssessment/Cmdlet/SqlDatabaseVulnerabilityAssessmentOperationCmdletBase.cs
  • src/ResourceManager/Sql/Commands.Sql/VulnerabilityAssessment/Cmdlet/VulnerabilityAssessmentRuleBaseline/SqlDatabaseVulnerabilityAssessmentRuleBaselineCmdletBase.cs
  • src/ResourceManager/Sql/Commands.Sql/VulnerabilityAssessment/Services/BaseSqlVulnerabilityAssessmentAdapter.cs
  • src/ResourceManager/Sql/Commands.Sql/VulnerabilityAssessment/Services/SqlVulnerabilityAssessmentAdapter.cs
  • src/ResourceManager/Sql/Commands.Sql/VulnerabilityAssessment/Services/SqlVulnerabilityAssessmentRuleBaselineAdapter.cs
  • src/ResourceManager/Sql/Commands.Sql/VulnerabilityAssessment/Services/SqlVulnerabilityAssessmentScanAdapter.cs
  • src/ResourceManager/Sql/Commands.Sql/VulnerabilityAssessment/Services/VulnerabilityAssessmentEndpointsCommunicator.cs
  • src/ResourceManager/Sql/Commands.Sql/help/Clear-AzSqlDatabaseVulnerabilityAssessmentRuleBaseline.md
  • src/ResourceManager/Sql/Commands.Sql/help/Convert-AzSqlDatabaseVulnerabilityAssessmentScan.md
  • src/ResourceManager/Sql/Commands.Sql/help/Get-AzSqlDatabaseVulnerabilityAssessmentRuleBaseline.md
  • src/ResourceManager/Sql/Commands.Sql/help/Get-AzSqlDatabaseVulnerabilityAssessmentScanRecord.md
  • src/ResourceManager/Sql/Commands.Sql/help/Set-AzSqlDatabaseVulnerabilityAssessmentRuleBaseline.md
  • src/ResourceManager/Sql/Commands.Sql/help/Start-AzSqlDatabaseVulnerabilityAssessmentScan.md

Now need to be made to:

  • src/Sql/Sql.Test/Commands.Sql.Test.Netcore.csproj
  • src/Sql/Sql.Test/ScenarioTests/Common.ps1
  • src/Sql/Sql/AdvancedThreatProtection/Services/SqlAdvancedThreatProtectionAdapter.cs
  • src/Sql/Sql/Az.Sql.psd1
  • src/Sql/Sql/Commands.Sql.Netcore.csproj
  • src/Sql/Sql/Properties/Resources.Designer.cs
  • src/Sql/Sql/Properties/Resources.resx
  • src/Sql/Sql/ThreatDetection/Services/SqlThreatDetectionAdapter.cs
  • src/Sql/Sql/ThreatDetection/Services/ThreatDetectionEndpointsCommunicator.cs
  • src/Sql/Sql/VulnerabilityAssessment/Cmdlet/SqlDatabaseVulnerabilityAssessmentAtpCmdletBase.cs
  • src/Sql/Sql/VulnerabilityAssessment/Cmdlet/SqlDatabaseVulnerabilityAssessmentOperationCmdletBase.cs
  • src/Sql/Sql/VulnerabilityAssessment/Cmdlet/VulnerabilityAssessmentRuleBaseline/SqlDatabaseVulnerabilityAssessmentRuleBaselineCmdletBase.cs
  • src/Sql/Sql/VulnerabilityAssessment/Services/BaseSqlVulnerabilityAssessmentAdapter.cs
  • src/Sql/Sql/VulnerabilityAssessment/Services/SqlVulnerabilityAssessmentAdapter.cs
  • src/Sql/Sql/VulnerabilityAssessment/Services/SqlVulnerabilityAssessmentRuleBaselineAdapter.cs
  • src/Sql/Sql/VulnerabilityAssessment/Services/SqlVulnerabilityAssessmentScanAdapter.cs
  • src/Sql/Sql/VulnerabilityAssessment/Services/VulnerabilityAssessmentEndpointsCommunicator.cs
  • src/Sql/Sql/help/Clear-AzSqlDatabaseVulnerabilityAssessmentRuleBaseline.md
  • src/Sql/Sql/help/Convert-AzSqlDatabaseVulnerabilityAssessmentScan.md
  • src/Sql/Sql/help/Get-AzSqlDatabaseVulnerabilityAssessmentRuleBaseline.md
  • src/Sql/Sql/help/Get-AzSqlDatabaseVulnerabilityAssessmentScanRecord.md
  • src/Sql/Sql/help/Set-AzSqlDatabaseVulnerabilityAssessmentRuleBaseline.md
  • src/Sql/Sql/help/Start-AzSqlDatabaseVulnerabilityAssessmentScan.md

Please update those accordingly and resolve the merge conflicts by deleting the files at the old path.

@jaredmoo
Copy link
Contributor

jaredmoo commented Jan 11, 2019

Tal, you are seeing weird merge problems because you are making changes directly in talhers/master instead of a feature branch. You should always develop in a feature branch to avoid this.

Here is how we can fix this. I already ran the following commands:

# Make sure all branches are up to date
[master ≡]> git fetch --all

# Make a new branch named talhersFixed that is at the same commit as azure/master
[master ≡]> git checkout -b talhersFixed azure/master

# Merge changes from talhers/master into this branch, squashed into a single commit in order to simplify history
[talhersFixed ≡]> git merge --squash talhers/master
[talhersFixed ≡ +56 ~37 -1 ~]> git commit -m "Adding Advanced Threat Protection and Vulnerability Assessment cmdlets on Managed Instance"
[talhersFixed ↑]> git push --set-upstream jaredmoo talhersFixed

As a result, now I have a branch jaredmoo/talhersFixed that your PR should use. You can forcefully change the PR to have the same commit as my jaredmoo/talhersFixed branch by doing this:

# Add jaredmoo as known repo
> git remote add jaredmoo https://github.com/jaredmoo/azure-powershell

# Get all commits from all known repos
> git fetch --all

# Force reset master branch to same commit as jaredmoo/talhersFixed
> git checkout master
> git reset --hard jaredmoo/talhersFixed
> git push --force

@talhers
Copy link
Member Author

talhers commented Jan 13, 2019

Thanks for you help!
@jaredmoo , @MiYanni - can you take another look and merge the PR if everything is fine?
Thanks!

@markcowl
Copy link
Member

@talhers - there are some static analysis failures causing the ci build to fial - at least some of them (the places outlined in SignatureIssues.csv where you have cmdlets with mutiple parameters sets but no default parameter set) will need to be fixed, and you will need to go over thene potential breakign changes outlined in BreakingChangeIssues.csv to see if the new types replacing the current types have the same public property signature. Look at the log for detailed errors, and this document describes how to process atatic analysis errors:

@markcowl
Copy link
Member

@maddieclayton Can you work with @tahlers to ensure this is ready for the next release?

@talhers
Copy link
Member Author

talhers commented Jan 22, 2019

@markcowl - thanks for checking my PR,
I've gone through both breaking changes and signature issues:

breaking changes - static analysis reported a change in input object - this is because previously the VA database cmdlets would receive the DatabaseVulnerabilityAssessmentSettingsModel object, and now they can receive the base class object - VulnerabilityAssessmentSettingsModel. This will not break any existing scripts as DatabaseVulnerabilityAssessmentSettingsModel object is still accepted. (same explanation applies on all input objects reported)

signature issues - I have defined default parameters in the required places.
As to "Consider using a singular noun for the cmdlet name" comment - I didn't change the names because I have named the additional cmdlets on managed database in the same manner as the cmdlets on regular database in order to be consistent with them.

@markcowl , @maddieclayton - can you take another look?
Thanks!

@MiYanni
Copy link
Contributor

MiYanni commented Jan 22, 2019

@talhers You have to update the suppression files or the build will continue to fail. For SQL, they are in tools/StaticAnalysis/Exceptions/Az.Sql. Add the entries to the appropriate files there.

Copy link
Contributor

@MiYanni MiYanni left a comment

Choose a reason for hiding this comment

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

LGTM

@MiYanni MiYanni dismissed jaredmoo’s stale review January 23, 2019 18:35

Comments were addressed.

@MiYanni MiYanni merged commit 84039d9 into Azure:master Jan 23, 2019
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