Configuration and policy authoring
Anubis configuration defines how requests are identified, scored, challenged, allowed, or denied. A single YAML policy joins global service settings with ordered bot rules and score thresholds, then turns them into the runtime policy used by the request filter.
Configuration model
The configuration has two related layers. Global settings provide the services and defaults that rules depend on, while policy settings describe how request signals change the result for each client.
Global settings
Global settings control shared behavior around policy evaluation and request handling. They cover storage, logging, metrics, DNS and DNS block lists, GeoIP databases, honeypots, Open Graph responses, response status codes, and optional legal page content. These settings do not identify a bot by themselves. They provide the shared resources and defaults used by the policy.
The main global areas are:
| Area | Purpose |
|---|---|
store | Keeps temporary state used by challenges and request handling. |
logging and metrics | Control operational output and measurement. |
geoip and dnsbl | Provide network and location signals to rules. |
honeypot | Adds a trap path that can produce more policy weight. |
openGraph and impressum | Control pages and metadata that Anubis can serve. |
status_codes | Selects the HTTP status returned for challenge and denial results. |
References: lib/…/config.go• L308-320 lib/…/config.go• L412-425 data/botPolicies.yaml• L111-196
Bot rules
Bot rules describe request signals and the action that follows a match. A rule has a name, one or more match sources, and an action such as ALLOW, DENY, CHALLENGE, WEIGH, or DEBUG_BENCHMARK.
Rules can use request text, paths, headers, network ranges, remote address lists, CEL expressions, ASN data, or country data. A WEIGH rule changes the request score instead of making the final decision. This lets several signals combine before a threshold selects the result.
References: lib/…/config.go• L35-53 lib/…/config.go• L57-73 lib/…/policy.go• L150-261
Threshold rules
Threshold rules turn the accumulated request weight into a final policy action. Their expression reads the weight and can choose ALLOW or CHALLENGE; a threshold cannot add more weight. A challenge threshold must define the challenge to send.
When no thresholds are provided, Anubis supplies a compatibility threshold that challenges requests with a positive weight. Explicit thresholds replace that default set, so authoring a threshold list is a policy choice rather than an additive change.
References: lib/…/threshold.go• L17-37 lib/…/threshold.go• L39-78 lib/…/config.go• L464-475
Challenge settings
Challenge settings belong to a bot rule or a threshold. They select the challenge algorithm, its difficulty, and optional extensions. A missing challenge on a matching bot rule uses the process default difficulty and the default algorithm, while a CHALLENGE threshold must state its challenge settings.
References: lib/…/config.go• L212-261 lib/…/policy.go• L235-249
Policy authoring flow
Policy authoring starts with a YAML document that names shared services and rule inputs. Loading expands imports and applies defaults. Validation then checks both the shape of the document and the resources needed to run it. The policy parser compiles the accepted rules into request checks and thresholds.
The diagram shows how author input becomes the runtime policy used by Anubis.
flowchart LR
A[YAML configuration] --> B[Global settings and policy entries]
B --> C[Imported rule data expanded]
C --> D[Schema and resource validation]
D --> E[Parsed bot rules and thresholds]
E --> F[Request evaluation]
F --> G[Allow, challenge, or deny]
Rule composition
Anubis combines rule results in stages. Matching bot rules can allow, deny, challenge, or adjust weight. Thresholds then use the resulting weight to select the final action, with a direct challenge taking precedence over threshold handling.
This model supports small rules with one clear purpose. For example, a shared rule can add weight for a network signal, while a local threshold decides how much challenge that weight requires.
References: lib/…/policy.go• L150-162 lib/…/threshold.go• L60-66 data/botPolicies.yaml• L236-295
Import composition
An import inserts reusable bot rule data into the bots list. Imports can point to packaged policy data through the (data)/ prefix or to files on the local system. A glob can combine several matching files in natural order. Imported files can contain more imports, so a policy can build a larger rule set from small shared parts.
One list item must be either an inline bot rule or an import statement. It cannot define both. An import is expanded before the complete policy is validated.
For details about file lookup and load order, see Configuration loading. For the packaged rule sets and their intended use, see Packaged policy data.
References: lib/…/import.go• L26-31 lib/…/import.go• L33-103 lib/…/import.go• L105-155 data/…/default-config.yaml• L1-33
Configuration validation
Validation protects the runtime policy from incomplete rules and unusable shared services. It runs at more than one boundary because a syntactically valid YAML file can still refer to an invalid expression, missing database, unknown store, unsupported challenge, or unavailable imported file.
Document validation
The top-level document must contain at least one bot entry. Each bot needs a name and a match source, and it must use only one of the mutually exclusive match forms. Regular expressions, CIDR ranges, remote URLs, actions, expressions, challenge settings, thresholds, and global service blocks are checked before the configuration is accepted.
Validation reports joined errors together when possible. This gives an author one failure result that can cover several independent mistakes in the same document.
References: lib/…/config.go• L96-200 lib/…/config.go• L323-385 lib/…/config.go• L387-410
Runtime validation
After the document passes structural checks, Anubis builds the services and compiles the policy. This stage confirms that selected stores and challenge extensions exist, GeoIP resources can load, and each rule can become a working request check.
A configuration can therefore fail after YAML parsing even when its fields have the right shape. The effective contract includes the runtime capabilities named by the configuration.
References: lib/…/policy.go• L80-149 lib/…/policy.go• L163-233 lib/config.go• L88-111
Change checklist
When these files or sections are changed, remember to consider these:
- Changing
WEIGHrules or theiradjustvalues can change which threshold handles the same request. - Changing
thresholdscan remove the compatibility default and alter the final action for every weighted request. - Adding
geoip, ASN, DNS, or store-dependent rules requires the matching global service to be available and valid. - Adding a challenge extension or algorithm requires the runtime registry to support the name.
- Moving packaged policy files requires updating every
(data)/import that points to them. - Changing
status_codesaffects clients and upstream systems that depend on challenge or denial responses.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A bot entry contains neither an inline match nor an expression | The policy cannot identify that entry | Require at least one supported match source. |
| An import path matches no files or names unsupported glob syntax | Policy loading stops before rule assembly | Use an existing file or a supported glob pattern. |
A WEIGH rule has no weight block | The rule has no explicit score change | Add weight.adjust; the validator supplies the normal default only for a valid WEIGH action. |
A threshold uses CHALLENGE without challenge settings | The final action has no challenge to issue | Define an algorithm and valid difficulty. |
| A rule uses GeoIP or ASN matching without the related database | The signal cannot be evaluated | Configure the required GeoIP database before using the rule. |
| A configured store, challenge algorithm, or extension is not registered | Runtime policy construction fails | Use a supported runtime capability. |
Key files
| File | Why to read it |
|---|---|
| lib/…/config.go | Defines the top-level configuration model, defaults, and structural validation. |
| lib/…/import.go | Explains how local and packaged rule data becomes one bot list. |
| lib/…/threshold.go | Defines the score-to-action model and compatibility threshold. |
| lib/…/policy.go | Shows how accepted configuration becomes the runtime policy. |
| lib/config.go | Shows policy file selection and final challenge-extension checks. |
| data/…/default-config.yaml | Shows the packaged default policy assembled from reusable imports. |
| data/botPolicies.yaml | Shows the packaged policy template and the relationship between global settings and rules. |