Rule simulator¶
A block decision is never about one target: it is a WAF expression — a set of ASNs, a country, a user-agent condition, a path, and the exemptions that keep verified crawlers and your own services out. What that expression does is not the volume of its target. Three examples from one week on a live zone:
- AS30633 looked four times bigger than it was. About 147,000 requests a day, listed as a block candidate. But ~111,000 of them were ExaSearchBot, a Cloudflare-verified bot that
and not cf.client.botexempts. What the rule could actually stop was ~36,000 a day. - An exemption that should have been written before the block. A rule on AS45102 also caught rednote (not a verified bot, ~5,000 requests a day, all from that network), which the owner had decided to leave alone. The
and not (http.user_agent contains "rednote")branch was added afterwards. - A rule nobody could size. A referer branch ("referer is exactly the home page") was sized only by watching the challenge count after it went live.
The simulator replays a draft expression against the last days of real traffic and answers before the rule exists. It only reads. It creates no rule and no block plan.
Running it¶
flarehound simulate --zone starngage.com --expr '(ip.geoip.asnum eq 30633 and not cf.client.bot)' --action challenge
flarehound simulate --expr 'http.user_agent contains "python-requests"' --days 1
flarehound simulate --expr '…' --date 2026-11-17 # one local day
flarehound simulate --expr '…' --before 3 # as if inserted before custom rule #3
flarehound simulate --expr '…' --json # the report as JSON
Read token only (Zone → Analytics: Read); the watch side can run it. Window: the last 7 days (--days 1 for 24 hours, or --date for one day in schedule.timezone), ending an hour ago — the last hour's data is still landing.
In the console: Simulate tab (any signed-in account). Composition rows link to the drill-down.
At block review the simulation runs by itself: for an ASN, country or user-agent block, the review simulates the rule this target becomes ((ip.geoip.asnum in {N}) and not cf.client.bot, …) and shows the verdict above the confirm button, in place of the single-target measurement. IP blocks keep the light measurement. If the expression cannot be evaluated on the zone (Free plan, no country dimension …), the review falls back to the measurement and says why.
What the report says¶
- Gross matches — requests the expression matches without its own
and not …branches, and with them (what the rule matches); share of all traffic and of dynamic (origin) traffic; split per day. - Exemptions — gross minus matches: what "the rule would block" vs "the rule actually blocks". Each top-level
and not …branch is counted on its own. - Net new — the number that counts: the matches minus what existing rules already block or challenge (firewall events filtered by the same expression; block, challenge, JS challenge, managed challenge — not their outcomes, so a request is not counted twice), minus what skip rules ahead of it let through first (see Position). When the firewall events do not reach back over the whole window (
--dateon an older day), the line leads with the daily rate extrapolated from the covered part, and the covered part's own count is a footnote. - Composition — top 5 paths, user agents, client IPs (with IP location), countries; top networks when the expression is not bound to ASNs. Known sources (
known_faces) among the matches are listed. - Action — the slice's challenge history from the firewall events: challenges issued, solved, passed with an earlier clearance, failed, and a reference range of how many got through (at least solved ÷ issued, at most solved + cleared ÷ issued + cleared).
challenge: that is the pass rate to expect, roughly.block: those are the people a block stops too. Only requests that met a challenge are in that sample — a biased one, so a range for reference, not a prediction; under 30 events no range is given. - Confidence label — one per report:
- approximate (sampled data);
- approximate (includes a cross-dataset estimate) — net new joins two datasets;
- upper bound — a sub-expression could only be widened (the referer, see below): every number carries
≤and the sub-expression is named; or a skip rule ahead could not be counted (see Position): net new carries≤.
- Verdict line — one sentence in the guard rails' terms: nothing matched; a residential network in the matches; a known source hit; verified bots ≥ 20 % of the matches; net new < 1 % of all traffic; net new far below the gross. Example: Gross 147,300, of which 111,493 exempted (verified bots 111,493), net new ≈ 35,800 (0.2 % of all traffic) — consider a challenge, or no action.
Numbers are in FlareHound's units, cleaned like the reports (on zones with Workers, empty-UA entries — Worker bookkeeping — are left out everywhere and counted on their own line); once calibrated, counts also show their dashboard equivalent.
What can be evaluated¶
There is no replay API. GraphQL analytics are sampled, aggregated datasets; per-request logs are Logpush (Enterprise), which FlareHound does not use. The simulator translates the expression into dimension filters:
| Tier | Fields | |
|---|---|---|
| Exact (sampled) | ip.src (single addresses), ip.geoip.asnum / ip.src.asnum, ip.geoip.country / ip.src.country, http.user_agent, http.request.uri.path, http.request.uri.query, http.host, http.request.method, cf.client.bot, cf.verified_bot_category with eq ne in contains starts_with() ends_with(), combined with and or xor not and parentheses |
Negations are pushed down to each comparison |
| Upper bound | http.referer — only the referer's host is a dimension (paid plans). eq "https://site/" is counted as every referer from site. Not allowed under a negation (it would be neither a count nor a bound). http.referer eq "" (no referer) is exact |
Label upper bound, sub-expression named |
| Expanded | $list references to the account's IP and ASN lists (ip.src in $bad_ips, ip.geoip.asnum in $clouds): read through the Lists API and replaced by their values |
The report names each expanded list and its size |
| Bounded | headers, cookies, bodies, matches (regex), wildcard, cf.threat_score / bot score, rates, lower() and other functions, IP ranges (CIDR); lists that cannot be expanded — Cloudflare's managed lists ($cf.…), lists holding ranges, hostname / redirect lists, lists over 1,000 items, and lists the token cannot read (no account_id, or no Account → Account Filter Lists: Read — e.g. a tenant account) |
Named with the reason and bounded: counted as matching for the upper bound, as not matching for the lower bound — never silently dropped |
| Not supported here | a field the zone's plan does not expose (ASN on Free), an invalid value | No numbers at all for the expression |
Partial evaluation¶
A mixed expression — some terms evaluable, some not — still gets numbers, as bounds. After negations are pushed down, the expression only grows when a term is made true and only shrinks when it is made false. So:
- upper bound: every unknown term counted as matching. All counts in the report (and the composition) are over this filter and carry
≤; - lower bound: every unknown term counted as not matching. Matches is given as a range — "between 3,100 and ≤ 10,000";
- net new stays a sound upper bound: the upper matches minus what existing rules certainly stop and skip rules ahead certainly let through — both read over the lower-bound filter;
- term by term: each top-level term (
a and b and not c) is listed with ✓ evaluated, ≤ widened (referer host), ? bounded (with its reason) or ✗ not supported here.
An expression whose upper bound is the whole zone (ip.geoip.asnum eq 30633 or http.cookie contains "x": the unknown branch could be anything) gets no numbers — a bound of "everything" says nothing. The exemption split is left out under partial evaluation (a range of ranges); the term annotations say what each branch is.
Every field is checked against what the zone's plan exposes (flarehound doctor shows a rule simulator row per zone). On Free there is no ASN dimension and no firewall-events dataset: an ASN expression is not evaluable on this zone, and net new is not available — the report says so instead of filling the gap from another source.
Position¶
A rule only sees what the rules ahead of it let through. The simulator reads the zone's custom rules (read token, Zone → WAF: Read) and places the draft where a new FlareHound rule goes — after the skip rules, ahead of the first challenge or block rule — or before rule --before N (console: Insert before custom rule #). The block review uses the plan's own position.
- Skip rules ahead that skip the remaining custom rules take their share first. Cloudflare logs those skips per rule, so they come with the firewall-events query at no extra cost: "position #4, before «Protected Pages» (managed_challenge); skip rules ahead let 900 of the matches through first".
- A skip rule with logging off leaves no events: it is counted from its own expression (one query each, up to three). If that expression cannot be translated, it is named and net new becomes an upper bound.
- A block or challenge rule ahead already counts as "already stopped"; so does one behind it — that traffic is stopped either way, so it is not new.
- Without the rules (no Zone → WAF: Read) net new is counted against the whole rule set and the report says so.
Budget and cache¶
At most 24 GraphQL queries per simulation (typically 15–19), four at a time; reading the rules and lists are REST calls outside that budget. The same simulation within 10 minutes comes from the cache (console; the review and the apply share it).
After the block¶
The simulation shown at review is kept with the block record (archive table block_sims). The before/after comparison (console and daily report) then adds a line: predicted net new ≈ 1,490/h (simulation at review); actual 1,320 stopped in the hour after (−11 %) — so the prediction's error stays visible. "Actual" is the rule's firewall events; on plans without them it says it cannot be counted.
Once a block's hour after has settled, the daily report records that outcome (archive table sim_outcomes, one firewall query per block, at most ten per report) and carries a fixed line with the simulator's record over the last 30 days: how many blocks were confirmed with a net-new prediction, how many were measured, and the median and widest deviation of actual from predicted — upper-bound predictions noted, since a shortfall there is expected.
Not done¶
- No one-click apply: a report produces no block plan and no write path.
- No per-request replay, no Logpush, no raw logs on disk: sampling is the precision limit.
- No cross-zone simulation: expressions and rule sets are per zone.
- Not done: hostname lists; per-term numbers (a term is only annotated, the counts are for the expression as a whole).