Class Rule
- All Implemented Interfaces:
Serializable,SdkPojo,ToCopyableBuilder<Rule.Builder,Rule>
A single rule, which you can use in a WebACL or RuleGroup to identify web requests that you want to manage in some way. Each rule includes one top-level Statement that WAF uses to identify matching web requests, and parameters that govern how WAF handles them.
- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionfinal RuleActionaction()The action that WAF should take on a web request when it matches the rule statement.static Rule.Builderbuilder()final CaptchaConfigSpecifies how WAF should handleCAPTCHAevaluations.final ChallengeConfigSpecifies how WAF should handleChallengeevaluations.final booleanfinal booleanequalsBySdkFields(Object obj) Indicates whether some other object is "equal to" this one by SDK fields.final <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) final inthashCode()final booleanFor responses, this returns true if the service returned a value for the RuleLabels property.final Stringname()The name of the rule.final OverrideActionThe action to use in the place of the action that results from the rule group evaluation.final Integerpriority()If you define more than oneRulein aWebACL, WAF evaluates each request against theRulesin order based on the value ofPriority.Labels to apply to web requests that match the rule match statement.static Class<? extends Rule.Builder> final StatementThe WAF processing statement for the rule, for example ByteMatchStatement or SizeConstraintStatement.Take this object and create a builder that contains all of the current property values of this object.final StringtoString()Returns a string representation of this object.final VisibilityConfigDefines and enables Amazon CloudWatch metrics and web request sample collection.Methods inherited from interface software.amazon.awssdk.utils.builder.ToCopyableBuilder
copy
-
Method Details
-
name
The name of the rule.
If you change the name of a
Ruleafter you create it and you want the rule's metric name to reflect the change, update the metric name in the rule'sVisibilityConfigsettings. WAF doesn't automatically update the metric name when you update the rule name.- Returns:
- The name of the rule.
If you change the name of a
Ruleafter you create it and you want the rule's metric name to reflect the change, update the metric name in the rule'sVisibilityConfigsettings. WAF doesn't automatically update the metric name when you update the rule name.
-
priority
If you define more than one
Rulein aWebACL, WAF evaluates each request against theRulesin order based on the value ofPriority. WAF processes rules with lower priority first. The priorities don't need to be consecutive, but they must all be different.- Returns:
- If you define more than one
Rulein aWebACL, WAF evaluates each request against theRulesin order based on the value ofPriority. WAF processes rules with lower priority first. The priorities don't need to be consecutive, but they must all be different.
-
statement
The WAF processing statement for the rule, for example ByteMatchStatement or SizeConstraintStatement.
- Returns:
- The WAF processing statement for the rule, for example ByteMatchStatement or SizeConstraintStatement.
-
action
The action that WAF should take on a web request when it matches the rule statement. Settings at the web ACL level can override the rule action setting.
This is used only for rules whose statements do not reference a rule group. Rule statements that reference a rule group include
RuleGroupReferenceStatementandManagedRuleGroupStatement.You must specify either this
Actionsetting or the ruleOverrideActionsetting, but not both:-
If the rule statement does not reference a rule group, use this rule action setting and not the rule override action setting.
-
If the rule statement references a rule group, use the override action setting and not this action setting.
- Returns:
- The action that WAF should take on a web request when it matches the rule statement. Settings at the web
ACL level can override the rule action setting.
This is used only for rules whose statements do not reference a rule group. Rule statements that reference a rule group include
RuleGroupReferenceStatementandManagedRuleGroupStatement.You must specify either this
Actionsetting or the ruleOverrideActionsetting, but not both:-
If the rule statement does not reference a rule group, use this rule action setting and not the rule override action setting.
-
If the rule statement references a rule group, use the override action setting and not this action setting.
-
-
-
overrideAction
The action to use in the place of the action that results from the rule group evaluation. Set the override action to none to leave the result of the rule group alone. Set it to count to override the result to count only.
You can only use this for rule statements that reference a rule group, like
RuleGroupReferenceStatementandManagedRuleGroupStatement.This option is usually set to none. It does not affect how the rules in the rule group are evaluated. If you want the rules in the rule group to only count matches, do not use this and instead use the rule action override option, with
Countaction, in your rule group reference statement settings.- Returns:
- The action to use in the place of the action that results from the rule group evaluation. Set the
override action to none to leave the result of the rule group alone. Set it to count to override the
result to count only.
You can only use this for rule statements that reference a rule group, like
RuleGroupReferenceStatementandManagedRuleGroupStatement.This option is usually set to none. It does not affect how the rules in the rule group are evaluated. If you want the rules in the rule group to only count matches, do not use this and instead use the rule action override option, with
Countaction, in your rule group reference statement settings.
-
hasRuleLabels
public final boolean hasRuleLabels()For responses, this returns true if the service returned a value for the RuleLabels property. This DOES NOT check that the value is non-empty (for which, you should check theisEmpty()method on the property). This is useful because the SDK will never return a null collection or map, but you may need to differentiate between the service returning nothing (or null) and the service returning an empty collection or map. For requests, this returns true if a value for the property was specified in the request builder, and false if a value was not specified. -
ruleLabels
Labels to apply to web requests that match the rule match statement. WAF applies fully qualified labels to matching web requests. A fully qualified label is the concatenation of a label namespace and a rule label. The rule's rule group or web ACL defines the label namespace.
Any rule that isn't a rule group reference statement or managed rule group statement can add labels to matching web requests.
Rules that run after this rule in the web ACL can match against these labels using a
LabelMatchStatement.For each label, provide a case-sensitive string containing optional namespaces and a label name, according to the following guidelines:
-
Separate each component of the label with a colon.
-
Each namespace or name can have up to 128 characters.
-
You can specify up to 5 namespaces in a label.
-
Don't use the following reserved words in your label specification:
aws,waf,managed,rulegroup,webacl,regexpatternset, oripset.
For example,
myLabelNameornameSpace1:nameSpace2:myLabelName.Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
This method will never return null. If you would like to know whether the service returned this field (so that you can differentiate between null and empty), you can use the
hasRuleLabels()method.- Returns:
- Labels to apply to web requests that match the rule match statement. WAF applies fully qualified labels
to matching web requests. A fully qualified label is the concatenation of a label namespace and a rule
label. The rule's rule group or web ACL defines the label namespace.
Any rule that isn't a rule group reference statement or managed rule group statement can add labels to matching web requests.
Rules that run after this rule in the web ACL can match against these labels using a
LabelMatchStatement.For each label, provide a case-sensitive string containing optional namespaces and a label name, according to the following guidelines:
-
Separate each component of the label with a colon.
-
Each namespace or name can have up to 128 characters.
-
You can specify up to 5 namespaces in a label.
-
Don't use the following reserved words in your label specification:
aws,waf,managed,rulegroup,webacl,regexpatternset, oripset.
For example,
myLabelNameornameSpace1:nameSpace2:myLabelName. -
-
-
visibilityConfig
Defines and enables Amazon CloudWatch metrics and web request sample collection.
If you change the name of a
Ruleafter you create it and you want the rule's metric name to reflect the change, update the metric name as well. WAF doesn't automatically update the metric name.- Returns:
- Defines and enables Amazon CloudWatch metrics and web request sample collection.
If you change the name of a
Ruleafter you create it and you want the rule's metric name to reflect the change, update the metric name as well. WAF doesn't automatically update the metric name.
-
captchaConfig
Specifies how WAF should handle
CAPTCHAevaluations. If you don't specify this, WAF uses theCAPTCHAconfiguration that's defined for the web ACL.- Returns:
- Specifies how WAF should handle
CAPTCHAevaluations. If you don't specify this, WAF uses theCAPTCHAconfiguration that's defined for the web ACL.
-
challengeConfig
Specifies how WAF should handle
Challengeevaluations. If you don't specify this, WAF uses the challenge configuration that's defined for the web ACL.- Returns:
- Specifies how WAF should handle
Challengeevaluations. If you don't specify this, WAF uses the challenge configuration that's defined for the web ACL.
-
toBuilder
Description copied from interface:ToCopyableBuilderTake this object and create a builder that contains all of the current property values of this object.- Specified by:
toBuilderin interfaceToCopyableBuilder<Rule.Builder,Rule> - Returns:
- a builder for type T
-
builder
-
serializableBuilderClass
-
hashCode
-
equals
-
equalsBySdkFields
Description copied from interface:SdkPojoIndicates whether some other object is "equal to" this one by SDK fields. An SDK field is a modeled, non-inherited field in anSdkPojoclass, and is generated based on a service model.If an
SdkPojoclass does not have any inherited fields,equalsBySdkFieldsandequalsare essentially the same.- Specified by:
equalsBySdkFieldsin interfaceSdkPojo- Parameters:
obj- the object to be compared with- Returns:
- true if the other object equals to this object by sdk fields, false otherwise.
-
toString
-
getValueForField
-
sdkFields
-
sdkFieldNameToField
- Specified by:
sdkFieldNameToFieldin interfaceSdkPojo- Returns:
- The mapping between the field name and its corresponding field.
-