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

Merge release-network-2022-11-01 to Main #21829

Merged
merged 32 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
274c8af
Update Set-AzNetworkInterfaceIpConfig.md (#21193)
rnautiyal Mar 14, 2023
5ffb787
PowerShell Live Test Fix for Firewall (#21387)
Gizachew-Eshetie Apr 3, 2023
cbb2a2d
merge main
VeryEarly Apr 3, 2023
79caa9a
Merged with main, resolved conflicts
MikhailTryakhov Apr 3, 2023
859af6b
Merge branch 'main' into sync-main
VeryEarly Apr 6, 2023
5deeb61
Merge pull request #21409 from Azure/sync-main
wyunchi-ms Apr 6, 2023
fb17222
Support Route Map CRUD (#21270)
zaynchen115 Apr 10, 2023
9bc7905
Support Rate Limit Rule For Application Gateway WAF Custom Rule (#21557)
Shawnli222 Apr 19, 2023
80e9ff7
[nva] updating the description (#21599)
JainRah Apr 20, 2023
ad2b51f
[nva] Updating the nva help file using Update-MarkdownHelp (#21607)
JainRah Apr 20, 2023
3b3cdcc
Azfw - add property "httpHeadersToInsert" to Application Rule (#21580)
NiviShenker Apr 23, 2023
582d3cb
Additional Nic (#21630)
JainRah Apr 23, 2023
c76b8a6
[nva] New Cmdlet: New-AzVirtualApplianceAdditionalNicProperty (#21633)
JainRah Apr 25, 2023
f7c280c
[nva] Printing Instance Name during Get-AzNetworkVirtualAppliance (#2…
JainRah Apr 26, 2023
22d6177
Log Scrubbing Feature for Application Gateway Firewall Policy Setting…
Shawnli222 Apr 28, 2023
db25c22
[nva] correcting email alias for test owners (#21657)
JainRah Apr 28, 2023
86ad901
Merge branch 'release-network-2022-11-01' of https://github.com/Azure…
MikhailTryakhov Apr 28, 2023
871a7be
Merge branch 'main' into mitryakh/2022-11-01-sdk
MikhailTryakhov Apr 28, 2023
3328105
Generated new sdk for 2022-11-01
MikhailTryakhov Apr 28, 2023
f446775
merged conflicts
MikhailTryakhov May 1, 2023
e52b742
Fixed the config file
MikhailTryakhov May 2, 2023
c13d515
Updated SDK
MikhailTryakhov May 3, 2023
b3f22e2
updated SDK version
MikhailTryakhov May 3, 2023
fc8c820
Inspection Limit Feature for Application Gateway Firewall Policy Sett…
Shawnli222 May 4, 2023
8231c97
Fixed SDK version
MikhailTryakhov May 4, 2023
372acff
Solved merge failures
MikhailTryakhov May 4, 2023
82c7049
Merge branch 'release-network-2022-11-01' of https://github.com/Azure…
MikhailTryakhov May 4, 2023
b0b43ab
Fixed merge conflicts
MikhailTryakhov May 4, 2023
9790495
Merge pull request #21827 from Azure/mitryakh/2022-11-01-sdk
msJinLei May 16, 2023
3ffc41e
Set Standard SKU as defaults for LB and IP creates (#21709)
phrazfipho May 6, 2023
c3761d1
{Sirius] Adding AuxiliarySku to NetworkInterface (#21517)
pr-work May 11, 2023
f4b8f5a
Remove LocalFeed (#21729)
MikhailTryakhov May 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Inspection Limit Feature for Application Gateway Firewall Policy Sett…
…ings (#21603)

* 2

* 1

* 2

* new change

* final test

* true

* new sdk

* test name

* merge conflict

* description change

* change test case var to false

* help msg for var change

* address comment

* edit help file

* revert previous change

* change var to diabled

* help edit

* null condition

* move condition outside

* help function

* new function to new var

* edit var to nullable
  • Loading branch information
Shawnli222 authored May 4, 2023
commit fc8c820fed3bb64781494954303ae4cc56340d42
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,14 @@ public void TestApplicationGatewayFirewallPolicyWithUppercaseTransform()
TestRunner.RunTestScript("Test-ApplicationGatewayFirewallPolicyWithUppercaseTransform");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.nvadev_subset1)]
public void TestApplicationGatewayFirewallPolicyWithInspectionLimit()
{
TestRunner.RunTestScript("Test-ApplicationGatewayFirewallPolicyWithInspectionLimit");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.nvadev_subset1)]
Expand Down
54 changes: 54 additions & 0 deletions src/Network/Network.Test/ScenarioTests/ApplicationGatewayTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4401,6 +4401,60 @@ function Test-ApplicationGatewayFirewallPolicyWithUppercaseTransform
}
}

function Test-ApplicationGatewayFirewallPolicyWithInspectionLimit
{
# Setup
$location = Get-ProviderLocation "Microsoft.Network/applicationGateways" "West US 2"

$rgname = Get-ResourceGroupName
$wafPolicy = Get-ResourceName

try
{
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $location -Tags @{ testtag = "APPGw tag"}

# WAF Policy and Custom Rule
$variable = New-AzApplicationGatewayFirewallMatchVariable -VariableName RequestHeaders -Selector Content-Length
$condition = New-AzApplicationGatewayFirewallCondition -MatchVariable $variable -Operator GreaterThan -MatchValue 1000 -Transform Uppercase -NegationCondition $False
$rule = New-AzApplicationGatewayFirewallCustomRule -Name example -Priority 2 -RuleType MatchRule -MatchCondition $condition -Action Block
$policySettings = New-AzApplicationGatewayFirewallPolicySetting -Mode Prevention -State Enabled -DisableRequestBodyEnforcement $True -RequestBodyInspectLimitInKB 2000 -MaxFileUploadInMb 70 -DisableFileUploadEnforcement $True -MaxRequestBodySizeInKb 70
$managedRuleSet = New-AzApplicationGatewayFirewallPolicyManagedRuleSet -RuleSetType "OWASP" -RuleSetVersion "3.2"
$managedRule = New-AzApplicationGatewayFirewallPolicyManagedRule -ManagedRuleSet $managedRuleSet
New-AzApplicationGatewayFirewallPolicy -Name $wafPolicy -ResourceGroupName $rgname -Location $location -ManagedRule $managedRule -PolicySetting $policySettings

$policy = Get-AzApplicationGatewayFirewallPolicy -Name $wafPolicy -ResourceGroupName $rgname
$policy.CustomRules = $rule
Set-AzApplicationGatewayFirewallPolicy -InputObject $policy

$policy = Get-AzApplicationGatewayFirewallPolicy -Name $wafPolicy -ResourceGroupName $rgname

# Check firewall policy
Assert-AreEqual $policy.CustomRules[0].Name $rule.Name
Assert-AreEqual $policy.CustomRules[0].RuleType $rule.RuleType
Assert-AreEqual $policy.CustomRules[0].Action $rule.Action
Assert-AreEqual $policy.CustomRules[0].Priority $rule.Priority
Assert-AreEqual $policy.CustomRules[0].MatchConditions[0].OperatorProperty $rule.MatchConditions[0].OperatorProperty
Assert-AreEqual $policy.CustomRules[0].MatchConditions[0].Transforms[0] $rule.MatchConditions[0].Transforms[0]
Assert-AreEqual $policy.CustomRules[0].MatchConditions[0].NegationConditon $rule.MatchConditions[0].NegationConditon
Assert-AreEqual $policy.CustomRules[0].MatchConditions[0].MatchValues[0] $rule.MatchConditions[0].MatchValues[0]
Assert-AreEqual $policy.CustomRules[0].MatchConditions[0].MatchVariables[0].VariableName $rule.MatchConditions[0].MatchVariables[0].VariableName
Assert-AreEqual $policy.CustomRules[0].MatchConditions[0].MatchVariables[0].Selector $rule.MatchConditions[0].MatchVariables[0].Selector
Assert-AreEqual $policy.PolicySettings.FileUploadLimitInMb $policySettings.FileUploadLimitInMb
Assert-AreEqual $policy.PolicySettings.MaxRequestBodySizeInKb $policySettings.MaxRequestBodySizeInKb
Assert-AreEqual $policy.PolicySettings.RequestBodyCheck $policySettings.RequestBodyCheck
Assert-AreEqual $policy.PolicySettings.Mode $policySettings.Mode
Assert-AreEqual $policy.PolicySettings.State $policySettings.State
Assert-AreEqual $False $policySettings.RequestBodyEnforcement
Assert-AreEqual $policy.PolicySettings.RequestBodyInspectLimitInKB $policySettings.RequestBodyInspectLimitInKB
Assert-AreEqual $False $policySettings.FileUploadEnforcement
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

function Test-ApplicationGatewayFirewallPolicyWithCustomBlockResponse
{
# Setup
Expand Down

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/Network/Network/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
- 'New-AzApplicationGatewayFirewallPolicyLogScrubbingRule',
- Also updated cmdlet to add the property of LogScrubbing
- `New-AzApplicationGatewayFirewallPolicySetting`
* Updated cmdlet to add the property of DisableRequestBodyEnforcement, RequestBodyInspectLimitInKB and DisableFileUploadEnforcement
- `New-AzApplicationGatewayFirewallPolicySetting`



## Version 5.6.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ public class AzureApplicationGatewayFirewallPolicySetting : NetworkBaseCmdlet
[ValidateSet("Disabled", "Enabled", IgnoreCase = true)]
[ValidateNotNullOrEmpty]
public string State { get; set; }


[Parameter(Mandatory = false, HelpMessage = "Disable request body enforcement limits for WAF.")]
[ValidateNotNullOrEmpty]
public bool? DisableRequestBodyEnforcement { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Max inspection limit in KB for request body inspection.")]
[ValidateNotNullOrEmpty]
public int? RequestBodyInspectLimitInKB { get; set; }

[Parameter(
HelpMessage = "Disable Request Body check.")]
public SwitchParameter DisableRequestBodyCheck { get; set; }
Expand All @@ -43,6 +51,10 @@ public class AzureApplicationGatewayFirewallPolicySetting : NetworkBaseCmdlet
[ValidateNotNullOrEmpty]
public int MaxRequestBodySizeInKb { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Disable file upload enforcement limits for WAF.")]
[ValidateNotNullOrEmpty]
public bool? DisableFileUploadEnforcement { get; set; }

[Parameter(
HelpMessage = "Maximum fileUpload size in MB.")]
[ValidateNotNullOrEmpty]
Expand Down Expand Up @@ -89,6 +101,21 @@ public override void ExecuteCmdlet()
this.CustomBlockResponseStatusCode = (int?)null;
}

if (!this.MyInvocation.BoundParameters.ContainsKey("RequestBodyInspectLimitInKB"))
{
this.RequestBodyInspectLimitInKB = (int?)null;
}

if (!this.MyInvocation.BoundParameters.ContainsKey("DisableFileUploadEnforcement"))
{
this.DisableFileUploadEnforcement = (bool?)null;
}

if (!this.MyInvocation.BoundParameters.ContainsKey("DisableRequestBodyEnforcement"))
{
this.DisableRequestBodyEnforcement = (bool?)null;
}

if (this.MyInvocation.BoundParameters.ContainsKey("CustomBlockResponseBody"))
{
this.CustomBlockResponseBody = System.Convert.ToBase64String(Encoding.UTF8.GetBytes(CustomBlockResponseBody));
Expand All @@ -102,12 +129,34 @@ public override void ExecuteCmdlet()

protected PSApplicationGatewayFirewallPolicySettings NewObject()
{
bool? RequestBodyEnforcementVal = null;
if (this.DisableRequestBodyEnforcement != null)
{
RequestBodyEnforcementVal = true;
if (this.DisableRequestBodyEnforcement == true)
{
RequestBodyEnforcementVal = false;
}
}
bool? FileUploadEnforcementVal = null;
if (this.DisableFileUploadEnforcement != null)
{
FileUploadEnforcementVal = true;
if (this.DisableFileUploadEnforcement == true)
{
FileUploadEnforcementVal = false;
}
}

return new PSApplicationGatewayFirewallPolicySettings()
{
Mode = this.Mode,
State = this.State,
RequestBodyEnforcement = RequestBodyEnforcementVal,
RequestBodyInspectLimitInKB = this.RequestBodyInspectLimitInKB,
RequestBodyCheck = this.DisableRequestBodyCheck.IsPresent ? false : true,
MaxRequestBodySizeInKb = this.MaxRequestBodySizeInKb,
FileUploadEnforcement = FileUploadEnforcementVal,
FileUploadLimitInMb = this.MaxFileUploadInMb,
CustomBlockResponseBody = this.CustomBlockResponseBody,
CustomBlockResponseStatusCode = this.CustomBlockResponseStatusCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,21 @@ public partial class PSApplicationGatewayFirewallPolicySettings
[Ps1Xml(Target = ViewControl.Table)]
public string Mode { get; set; }

[Ps1Xml(Target = ViewControl.Table)]
public bool? RequestBodyEnforcement { get; set; }

[Ps1Xml(Target = ViewControl.Table)]
public int? RequestBodyInspectLimitInKB { get; set; }

[Ps1Xml(Target = ViewControl.Table)]
public bool RequestBodyCheck { get; set; }

[Ps1Xml(Target = ViewControl.Table)]
public int MaxRequestBodySizeInKb { get; set; }

[Ps1Xml(Target = ViewControl.Table)]
public bool? FileUploadEnforcement { get; set; }

[Ps1Xml(Target = ViewControl.Table)]
public int FileUploadLimitInMb { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Creates a policy setting for the firewall policy
## SYNTAX

```
New-AzApplicationGatewayFirewallPolicySetting [-Mode <String>] [-State <String>] [-DisableRequestBodyCheck]
[-MaxRequestBodySizeInKb <Int32>] [-MaxFileUploadInMb <Int32>] [-CustomBlockResponseStatusCode <Int32>]
New-AzApplicationGatewayFirewallPolicySetting [-Mode <String>] [-State <String>] [-DisableRequestBodyEnforcement <Boolean>] [-RequestBodyInspectLimitInKB <Int32>] [-DisableRequestBodyCheck]
[-MaxRequestBodySizeInKb <Int32>] [-MaxFileUploadInMb <Int32>] [-DisableFileUploadEnforcement <Boolean>] [-CustomBlockResponseStatusCode <Int32>]
[-CustomBlockResponseBody <String>] [-LogScrubbing <PSApplicationGatewayFirewallPolicyLogScrubbingConfiguration>] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

Expand All @@ -39,8 +39,60 @@ $condition = New-AzApplicationGatewayFirewallPolicySetting -State $enabledState
The command creates a policy setting with state as $enabledState, mode as $enabledMode, RequestBodyCheck as false, FileUploadLimitInMb as $fileUploadLimitInMb and MaxRequestBodySizeInKb as $$maxRequestBodySizeInKb with a scrubbing rule as $logScrubbingRuleConfig.
The new policySettings is stored to $condition.

### Example 3
```powershell
$condition = New-AzApplicationGatewayFirewallPolicySetting -State $enabledState -Mode $enabledMode -DisableRequestBodyEnforcement true -RequestBodyInspectLimitInKB 2000 -DisableRequestBodyCheck -MaxFileUploadInMb $fileUploadLimitInMb -DisableFileUploadEnforcement true -MaxRequestBodySizeInKb $maxRequestBodySizeInKb
```

The command creates a policy setting with state as $enabledState, mode as $enabledMode, RequestBodyEnforcement as false, RequestBodyInspectLimitInKB as 2000, RequestBodyCheck as false, FileUploadLimitInMb as $fileUploadLimitInMb, FileUploadEnforcement as false and MaxRequestBodySizeInKb as $$maxRequestBodySizeInKb.

## PARAMETERS

### -DisableRequestBodyEnforcement
Disable request body enforcement limits for WAF.

```yaml
Type: System.Nullable`1[System.Boolean]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -RequestBodyInspectLimitInKB
Max inspection limit in KB for request body inspection.

```yaml
Type: System.Nullable`1[System.Int32]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -DisableFileUploadEnforcement
Disable file upload enforcement limits for WAF.

```yaml
Type: System.Nullable`1[System.Boolean]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -CustomBlockResponseBody
Custom Block Response Body in policy settings of the firewall policy.

Expand Down
Binary file not shown.
Binary file not shown.