Adding a WAF exclusion rule
- In the management console
, select the folder containing the WAF profile. - In the list of services, select Smart Web Security.
- In the left-hand panel, select WAF profiles.
- Select the profile where you want to add an exclusion rule.
- In the left-hand menu, go to the
Exclusion rules tab and click Create exception rule. In the window that opens:-
Name the exclusion rule.
-
Optionally, provide a description.
-
Optionally, enable Write logs to log exception rule triggering.
-
Under Scope of use, select rules from the basic set to which the exclusion will apply:
-
All rules
: Exclusion will apply to all rules. -
Selected rules
: Exclusion will apply to the selected rules.Click Add rules to select rules from the basic set.
-
-
Under Traffic conditions, specify the traffic the rule will apply to:
-
All traffic
: Rule will apply to all traffic. -
On condition
: Rule will apply to the traffic defined in the Conditions field:IP
: IP address, IP address range, or IP address region.HTTP header
: HTTP header string.HTTP body
: HTTP body string.Request URI
: Request path.Host
: Domain receiving the request.HTTP method
: Request method.Cookie
: Cookie header string.
You can set multiple conditions of the same type by selecting all the condition types you need in the Conditions field.
You can also set multiple conditions of the same type at the same time by clicking
and or or in the section with the condition you need.To delete a condition, click
.
-
-
Click Create.
-
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
Open the Terraform configuration file and edit the
yandex_sws_waf_profile
description: add theexclusion_rule
section with a WAF exclusion rule.# WAF profile resource "yandex_sws_waf_profile" "default" { name = "waf-profile-default" core_rule_set { inbound_anomaly_score = 2 paranoia_level = local.waf_paranoia_level rule_set { name = "OWASP Core Ruleset" version = "4.0.0" } } ... # Exclusion rule exclusion_rule { name = "<exclusion_rule_name>" exclude_rules { exclude_all = <true_or_false> rule_ids = ["rule_1_ID","rule_2_ID"] } } }
Where:
exclusion_rule
:name
: Exclusion rule name.exclude_rules
: Exclusion rule settings:exclude_all
: Exclusion will apply to all rules. It can be eitherfalse
ortrue
.rule_ids
: List of IDs of rules from the basic set to which the exclusion will apply. To specify individual rules, setexclude_all
tofalse
.
For more information about
sws_waf_profile
properties, see this Terraform provider article . -
Create the resources:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validate
If the configuration is correct, you will get this message:
Success! The configuration is valid.
-
Run this command:
terraform plan
You will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply
-
Type
yes
and press Enter to confirm the changes.
-
You can check the resource updates in the management console
Use the update REST API method for the WafProfile resource or the WafProfile/Update gRPC API call.