Introducing a new way to review your PRs.

Read the announcement

techarohq / anubis

Weighs the soul of incoming HTTP requests to stop AI crawlers

View on GitHub

19 documents · Updated Nov 23, 2026

docs / policy-data

Packaged bot and service policy data

The packaged policy data is a built-in library of request rules for common bots, crawlers, clients, applications, services, and shared request patterns. Administrators select these rules from their main policy through imports. The selected rules then become part of runtime classification and can allow, deny, challenge, or change the weight of a request. See Configuration for the wider policy model and Configuration loading for the full load path.

Dataset model

The policy data is grouped by the kind of request it describes. The groups keep reusable rules separate from the policy choices that combine them.

Policy categories

The package exposes one embedded policy file system through data/embed.go. It includes the botPolicies.yaml default policy and YAML snippets under these groups:

GroupPurposeTypical signal
botsIdentify unwanted or unusual automated agentsUser-agent names or browser behavior
crawlersClassify search, archive, indexing, and training crawlersUser-agent data or published network ranges
clientsClassify software that acts for a user or uses a non-browser clientHeaders, user-agent data, or source addresses
appsPreserve known application routes and application-specific trafficURL paths or request expressions
servicesRecognize external monitoring and service agentsUser-agent data and source addresses
commonProvide reusable request behavior checksPaths, headers, and browser-like behavior
metaCombine rules into an administrator stanceImports from several other groups

These names describe the policy subject, not separate runtime engines. All groups produce the same kind of bot rule, so a selected rule enters classification in the same way as any other rule. References: data/embed.go• L5-7, data/…/README.md• L1-5, lib/…/config.go• L57-73

Policy composition

The data is designed for composition. A small snippet can describe one agent, while a meta policy can assemble many snippets into a broader choice such as aggressive AI blocking or a default set of trusted crawlers. data/botPolicies.yaml is the packaged starting point and shows how common rules, crawler rules, client rules, and meta rules can be combined.

Imports use the (data)/ prefix to select packaged data. A configuration can also import a local file, but packaged data stays available after the application is built and does not depend on a source checkout. A glob can select a group of snippets when a policy needs a set rather than one named rule. References: data/botPolicies.yaml• L1-50, data/…/default-config.yaml• L1-33, lib/…/import.go• L33-49, lib/…/import.go• L86-103

Runtime classification

Runtime classification turns the selected snippets into request checks. The configuration loader resolves imports first. The policy parser then turns each rule into a named action with one or more request conditions.

Import resolution

An import resolves to one or more policy documents. Nested imports are allowed, so a meta policy can point to other groups and those groups can point to individual rules. The loader flattens the result into the bot-rule list before request handling starts.

The loader rejects missing files, invalid patterns, unreadable data, and malformed policy documents. It also requires each imported document to produce valid rule definitions. This keeps packaged data from silently becoming a partial runtime policy. References: lib/…/import.go• L20-24, lib/…/import.go• L105-150, lib/…/import_test.go• L100-145

Rule evaluation

Each selected rule has a condition set and an action. Conditions can use request headers, paths, client addresses, expressions, or optional IP metadata. When a rule has several conditions, all conditions must match before its action applies.

The policy parser validates the rule and builds the request checks before it returns the active policy. The resulting action can allow or deny a request, issue a challenge, or adjust its weight for later threshold handling.

The following flow shows how packaged data reaches request classification.

flowchart LR
    A[Main policy] --> B[Packaged import]
    B --> C[Selected policy snippets]
    C --> D[Validated request rules]
    D --> E[Runtime request checks]
    E --> F[Allow, deny, challenge, or weight]

References: lib/…/config.go• L35-53 lib/…/config.go• L96-200 lib/…/policy.go• L80-89 lib/…/policy.go• L150-262 lib/…/checker.go• L25-45

Dataset roles

The groups cover different sources of request identity. They let an administrator apply a narrow rule to a known service or compose a wider policy for a class of automated traffic.

Bot and crawler rules

Bot rules target agents that are unwanted, suspicious, or known to behave unlike a normal browser. Crawler rules cover search and archive systems that an administrator may want to allow so they can index a site without trying to bypass the protection.

The two groups can work together. For example, the aggressive AI meta policy imports a broad AI catch-all rule, rules for AI clients, and rules for AI search and training crawlers. The allow-list for known crawlers instead imports named crawler policies so trusted indexing traffic can be handled as a set.

The bot group also supports narrow allow rules for known automated agents. The Arch Linux IRC phrik rule allows the agent only when its expected user-agent and one of its published addresses match, which limits the rule to that specific service identity.

