Aias00 commented on code in PR #7320:
URL: https://github.com/apache/shenyu/pull/7320#discussion_r4114112604
##########
shenyu-plugin/shenyu-plugin-waf/src/main/java/org/apache/shenyu/plugin/waf/WafPlugin.java:
##########
@@ -65,7 +65,9 @@ protected Mono<Void> doExecute(final ServerWebExchange
exchange, final ShenyuPlu
return chain.execute(exchange);
}
if (WafEnum.REJECT.getName().equals(wafHandle.getPermission())) {
- int statusCode = Integer.parseInt(wafHandle.getStatusCode());
+ int statusCode = StringUtils.isBlank(wafHandle.getStatusCode())
+ ? HttpStatus.FORBIDDEN.value()
+ : Integer.parseInt(wafHandle.getStatusCode());
Review Comment:
Suggestion (non-blocking): this covers blank/null, but `Integer.parseInt`
still throws for any non-blank non-numeric value — e.g. `"forbidden"`, or a
value with stray whitespace like `"403 "`. Since
`org.apache.commons.lang3.StringUtils` is already imported here, this could be:
```java
int statusCode = NumberUtils.toInt(wafHandle.getStatusCode(),
HttpStatus.FORBIDDEN.value());
```
which handles missing, blank and malformed in one expression and keeps the
code hard to misuse. Up to you whether to fold it in now or in a follow-up —
the fix as written resolves the reported failure mode.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]