Skip to content

#WAF Adding WAF support to PowerShell#3678

Merged
cormacpayne merged 26 commits into
Azure:devfrom
jobatzil:feature/jobatzil/waf
Mar 31, 2017
Merged

#WAF Adding WAF support to PowerShell#3678
cormacpayne merged 26 commits into
Azure:devfrom
jobatzil:feature/jobatzil/waf

Conversation

@jobatzil
Copy link
Copy Markdown
Contributor

@jobatzil jobatzil commented Mar 28, 2017

Description

Add support of newest WAF functionality to PowerShell.


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.

@msftclas
Copy link
Copy Markdown

@jobatzil,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

Copy link
Copy Markdown
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.

@jobatzil Hey Johannes, a couple of comments that need to be resolved

<Reference Include="Microsoft.Azure.Management.Network, Version=9.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.9.1.0-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
<Reference Include="Microsoft.Azure.Management.Network, Version=9.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.9.2.0-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jobatzil 10.0.0-preview

@@ -7,7 +7,7 @@
<package id="Microsoft.Azure.Graph.RBAC" version="3.2.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Compute" version="14.0.0-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="9.1.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="9.2.0-preview" targetFramework="net45" />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jobatzil 10.0.0-preview

Mandatory = true,
HelpMessage = "The version of the rule set type.")]
[ValidateNotNullOrEmpty]
public string RuleSetVersion { get; set; }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jobatzil adding parameters RuleSetType and RuleSetVersion that are mandatory is a breaking change - existing scripts that use these cmdlets will not work

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is also mandatory in the new azure-sdk

@@ -17,24 +17,24 @@

namespace Microsoft.Azure.Commands.Network
{
[Cmdlet(VerbsCommon.New, "AzureRmApplicationGatewayWebApplicationFirewallConfiguration", SupportsShouldProcess = true),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jobatzil why was this removed?

Copy link
Copy Markdown
Contributor Author

@jobatzil jobatzil Mar 28, 2017

Choose a reason for hiding this comment

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

it only changes the local object, it shouldn't have been there in the first place.

@@ -17,7 +17,7 @@

namespace Microsoft.Azure.Commands.Network
{
[Cmdlet(VerbsCommon.Set, "AzureRmApplicationGatewayWebApplicationFirewallConfiguration", SupportsShouldProcess = true),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jobatzil why was this removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

same as above.

[Parameter(
Mandatory = false,
HelpMessage = "The list of rules that will be disabled. If null, all rules of the rule group will be disabled.")]
public List<int> Rules { get; set; }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jobatzil according to PowerShell Strongly Encouraged Development Guidelines, parameter nouns should be singular:

Avoid using plural names for parameters whose value is a single element. This includes parameters that take arrays or lists because the user might supply an array or list with only one element.

Let's think of a different noun that can be used instead of Rules. How does RuleList work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, this is the name we use on every level (powershell, azure-ask, backend)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will leave it like that to keep it consistent.


namespace Microsoft.Azure.Commands.Network
{
[Cmdlet(VerbsCommon.New, "AzureRmApplicationGatewayFirewallDisabledRuleGroupConfig"),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jobatzil I'm worried that the name of this cmdlet is too long. Is there any way we can keep the name, but add an alias to something shorter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As discussed offline, there is no shorter name that still matches our current pattern. We are actually thinking of introducing shorter aliases for all of the cmdlets (agw instead of applicationGateway?), this will not be part of this PR though.

public List<PSApplicationGatewayFirewallRuleSet> Value { get; set; }

[JsonIgnore]
public string ValueText
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jobatzil for each of the classes you are adding to the Model folder, can you make sure that each of their properties have corresponding help with them?

/// <summary>
/// Brief summary of property.
/// </summary>
public string ValueText
{
    ...
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We've never done that before, but I can do that.

@@ -30,6 +30,13 @@ public ApplicationGatewayTests(ITestOutputHelper output)

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAvailableWafRuleSets()
{
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-AvailableWafRuleSets -baseDir '{0}'", AppDomain.CurrentDomain.BaseDirectory));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jobatzil was there a test recording file associated with this test? I didn't see one. If so, make sure it is added in the test csproj file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, but it is not uploaded yet, I may change the cmdlet before it gets finalized.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I uploaded the test recordings.

@jobatzil
Copy link
Copy Markdown
Contributor Author

@cormacpayne I didn't update the TestApplicationGatewayCRUD test recordings yet.

@cormacpayne cormacpayne merged commit bc5c27c into Azure:dev Mar 31, 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.

5 participants