← Back to Pull requests

feat: add bot rules, a 404 rate limit and an e2e bypass header #1597

Closed
unknown closed this pull request without merging on Nov 28, 2026 09:47 UTC
View on GitHub
unknown unknown commented on Nov 27, 2026 12:45 UTC
Author

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/html requests, so
this covers what website_requests adds.
The two existing managed_challenge rules, unchanged apart from
the 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_requests mirrors the LB's routing: requests on jsr.io
except 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.ts checks that the module path regex matches
isModuleFilePath, 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-e2e header carrying the
E2E_BYPASS_TOKEN secret, which replaces the Deno/ user agent
exemption. e2e_bypass_token is sensitive, so the plan shows the
custom rules as (sensitive value).

  • Removes the @font-face for the missing DMMono-Bold.woff2 (about

  • 2.3k 404s an hour) and declares the existing DMMono-Medium.woff2 at
    weight 500.

    The LB's FRONTEND_RATELIMIT and DOCS_RATELIMIT stay for now; they
    can 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_ratelimit entrypoint were created on the
    prod zone through the API with the same refs, so the first apply updates
    them in place. The hand-applied rules exempt Deno/ user agents instead
    of the e2e header; the apply switches them over. E2E_BYPASS_TOKEN was
    reset 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.

    Diff: 385 lines (+288 / -97) across 4 files Reviewer: piscisaureus Review duration: 1261m
    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
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43% (MEDIUM) · Higher = larger blast radius
    43%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.0% · Safe to merge
    17.0%
    Repository