feat: add bot rules, a 404 rate limit and an e2e bypass header #1597
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 385 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.356
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1597"
general
weight: 0.35
piscisaureus
Most HTML traffic on jsr.io is unverified automation: about 3M
requests a day with a bot score under 30, against roughly 0.4M from
likely humans. The scrapers spread across thousands of IPs, so the
busiest single IP makes about 16 page requests a minute and never trips
the per-IP Worker limits.
This builds on the challenge rules that are already live (see #1601),
adds a challenge for scraping networks, and adds log-only rules to
measure the rest of the website before anything there is challenged.
Module files served from R2, api.jsr.io and npm.jsr.io are never
matched.
terraform/bots.tf, custom rules, in evaluation order:Log: Cloudflare's scraping detection IDs on website requests.
Log: website requests without an HTML Accept header that score
under 30. The challenge rules only see
text/htmlrequests, sothis covers what
website_requestsadds.The two existing
managed_challengerules, unchanged apart fromthe e2e exemption below.
Challenge: page requests carrying Bot Management detection
50331656 (networks that scrape many zones), whatever their score.
It catches a crawl of doc and diff pages from 1,000+ proxy and VPN
IPs, at most about 11 requests each, that scores 30 or more.
website_requestsmirrors the LB's routing: requests on jsr.ioexcept API, login and sitemap routes, badge endpoints (shields.io
fetches them server-side), the OG image route, static resources, and
module-file requests the LB would serve from R2. A new test in
lb/main_test.tschecks that the module path regex matchesisModuleFilePath, and CI now runs the LB tests.Rate limiting, log only: more than 20 website 404s a minute per IP
and colo. The zone's plan doesn't allow JA4 as a characteristic,
throttling (a mitigation timeout of 0), or request headers in rate
limiting expressions, so the rule matches by path and leaves out
module-file paths for every client.
The post-deploy e2e tests send an
x-jsr-e2eheader carrying theE2E_BYPASS_TOKENsecret, which replaces theDeno/user agentexemption.
e2e_bypass_tokenis sensitive, so the plan shows thecustom rules as
(sensitive value).@font-facefor the missingDMMono-Bold.woff2(about2.3k 404s an hour) and declares the existing
DMMono-Medium.woff2atweight 500.
The LB's
FRONTEND_RATELIMITandDOCS_RATELIMITstay for now; theycan go once the WAF rules have run for a while.
Bot Management settings aren't managed here: prod already has
JavaScript detections and model auto-updates on.
The new rules and the
http_ratelimitentrypoint were created on theprod zone through the API with the same refs, so the first apply updates
them in place. The hand-applied rules exempt
Deno/user agents insteadof the e2e header; the apply switches them over.
E2E_BYPASS_TOKENwasreset to a hex value in both environments so it passes the variable
validation.
The live ruleset also has two temporary log rules measuring detection
50331656. They aren't in terraform, so applying this removes them.