Skip to content

[KeyVault] adding soft-delete support for KeyVault certificates #4400

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 20 commits into from
Aug 28, 2017

Conversation

dragav
Copy link
Contributor

@dragav dragav commented Aug 2, 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.

Dragos Avadanei added 5 commits May 5, 2017 11:27
schaabs
schaabs previously approved these changes Aug 2, 2017
@dragav
Copy link
Contributor Author

dragav commented Aug 2, 2017

The build appears to be failing because of static analysis; there is a large number of warnings, none of which come from the KeyVault namespace.

The only references to KeyVault listed in the build warnings file are several skipped management test cases.

@cormacpayne cormacpayne changed the base branch from preview to release-4.3.0 August 4, 2017 16:04
Copy link
Member

@cormacpayne cormacpayne left a comment

Choose a reason for hiding this comment

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

@dragav a few comments that need to be resolved

@@ -196,6 +196,7 @@
<Compile Include="UnitTests\SetKeyVaultSecretTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
Copy link
Member

Choose a reason for hiding this comment

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

@dragav please remove this

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Member

Choose a reason for hiding this comment

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

@dragav please remove this file

@@ -12,176 +12,36 @@ Creates a key in a key vault or imports a key into a key vault.

## SYNTAX

### Create (Default)
Copy link
Member

Choose a reason for hiding this comment

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

@dragav what happened to this file?

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 help generation seems to output incorrect content for a few commands, I haven't figured out why. I've manually updated some of them, and this one slipped through; will revert the change.

@@ -1,7 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.ActiveDirectory.GraphClient" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.KeyVault" version="2.3.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.KeyVault.WebKey" version="2.0.6" targetFramework="net452" />
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
Copy link
Member

Choose a reason for hiding this comment

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

@dragav please remove the extra dependencies that were added outside of what previously resided in this file. We recently made some changes to move common dependencies into a separate targets file that is referenced by all projects, so anything defined in that target should not exist in your csproj file or packages.config

Assert-NotNull $createdCert2

Get-AzureKeyVaultCertificate $keyVault | Where-Object {$_.CertificateName -like $rootCertName + '*'} | Remove-AzureKeyVaultCertificate -Force -Confirm:$false
Wait-Seconds 30
Copy link
Member

Choose a reason for hiding this comment

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

@dragav why do we need to wait 30 seconds?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Soft-deletion is an asynchronous operation, performed in the background by a different role.

{
[Cmdlet( VerbsCommon.Undo, "AzureKeyVaultCertificateRemoval",
SupportsShouldProcess = true,
ConfirmImpact = ConfirmImpact.Low,
Copy link
Member

Choose a reason for hiding this comment

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

@dragav why change the ConfirmImpact level?

@@ -20,9 +20,6 @@ Adds a contact for certificate notifications.
### [Add-AzureKeyVaultKey](Add-AzureKeyVaultKey.md)
Creates a key in a key vault or imports a key into a key vault.

### [Add-AzureKeyVaultManagedStorageAccount](Add-AzureKeyVaultManagedStorageAccount.md)
Copy link
Member

Choose a reason for hiding this comment

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

@dragav it seems like this file did not get refreshed properly

@@ -65,7 +65,7 @@ public KeyAttributes()

public DateTime? Updated { get; private set; }

public bool PurgeDisabled { get; private set; }
public string RecoveryLevel { get; private set; }
Copy link
Member

Choose a reason for hiding this comment

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

@dragav removing the PurgeDisabled property is a breaking change. Users who run the following will be broken:

$recoveredKey = Undo-AzureKeyVaultKeyRemoval -VaultName $vault -Name $keyName
$recoveredKey.Attributes.PurgeDisabled

Our recommendation is to keep supporting this property, making it obsolete until the next breaking change release (this fall) when you can then remove it since users will have been warned ahead of time of the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Normally I'd heed your recommendation; in this case, however, the presence of this field has security implications. The server protocol does not include this field, and a default here conveys the wrong information. I would rather have the client be broken (and make a quick script change) than use incorrect information.

Furthermore, the previous PSH release was based on a non-public KV SDK; that is, this field should have been considered "pre-release" via PSH as well, but we did not find a way to mark it as such. This PSH release uses a public KV SDK, and so it is in line with the REST API spec and the service itself.

I can add this as an entry to the breaking change log..

Copy link
Member

Choose a reason for hiding this comment

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

We don't have the option of the client being broken, we will not ship any breaking changes until November, except in the case of critical security issues or other critical bugs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can't be a breaking change, since PurgeDisabled was never part of the service REST API spec. Yes, there is a publicly-released PowerShell out there which includes PurgeDisabled, but nobody should have taken a dependency on that since the feature was in preview.

Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately, no breaking changes are a hard requirement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood; reverted the breaking change.

@@ -36,7 +36,7 @@ internal KeyIdentityItem(Azure.KeyVault.Models.KeyItem keyItem, VaultUriHelper v
NotBefore = keyItem.Attributes.NotBefore;
Created = keyItem.Attributes.Created;
Updated = keyItem.Attributes.Updated;
PurgeDisabled = keyItem.Attributes.PurgeDisabled;
Copy link
Member

Choose a reason for hiding this comment

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

@dragav same comment throughout this file

@@ -27,7 +27,7 @@ namespace Microsoft.Azure.Commands.KeyVault
SupportsShouldProcess = true,
ConfirmImpact = ConfirmImpact.High,
HelpUri = Constants.KeyVaultHelpUri)]
[OutputType(typeof(KeyVaultCertificate))]
[OutputType(typeof(DeletedCertificateBundle))]
Copy link
Member

Choose a reason for hiding this comment

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

@dragav nothing has changed about the output of this cmdlet, right? It is still returning a KeyVaultCertificate below the block of code you added. The block you added does not write any object to the output stream, either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what you mean.. The response of this cmdlet is instantiated on line 93:

DeletedCertificateBundle certBundle = null;

The DataServiceClient (invoked to delete the cert) returns:

DeletedCertificateBundle DeleteCertificate(string vaultName, string certName);

Copy link
Member

Choose a reason for hiding this comment

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

@dragav the object being written to the output stream is still a KeyVaultCertificate on line 111, so the output type has not changed

@cormacpayne
Copy link
Member

@markcowl
Copy link
Member

@azuresdkci retest this please

@cormacpayne cormacpayne changed the base branch from release-4.3.0 to preview August 25, 2017 22:42
Dragos Avadanei added 2 commits August 28, 2017 13:40
Copy link
Member

@cormacpayne cormacpayne left a comment

Choose a reason for hiding this comment

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

@dragav please open a new PR that fixes the error in the change log

@@ -24,6 +24,10 @@
## Version 3.3.0

## Version 3.2.1
* New/updated Cmdlets to support soft-delete for KeyVault certificates
Copy link
Member

Choose a reason for hiding this comment

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

@dragav please move this to under Current Release; the versions that are already listed are the notes from previous releases

@cormacpayne cormacpayne merged commit 7d70753 into Azure:preview Aug 28, 2017
@dragav dragav deleted the feature/updates4aug branch August 29, 2017 01:14
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