You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by GitBox <gi...@apache.org> on 2022/10/20 10:47:00 UTC
[GitHub] [knox] zeroflag opened a new pull request, #650: KnoxKNOX-2827 - isDispatchAllowed should cut off path segments from the URL
zeroflag opened a new pull request, #650:
URL: https://github.com/apache/knox/pull/650
## What changes were proposed in this pull request?
pending
## How was this patch tested?
pending
--
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: dev-unsubscribe@knox.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [knox] moresandeep commented on a diff in pull request #650: KNOX-2827 - isDispatchAllowed should cut off path segments from the URL
Posted by GitBox <gi...@apache.org>.
moresandeep commented on code in PR #650:
URL: https://github.com/apache/knox/pull/650#discussion_r1001661250
##########
gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilter.java:
##########
@@ -145,14 +147,21 @@ private boolean isDispatchAllowed(HttpServletRequest request) {
if (whitelist != null) {
String requestURI = request.getRequestURI();
- String decodedURL = null;
+ String decodedURL = requestURI;
try {
decodedURL = URLDecoder.decode(requestURI, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
//
}
+ String baseUrl;
+ try {
+ URL url = new URL(decodedURL);
+ baseUrl = new URL(url.getProtocol(), url.getHost(), url.getPort(), "").toString();
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
Review Comment:
We should log the error before wrapping the exception and throwing.
--
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: dev-unsubscribe@knox.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [knox] zeroflag commented on a diff in pull request #650: KNOX-2827 - isDispatchAllowed should cut off path segments from the URL
Posted by GitBox <gi...@apache.org>.
zeroflag commented on code in PR #650:
URL: https://github.com/apache/knox/pull/650#discussion_r1002972633
##########
gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilter.java:
##########
@@ -145,14 +147,21 @@ private boolean isDispatchAllowed(HttpServletRequest request) {
if (whitelist != null) {
String requestURI = request.getRequestURI();
- String decodedURL = null;
+ String decodedURL = requestURI;
try {
decodedURL = URLDecoder.decode(requestURI, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
//
}
+ String baseUrl;
+ try {
+ URL url = new URL(decodedURL);
+ baseUrl = new URL(url.getProtocol(), url.getHost(), url.getPort(), "").toString();
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
Review Comment:
Hi @moresandeep, if we log it here then the message will appear in the log two times. I tested this with a malformed URL and the exception was still visible in the gateway.log, because at the outer level we catch and log everything. I don't see a reason to log it here too.
--
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: dev-unsubscribe@knox.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [knox] zeroflag merged pull request #650: KNOX-2827 - isDispatchAllowed should cut off path segments from the URL
Posted by GitBox <gi...@apache.org>.
zeroflag merged PR #650:
URL: https://github.com/apache/knox/pull/650
--
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: dev-unsubscribe@knox.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org