[ISSUE #8261] Inspect decoded JSON text in the sensitive word plugin #8267
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.45) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 443 lines diff across 5 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.365
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #8267"
general
weight: 0.35
yuluo-yx
Fixes #8261
Problem
SensitiveWordPluginscanned the raw request body. A JSON document can carry the same text withescape sequences, so a message whose word is written with JSON Unicode escapes reached the model
while the same word spelled literally was rejected. The text a model reads is the decoded value,
not its wire form.
Impact
no currently rejected request becomes accepted.
maxBodySizecheck, so it never retains a parsed JSON tree.
Changes
JsonTextValues(new): a package-private streaming walker that decodes every JSON string memberand skips object member names and non-string values. It stops at the first match, leaves the body
untouched, and stops at the first malformed token.
SensitiveWordPlugin: scans the raw body, and when no word is found there, scans the decodedstring values. The class Javadoc states the inspected fields and the malformed/non-JSON policy.
README.md: a JSON decoding section listing the covered fields and the limits.SensitiveWordPluginTest: seven tests — the issue reproduction, an escape split across incomingbuffers, a multimodal text part, a tool definition, a Responses
input, byte-preservation of theforwarded body, and a malformed document.
Inspected fields
A JSON body is scanned once as raw text and once through the decoded value of every string member:
openai-chat:messages[].content, both as a string and as thetextmembers of multimodalcontent parts, plus tool definitions and function arguments;
openai-responses:input, either a string or items whose text lives incontentortext.Object member names and non-string values are not decoded. A string value that itself holds JSON is
decoded once, not recursively parsed. A body that is not a JSON object or array, and a malformed
JSON document, keep the raw plain-text scan only, so they are never treated as decoded and clean.
Validation
./mvnw -pl shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-sensitive-word -am test -Dtest='AhoCorasickTest,SensitiveWordPluginTest,SensitiveWordPluginDataHandlerTest' -Dsurefire.failIfNoSpecifiedTests=false -Drat.skip=true -Djacoco.skip=true→
Tests run: 54, Failures: 0, Errors: 0(27 inSensitiveWordPluginTest).SensitiveWordPluginchange reverted, the five escaped-contenttests fail (
Tests run: 5, Failures: 5, Errors: 0); with the fix they pass.0violations. Apache RAT:0unapproved, 8 approved licenses.Non-blocking note
#8255 owns the reusable normalized request view. It is not available yet, so this walker is
deliberately protocol-agnostic: it decodes string values instead of modeling a protocol schema,
which also covers model-visible fields the profile-based PII plugin does not redact, such as tool
definitions. When #8255 lands, the walker can be replaced without changing the plugin contract.
Checklist