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

allow SocketAddr to be used as a match_variable #8244

Merged
merged 3 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -167,6 +167,7 @@ func resourceArmFrontDoorFirewallPolicy() *schema.Resource {
string(frontdoor.RequestHeader),
string(frontdoor.RequestMethod),
string(frontdoor.RequestURI),
string(frontdoor.SocketAddr),
gchappel marked this conversation as resolved.
Show resolved Hide resolved
}, false),
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func TestAccAzureRMFrontDoorFirewallPolicy_update(t *testing.T) {
resource.TestCheckResourceAttr(data.ResourceName, "name", fmt.Sprintf("testAccFrontDoorWAF%d", data.RandomInteger)),
resource.TestCheckResourceAttr(data.ResourceName, "mode", "Prevention"),
resource.TestCheckResourceAttr(data.ResourceName, "custom_rule.1.name", "Rule2"),
resource.TestCheckResourceAttr(data.ResourceName, "custom_rule.2.name", "Rule3"),
),
},
{
Expand Down Expand Up @@ -336,6 +337,32 @@ resource "azurerm_frontdoor_firewall_policy" "test" {
}
}

custom_rule {
name = "Rule3"
enabled = true
priority = 2
gchappel marked this conversation as resolved.
Show resolved Hide resolved
rate_limit_duration_in_minutes = 1
rate_limit_threshold = 10
type = "MatchRule"
action = "Block"

match_condition {
match_variable = "SocketAddr"
operator = "IPMatch"
negation_condition = false
match_values = ["192.168.1.0/24"]
}

match_condition {
match_variable = "RequestHeader"
selector = "UserAgent"
operator = "Contains"
negation_condition = false
match_values = ["windows"]
transforms = ["Lowercase", "Trim"]
}
}

managed_rule {
type = "DefaultRuleSet"
version = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/frontdoor_firewall_policy.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ The `custom_rule` block supports the following:

The `match_condition` block supports the following:

* `match_variable` - (Required) The request variable to compare with. Possible values are `Cookies`, `PostArgs`, `QueryString`, `RemoteAddr`, `RequestBody`, `RequestHeader`, `RequestMethod`, or `RequestUri`.
* `match_variable` - (Required) The request variable to compare with. Possible values are `Cookies`, `PostArgs`, `QueryString`, `RemoteAddr`, `RequestBody`, `RequestHeader`, `RequestMethod`, `RequestUri`, or `SocketAddr`.

* `match_values` - (Required) Up to `100` possible values to match.

Expand Down