fix: apply configured WAF statusCode to HTTP response instead of hardcoded 403 - #6821
fix: apply configured WAF statusCode to HTTP response instead of hardcoded 403#6821wy471x wants to merge 3 commits into
Conversation
…coded 403 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Good catch — hardcoding Null/non-numeric int statusCode = Optional.ofNullable(wafHandle.getStatusCode())
.filter(NumberUtils::isCreatable)
.map(Integer::parseInt)
.orElse(HttpStatus.FORBIDDEN.value());Also: the two new tests cover 403 and 404 (valid codes) but not the null/empty/non-numeric Minor: |
apply configured WAF statusCode to HTTP response instead of hardcoded 403
Make sure that:
./mvnw clean install -Dmaven.javadoc.skip=true.Summary
Problem:
WafPlugin hardcoded exchange.getResponse().setStatusCode(HttpStatus.FORBIDDEN), ignoring the configurable statusCode from WafHandle. This meant setting a custom
statusCode (e.g., 404) only changed the response body code, while the actual HTTP transport status remained 403.
Changes:
value in ShenyuResultWrap.error(), keeping HTTP status and body code consistent.
testWafPluginRejectWithCustomStatusCode that configures statusCode: "404" and asserts the HTTP response status is actually 404.
close #6477