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

azurerm_web_application_firewall_policy - fix the value of rule_group_name does not exist for Application Gateway Firewall #24194

Merged
merged 3 commits into from
Dec 14, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
)

// ValidateWebApplicationFirewallPolicyRuleGroupName the following command will return a list of available Rule Group Names with information on whether the rules are GA, Deprecated, etc.:
// az rest --method get --url “https://management.azure.com/subscriptions/{subscription_id_here}/providers/Microsoft.Network/locations/{location}/applicationGatewayWafDynamicManifests/default?api-version=2023-05-01” --query “properties.availableRuleSets[].ruleGroups[].ruleGroupName” | sort | uniq
var ValidateWebApplicationFirewallPolicyRuleGroupName = validation.StringInSlice([]string{
"BadBots",
"crs_20_protocol_violations",
Expand All @@ -19,8 +21,10 @@ var ValidateWebApplicationFirewallPolicyRuleGroupName = validation.StringInSlice
"crs_41_xss_attacks",
"crs_42_tight_security",
"crs_45_trojans",
"crs_49_inbound_blocking",
"General",
"GoodBots",
"KnownBadBots",
"Known-CVEs",
"REQUEST-911-METHOD-ENFORCEMENT",
"REQUEST-913-SCANNER-DETECTION",
Expand All @@ -38,15 +42,15 @@ var ValidateWebApplicationFirewallPolicyRuleGroupName = validation.StringInSlice
"METHOD-ENFORCEMENT",
"PROTOCOL-ENFORCEMENT",
"PROTOCOL-ATTACK",
"APPLICATION-ATTACK-LFI",
"APPLICATION-ATTACK-RFI",
"APPLICATION-ATTACK-RCE",
"APPLICATION-ATTACK-PHP",
"APPLICATION-ATTACK-NodeJS",
"APPLICATION-ATTACK-XSS",
"APPLICATION-ATTACK-SQLI",
"APPLICATION-ATTACK-SESSION-FIXATION",
"APPLICATION-ATTACK-SESSION-JAVA",
"LFI",
Copy link
Member

Choose a reason for hiding this comment

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

Looking into this further there is a command which returns a list of supported rule set names and there are two that are still missing. Can you please add crs_49_inbound_blocking and KnownBadBots to the validation.

Can you also please add the following comment in this validation function - It will be helpful to ensure this list remains up to date:

// The following command will return a list of available Rule Group Names with information on whether the rules are GA, Deprecated, etc.:
// az rest --method get --url “https://management.azure.com/subscriptions/{subscription_id_here}/providers/Microsoft.Network/locations/{location}/applicationGatewayWafDynamicManifests/default?api-version=2023-05-01” --query “properties.availableRuleSets[].ruleGroups[].ruleGroupName” | sort | uniq

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great suggestion about adding above comment, the code has been updated. Could you please take a look at it again?

"RFI",
"RCE",
"PHP",
"NODEJS",
"XSS",
"SQLI",
"FIX",
"JAVA",
"MS-ThreatIntel-WebShells",
"MS-ThreatIntel-AppSec",
"MS-ThreatIntel-SQLI",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,87 @@ resource "azurerm_web_application_firewall_policy" "test" {
action = "Log"
}
}

rule_group_override {
rule_group_name = "LFI"
rule {
id = "930100"
enabled = false
action = "Log"
}
}

rule_group_override {
rule_group_name = "RFI"
rule {
id = "931100"
enabled = false
action = "Log"
}
}

rule_group_override {
rule_group_name = "RCE"
rule {
id = "932100"
enabled = false
action = "Log"
}
}

rule_group_override {
rule_group_name = "PHP"
rule {
id = "933100"
enabled = false
action = "Log"
}
}

rule_group_override {
rule_group_name = "NODEJS"
rule {
id = "934100"
enabled = false
action = "Log"
}
}

rule_group_override {
rule_group_name = "XSS"
rule {
id = "941100"
enabled = false
action = "Log"
}
}

rule_group_override {
rule_group_name = "SQLI"
rule {
id = "942100"
enabled = false
action = "Log"
}
}

rule_group_override {
rule_group_name = "FIX"
rule {
id = "943100"
enabled = false
action = "Log"
}
}

rule_group_override {
rule_group_name = "JAVA"
rule {
id = "944100"
enabled = false
action = "Log"
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ The `managed_rule_set` block supports the following:

The `rule_group_override` block supports the following:

* `rule_group_name` - (Required) The name of the Rule Group. Possible values are `BadBots`, `crs_20_protocol_violations`, `crs_21_protocol_anomalies`, `crs_23_request_limits`, `crs_30_http_policy`, `crs_35_bad_robots`, `crs_40_generic_attacks`, `crs_41_sql_injection_attacks`, `crs_41_xss_attacks`, `crs_42_tight_security`, `crs_45_trojans`, `General`, `GoodBots`, `Known-CVEs`, `REQUEST-911-METHOD-ENFORCEMENT`, `REQUEST-913-SCANNER-DETECTION`, `REQUEST-920-PROTOCOL-ENFORCEMENT`, `REQUEST-921-PROTOCOL-ATTACK`, `REQUEST-930-APPLICATION-ATTACK-LFI`, `REQUEST-931-APPLICATION-ATTACK-RFI`, `REQUEST-932-APPLICATION-ATTACK-RCE`, `REQUEST-933-APPLICATION-ATTACK-PHP`, `REQUEST-941-APPLICATION-ATTACK-XSS`, `REQUEST-942-APPLICATION-ATTACK-SQLI`, `REQUEST-943-APPLICATION-ATTACK-SESSION-FIXATION`, `REQUEST-944-APPLICATION-ATTACK-JAVA` `UnknownBots`, `METHOD-ENFORCEMENT`, `PROTOCOL-ENFORCEMENT`, `PROTOCOL-ATTACK`, `APPLICATION-ATTACK-LFI`, `APPLICATION-ATTACK-RFI`, `APPLICATION-ATTACK-RCE`, `APPLICATION-ATTACK-PHP`, `APPLICATION-ATTACK-NodeJS`, `APPLICATION-ATTACK-XSS`, `APPLICATION-ATTACK-SQLI`, `APPLICATION-ATTACK-SESSION-FIXATION`, `APPLICATION-ATTACK-SESSION-JAVA`, `MS-ThreatIntel-WebShells`,
* `rule_group_name` - (Required) The name of the Rule Group. Possible values are `BadBots`, `crs_20_protocol_violations`, `crs_21_protocol_anomalies`, `crs_23_request_limits`, `crs_30_http_policy`, `crs_35_bad_robots`, `crs_40_generic_attacks`, `crs_41_sql_injection_attacks`, `crs_41_xss_attacks`, `crs_42_tight_security`, `crs_45_trojans`, `crs_49_inbound_blocking`, General`, `GoodBots`, `KnownBadBots`, `Known-CVEs`, `REQUEST-911-METHOD-ENFORCEMENT`, `REQUEST-913-SCANNER-DETECTION`, `REQUEST-920-PROTOCOL-ENFORCEMENT`, `REQUEST-921-PROTOCOL-ATTACK`, `REQUEST-930-APPLICATION-ATTACK-LFI`, `REQUEST-931-APPLICATION-ATTACK-RFI`, `REQUEST-932-APPLICATION-ATTACK-RCE`, `REQUEST-933-APPLICATION-ATTACK-PHP`, `REQUEST-941-APPLICATION-ATTACK-XSS`, `REQUEST-942-APPLICATION-ATTACK-SQLI`, `REQUEST-943-APPLICATION-ATTACK-SESSION-FIXATION`, `REQUEST-944-APPLICATION-ATTACK-JAVA` `UnknownBots`, `METHOD-ENFORCEMENT`, `PROTOCOL-ENFORCEMENT`, `PROTOCOL-ATTACK`, `LFI`, `RFI`, `RCE`, `PHP`, `NODEJS`, `XSS`, `SQLI`, `FIX`, `JAVA`, `MS-ThreatIntel-WebShells`,

* `rule` - (Optional) One or more `rule` block defined below.

Expand Down
Loading