Overview
Bot policy configuration defines rules for identifying and handling different types of traffic. Each rule specifies matching criteria and an action to take when traffic matches.BotConfig
Defines a bot detection rule with matching criteria and action.Type Definition
Fields
Unique identifier for this bot rule. Used in logs and metrics.
Regular expression to match against the User-Agent header. Cannot be used with
PathRegex.Regular expression to match against the request path. Cannot be used with
UserAgentRegex.Map of header names to regular expressions. All specified headers must match for the rule to apply.
CEL (Common Expression Language) expression for advanced matching logic. See ExpressionOrList.
List of CIDR ranges to match against the client IP address (e.g.,
"192.168.1.0/24").Challenge configuration when
Action is CHALLENGE. See challenge-rules.Weight adjustment when
Action is WEIGH. If not set, defaults to {Adjust: 5}.Validation Rules
- Must set
Name - Must set at least one matching criterion:
UserAgentRegex,PathRegex,HeadersRegex,RemoteAddr,Expression,GeoIP, orASNs - Cannot set both
UserAgentRegexandPathRegex - Regular expressions must not end with newline (use
>-in YAML instead of>) RemoteAddrentries must be valid CIDR notation- If
ActionisCHALLENGE, must setChallenge - If
ActionisWEIGHandWeightis nil, defaults to{Adjust: 5}
Example
Rule Enum
Defines actions to take when traffic matches a bot rule.Type Definition
Values
Immediately allow the request without further checks.
Block the request with a configured status code.
Present a proof-of-work challenge to the client. Requires
Challenge configuration.Add weight to the client’s score. When thresholds are exceeded, triggers challenges or blocks.
Debug action for performance testing. Logs timing without affecting traffic.
ExpressionOrList
Flexible expression matching supporting single expressions or logical combinations.Type Definition
Fields
Single CEL expression. Can be set directly as a string in YAML/JSON.
List of CEL expressions that must all evaluate to true (logical AND).
List of CEL expressions where at least one must evaluate to true (logical OR).
Validation Rules
- Must set either
Expression,All, orAny - Cannot set both
AllandAny
Example
GeoIP
Geographic IP address matching based on country codes.Type Definition
Fields
List of two-letter ISO 3166-1 alpha-2 country codes (case-insensitive).
Validation Rules
- Country codes must be exactly 2 letters matching
[a-zA-Z]{2} - Country codes are normalized to lowercase
Example
ASNs
Autonomous System Number (ASN) matching for network-based rules.Type Definition
Fields
List of ASNs to match against the client’s network.
Validation Rules
- ASNs must not be in private use ranges (RFC 6996):
- 64512-65534
- 4200000000-4294967294
Example
Weight
Score adjustment for traffic matching aWEIGH rule.
Type Definition
Fields
Integer value to add to the client’s weight score. Can be negative to reduce weight.
Example
ImportStatement
Import bot rules from external files.Type Definition
Fields
Path to YAML file containing bot rules. Use
(data)/ prefix to load from embedded data.