← Back to Pull requests

fix(ai): honor failClosed when the sensitive-word scanner is uninitialized #8263

Closed
unknown closed this pull request without merging on Nov 02, 2026 15:35 UTC
View on GitHub
unknown unknown commented on Oct 31, 2026 03:56 UTC
Author

Fixes #8260

Problem

When the Redis template had not been initialized yet, SensitiveWordPlugin called the downstream chain unconditionally, without consulting the failClosed flag of the matched rule. A rule configured with failClosed=true therefore let an uninspected request reach the upstream in that state, while the same resource failure after Redis initialization was correctly rejected.

Impact

  • Existing rules with failClosed=true now return the plugin's standard 403 rejection while the scanner is unavailable, instead of passing the request through.

  • Rules with the default failClosed=false keep the documented pass-through; the log line now states that the request was not scanned.

  • No configuration, handle, or cache format changes.
  • Changes

  • SensitiveWordPlugin: apply the rule's failure policy to the uninitialized scanner.

  • SensitiveWordPluginTest: add testFailClosedRejectsTheRequestWhenTheRedisTemplateIsNotInitialized, which caches a fail-closed handle, removes the Redis template and asserts that the downstream chain is never invoked.
  • Validation

  • mvn -pl shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-sensitive-word -am test -Dtest=SensitiveWordPluginTest -Dsurefire.failIfNoSpecifiedTests=false → 21 tests, 0 failures.

  • The new test fails on the current code at SensitiveWordPluginTest:140 and passes with the fix.

  • Checkstyle ran in the reactor build and passed.
  • Out of scope

  • Scanning the rule's own words while no Redis template exists. The plugin returns before the dictionary is built in that state; this PR only aligns the failure policy, as described in the issue.

  • Missing-rule behavior is unchanged; this covers an existing matched rule only.
  • Checklist

  • You have read the contribution guidelines.

  • You submit test cases (unit or integration tests) that back your changes.

  • ./mvnw clean install was not run because the wrapper jar cannot be downloaded on this machine; the changed module and its reactor dependencies were built and tested instead (command above).
  • Diff: 266 lines (+199 / -67) across 3 files Reviewer: yuluo-yx Review duration: 3579m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.39) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 266 lines diff across 3 files
    0.39
    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%
    56%
    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.334
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #8263"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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.4% (MEDIUM) · Higher = larger blast radius
    39.4%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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% · Safe to merge
    17%
    Repository