fix(ai): honor failClosed when the sensitive-word scanner is uninitialized #8263
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
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.334
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #8263"
general
weight: 0.35
yuluo-yx
Fixes #8260
Problem
When the Redis template had not been initialized yet,
SensitiveWordPlugincalled the downstream chain unconditionally, without consulting thefailClosedflag of the matched rule. A rule configured withfailClosed=truetherefore let an uninspected request reach the upstream in that state, while the same resource failure after Redis initialization was correctly rejected.Impact
failClosed=truenow return the plugin's standard 403 rejection while the scanner is unavailable, instead of passing the request through.failClosed=falsekeep the documented pass-through; the log line now states that the request was not scanned.Changes
SensitiveWordPlugin: apply the rule's failure policy to the uninitialized scanner.SensitiveWordPluginTest: addtestFailClosedRejectsTheRequestWhenTheRedisTemplateIsNotInitialized, 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.SensitiveWordPluginTest:140and passes with the fix.Out of scope
Checklist
./mvnw clean installwas 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).