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

[Application Gateway] Add WAF properties for request body checking #3093

Merged
merged 1 commit into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 28 additions & 5 deletions azurerm/resource_arm_application_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,17 @@ func resourceArmApplicationGateway() *schema.Resource {
ValidateFunc: validation.IntBetween(1, 500),
Default: 100,
},
"request_body_check": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"max_request_body_size_kb": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(1, 128),
Default: 128,
},
},
},
},
Expand Down Expand Up @@ -2278,13 +2289,17 @@ func expandApplicationGatewayWafConfig(d *schema.ResourceData) *network.Applicat
ruleSetType := v["rule_set_type"].(string)
ruleSetVersion := v["rule_set_version"].(string)
fileUploadLimitInMb := v["file_upload_limit_mb"].(int)
requestBodyCheck := v["request_body_check"].(bool)
maxRequestBodySizeInKb := v["max_request_body_size_kb"].(int)

return &network.ApplicationGatewayWebApplicationFirewallConfiguration{
Enabled: utils.Bool(enabled),
FirewallMode: network.ApplicationGatewayFirewallMode(mode),
RuleSetType: utils.String(ruleSetType),
RuleSetVersion: utils.String(ruleSetVersion),
FileUploadLimitInMb: utils.Int32(int32(fileUploadLimitInMb)),
Enabled: utils.Bool(enabled),
FirewallMode: network.ApplicationGatewayFirewallMode(mode),
RuleSetType: utils.String(ruleSetType),
RuleSetVersion: utils.String(ruleSetVersion),
FileUploadLimitInMb: utils.Int32(int32(fileUploadLimitInMb)),
RequestBodyCheck: utils.Bool(requestBodyCheck),
MaxRequestBodySizeInKb: utils.Int32(int32(maxRequestBodySizeInKb)),
}
}

Expand Down Expand Up @@ -2314,6 +2329,14 @@ func flattenApplicationGatewayWafConfig(input *network.ApplicationGatewayWebAppl
output["file_upload_limit_mb"] = int(*input.FileUploadLimitInMb)
}

if input.RequestBodyCheck != nil {
output["request_body_check"] = *input.RequestBodyCheck
}

if input.MaxRequestBodySizeInKb != nil {
output["max_request_body_size_kb"] = int(*input.MaxRequestBodySizeInKb)
}

results = append(results, output)

return results
Expand Down
4 changes: 4 additions & 0 deletions azurerm/resource_arm_application_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ func TestAccAzureRMApplicationGateway_webApplicationFirewall(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "waf_configuration.0.rule_set_type", "OWASP"),
resource.TestCheckResourceAttr(resourceName, "waf_configuration.0.rule_set_version", "3.0"),
resource.TestCheckResourceAttr(resourceName, "waf_configuration.0.file_upload_limit_mb", "100"),
resource.TestCheckResourceAttr(resourceName, "waf_configuration.0.request_body_check", "true"),
resource.TestCheckResourceAttr(resourceName, "waf_configuration.0.max_request_body_size_kb", "100"),
),
},
},
Expand Down Expand Up @@ -1435,6 +1437,8 @@ resource "azurerm_application_gateway" "test" {
rule_set_type = "OWASP"
rule_set_version = "3.0"
file_upload_limit_mb = 100
request_body_check = true
max_request_body_size_kb = 100
}

gateway_ip_configuration {
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/application_gateway.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,10 @@ A `waf_configuration` block supports the following:

* `file_upload_limit_mb` - (Optional) The File Upload Limit in MB. Accepted values are in the range `1`MB to `500`MB. Defaults to `100`MB.

* `request_body_check` - (Optional) Is Request Body Inspection enabled? Defaults to `true`.

* `max_request_body_size_kb` - (Optional) The Maximum Request Body Size in KB. Accepted values are in the range `1`KB to `128`KB. Defaults to `128`KB.

---

A `custom_error_configuration` block supports the following:
Expand Down