← Back to Pull requests

refactor(bottle): demonstrate subscriber-owned request blocking #22078

Open
unknown opened this pull request with 287 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 24, 2026 20:11 UTC
Author

Description

Demonstrates how an independent subscriber can skip a Bottle route callback and supply an HTTP response while reusing the existing shared request tracing subscriber.

Bottle dispatches a typed inspection event inside its request context. The integration adapts a supplied status, headers, and byte body to HTTPResponse; the existing completion path handles HTTP tags and span finishing. A test-only subscriber supplies a 403 response, with coverage for allowed requests and exception cleanup. Contributor documentation explains the boundary.

This is a smaller demonstration related to #21006; it adds no production AppSec subscriber or WAF policy.

Customer impact

None with the existing production subscribers. The blocking policy exists only in tests. No release note is needed for this internal demonstration.

Testing

  • Latest test-only cleanup: Python 3.11.17 / Bottle 0.13.4: 78 passed, 12 skipped, including automatic patching. Python 3.9.25 / Bottle 0.12.25 also passed before the two redundant cases were removed.

  • Four additional local capture executions verified real Bottle WSGI allowed/blocked responses, incoming trace and parent IDs, exactly one finished request span, subscriber removal, and the existing tracing-disabled bypass.

  • scripts/lint checks, targeted typing/formatting/spelling, and type-comment checks passed.

  • Architecture review and baseline comparisons found no new import cycles or dependency-direction violations.

  • All eight existing Bottle request benchmark configurations completed against main 456bf4e843 on Python 3.12.10 / Bottle 0.13.4. No measured regressions in this run; the normal request case was 149.21 ± 6.42 µs on main and 143.76 ± 2.36 µs on the candidate. Baseline ran first and had higher variability in several cases, so this does not establish a speedup. This measures the path without an inspection subscriber.
  • Risks

    Adds an inspection dispatch to traced Bottle callbacks. Tracing-disabled requests keep their existing bypass. Request bodies, unmatched routes, later hooks, response/SDK blocking, and streaming are outside this example. Production security support requires separate implementation and validation.

    Additional Notes

    Draft demonstration for reviewing the subscriber extension point.

    Diff: 287 lines (+215 / -72) across 3 files Reviewer: dubloom Review duration: 13730m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 287 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.339
    Real PR Conversation Timeline
    1 comments
    "Review active on #22078"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 39.8% (MEDIUM) · Higher = larger blast radius
    39.8%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 21.2% · Safe to merge
    21.2%