Issue #4645 - ForwardedRequestCustomizer now gives 400 response for bad port values#4648
Merged
lachlan-roberts merged 5 commits intojetty-9.4.xfrom Mar 15, 2020
Merged
Conversation
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
gregw
requested changes
Mar 9, 2020
Contributor
gregw
left a comment
There was a problem hiding this comment.
We should catch exceptions from parsing all these headers and pass to a method on the Customizer, which by default will throw a BadMessageException.
If users want to ignore these bad headers they can extend and change the method
Contributor
|
@sbordet has also suggested that when we parse a port we check that it is a valid integer for a port... ie >0 <=64k |
joakime
reviewed
Mar 9, 2020
jetty-server/src/main/java/org/eclipse/jetty/server/ForwardedRequestCustomizer.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
gregw
requested changes
Mar 11, 2020
Contributor
gregw
left a comment
There was a problem hiding this comment.
Can you add at least one ForwardedRequestCustomerizerTest test that has a bad port. I want to make sure that the BadMessageException thrown and then wrapped as a RuntimeException is correctly unwrapped to get the 400 (rather than a 500).
jetty-server/src/main/java/org/eclipse/jetty/server/ForwardedRequestCustomizer.java
Outdated
Show resolved
Hide resolved
jetty-server/src/main/java/org/eclipse/jetty/server/ForwardedRequestCustomizer.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
gregw
requested changes
Mar 12, 2020
jetty-server/src/main/java/org/eclipse/jetty/server/ForwardedRequestCustomizer.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
gregw
approved these changes
Mar 13, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #4645
Replace the previous
NumberFormatExceptionwith anIllegalArgumentExceptionwith a more descriptive error message.It would also be possible to change the code to just return if we have an empty
X-Forwarded-Portvalue, which would ignore it. I'm not sure if that would be more correct than throwing.