References: data/…/ai-catchall.yaml• L1-11 data/…/headless-browsers.yaml• L1-15 data/…/archlinux-phrik.yaml• L1-7 data/…/_allow-good.yaml• L1-13 data/…/ai-block-aggressive.yaml• L1-6

Client, application, and service rules

Client rules describe software that sends requests for a person or uses a specialized protocol. Application rules protect routes that should remain usable for a known application. Service rules recognize monitoring or other external service traffic.

These rules often combine identity with a second signal. The Git client rule checks both the client pattern and expected headers. The Mistral user client rule pairs its documented user-agent pattern with published source addresses. The API route rule checks the request method and path. The UptimeRobot rule pairs its user-agent with published source addresses. This reduces reliance on a name that a different client could copy.

References: data/…/git.yaml• L1-21 data/…/mistral-mistralai-user.yaml• L1-7 data/…/allow-api-routes.yaml• L1-6 data/…/uptime-robot.yaml• L1-8 lib/…/config.go• L103-120

Shared metadata rules

Shared rules express behavior that applies across several policy subjects. They cover routes that support normal web operation, browser-like request traits, domain-fronting signals, private addresses, and other common request properties.

Meta policies use these shared rules as building blocks. For example, the default policy imports rules for common web routes and domain fronting while also adding subject-specific bot and crawler choices. This separates a reusable fact about a request from the decision to allow, deny, challenge, or weigh it.

References: data/…/keep-internet-working.yaml• L1-13 data/…/acts-like-browser.yaml• L7-55 data/…/default-config.yaml• L1-33 data/…/README.md• L1-5

Data quality boundary

The embedded data is part of the runtime policy surface. Every packaged YAML file must be present in the embedded file system, contain content, parse as YAML, and yield valid policy rules when imported. A bad snippet can therefore prevent configuration loading rather than merely reduce one classification match.

The data also depends on external facts that can change. Published service address lists and user-agent names need review when a provider changes its traffic. Rules that use ASN or country checks need matching GeoIP data in the active policy. Rules that use request expressions must continue to match the request fields exposed by the policy environment.

References: data/embed_test.go• L11-53 lib/…/import_test.go• L100-145 lib/…/policy.go• L116-128 lib/…/policy.go• L217-233

Change checklist

When these files or sections are changed, remember to consider these:

  • When adding or renaming a snippet, update every meta policy or default import that selects it.
  • When changing a service address list or user-agent pattern, check that the rule still has a second reliable signal where one is required.
  • When changing a rule that uses GeoIP, confirm that the matching database is available in deployments that select the rule.
  • When changing an expression, confirm that its request fields and header names remain available to bot rules.
  • When changing the embedded directory layout, preserve the (data)/ import path used by packaged and local policy examples.

Important failure modes

TriggerConsequenceGuard
A packaged import path does not exist or a glob matches no filesConfiguration validation fails before the policy becomes activeUse paths under the embedded data groups and keep import targets covered by the import validation
A snippet contains invalid YAML or an invalid ruleThe full policy load fails instead of installing a partial rule setKeep each snippet valid and use the embedded YAML and import checks
A rule needs GeoIP data that is not configuredThat rule is skipped and its intended match does not affect the requestConfigure the required country or ASN database before selecting the rule
A trusted service changes its user-agent or source addressesExpected service traffic can be classified as unknown or blockedReview provider-published identity data when maintaining the snippet
A narrow bot allow rule has stale addresses or user-agent dataThe known bot is not allowed as intended, or copied identity data may match unexpectedlyKeep the identity signals current and require both the expected agent and address
A broad user-agent rule matches a legitimate clientLegitimate traffic can receive an unintended actionPrefer narrow conditions and combine identity with headers, paths, or addresses

Key files

FileWhy to read it
data/embed.goDefines the packaged policy data available at runtime.
data/botPolicies.yamlShows the default composition of packaged rules.
data/…/default-config.yamlShows how a broad policy stance combines groups.
data/…/ai-block-aggressive.yamlShows a meta policy that combines bot, client, and crawler rules.
data/…/archlinux-phrik.yamlShows a narrow bot rule that uses both a service address and a user-agent.
data/…/mistral-mistralai-user.yamlShows a client rule that combines a documented user-agent with published source addresses.
lib/…/import.goDefines how packaged and local imports become one policy.
lib/…/config.goDefines the rule contract and the actions that runtime classification can produce.
lib/…/policy.goConnects validated configuration to active request checks.
data/embed_test.goVerifies that packaged files are embedded, non-empty, and valid YAML.