Skip to content

Commit

Permalink
[Network] `az network application-gateway waf-policy custom-rule matc…
Browse files Browse the repository at this point in the history
…h-condition add`: Add validation for WAF custom rule condition (#23137)

* add validation for WAF custom rule condition

* add test cases

* fix style check
  • Loading branch information
necusjz authored Jul 26, 2022
1 parent 5fc7511 commit 86f9769
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 104 deletions.
9 changes: 7 additions & 2 deletions src/azure-cli/azure/cli/command_modules/network/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1931,8 +1931,13 @@ def delete_waf_custom_rule(cmd, client, resource_group_name, policy_name, rule_n


# region ApplicationGatewayWAFPolicyRuleMatchConditions
def add_waf_custom_rule_match_cond(cmd, client, resource_group_name, policy_name, rule_name,
match_variables, operator, match_values, negation_condition=None, transforms=None):
def add_waf_custom_rule_match_cond(cmd, client, resource_group_name, policy_name, rule_name, match_variables, operator,
match_values=None, negation_condition=None, transforms=None):
if operator.lower() == "any" and match_values is not None:
raise ArgumentUsageError("Any operator does not require --match-values.")
if operator.lower() != "any" and match_values is None:
raise ArgumentUsageError("Non-any operator requires --match-values.")

MatchCondition = cmd.get_models('MatchCondition')
waf_policy = client.get(resource_group_name, policy_name)
custom_rule = find_child_item(waf_policy, rule_name, path='custom_rules', key_path='name')
Expand Down
Loading

0 comments on commit 86f9769

Please sign in to comment.