Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #6860 IPv6 Format #6861

Merged
merged 8 commits into from Sep 21, 2021
Merged

Fix #6860 IPv6 Format #6861

merged 8 commits into from Sep 21, 2021

Conversation

gregw
Copy link
Contributor

@gregw gregw commented Sep 17, 2021

Fix #6860 IPv6 format by adding a per context configuration.

Signed-off-by: Greg Wilkins gregw@webtide.com

Fix #6860 IPv6 format by adding a per context configuration.

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw gregw added this to In progress in Jetty 9.4.44 FROZEN via automation Sep 17, 2021
@gregw gregw added High Priority Sponsored This issue affects a user with a commercial support agreement labels Sep 17, 2021
@gregw gregw self-assigned this Sep 17, 2021
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
@lachlan-roberts
Copy link
Contributor

@gregw I pushed a fix to this branch, it had about 60 checkstyle failures.
I think you laptop is not configured with the Jetty intellij code style.

Jetty 9.4.44 FROZEN automation moved this from In progress to Review in progress Sep 17, 2021
updates from review

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@sbordet
Copy link
Contributor

sbordet commented Sep 17, 2021

@gregw this PR is missing tests, I fear that the "unchanged" semantic may not work as the field could already be set "normalized".

unit test and fixes

Signed-off-by: Greg Wilkins <gregw@webtide.com>
fix style

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@lachlan-roberts
Copy link
Contributor

@gregw this still doesn't work too well with ForwardedRequestCustomizer, the problem is that it goes through HostPort first which will bracket the IPv6 address regardless of the IPv6Format. The other difference is that 9.3 treats the last segment of an unbracketed address as the port and 9.4 does not. So the behaviour is now:

=== Jetty 9.4 ===
UNBRACKETED: 1:2:3:4:5:6:7:8:8080 --> 1:2:3:4:5:6:7:8:8080
UNCHANGED:   1:2:3:4:5:6:7:8:8080 --> [1:2:3:4:5:6:7:8:8080]

=== Jetty 9.3 ===
1:2:3:4:5:6:7:8:8080 --> 1:2:3:4:5:6:7:8

@gregw
Copy link
Contributor Author

gregw commented Sep 20, 2021

@lachlan-roberts I'm open to suggestions? But I'm not sure that 1:2:3:4:5:6:7:8:8080 is really ever valid?

@gregw
Copy link
Contributor Author

gregw commented Sep 20, 2021

So 9.3 just assumed that the last : always indicated a port. I think this was a bad/wrong/dangerous thing. So I'm not sure we should be bug for bug compatible with that.

@lachlan-roberts
Copy link
Contributor

So 9.3 just assumed that the last : always indicated a port. I think this was a bad/wrong/dangerous thing. So I'm not sure we should be bug for bug compatible with that.

That's fine. But I think the main issue is that HostPort already normalizes the address. This means even using ForwardedRequestCustomizer the IPv6Format.UNCHANGED acts the same as IPv6Format.BRACKETED.

@gregw
Copy link
Contributor Author

gregw commented Sep 20, 2021

Which is why we have the UNBRACKETED option. I don't think we can do anything else as this is a per webapp setting and the customizer is run before the webapp is known.
I think if we run with either UNBRACKETED or UNCHANGED then the sponsered use-case will work fine.

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw
Copy link
Contributor Author

gregw commented Sep 20, 2021

Both @lachlan-roberts and I were not totally happy that UNCHANGED didn't really work as we frequently normalize elsewhere. So instead of introducing new forever public configuration, this change now is the minimal that we can do to make the formatting in an easily extensible class for the sponsor. @sbordet please re-review.

@gregw gregw requested a review from sbordet September 20, 2021 06:54
@joakime joakime linked an issue Sep 20, 2021 that may be closed by this pull request
@lachlan-roberts
Copy link
Contributor

@gregw this PR has failures in DoSFilterTest:

[INFO] Running org.eclipse.jetty.servlets.DoSFilterTest
Running org.eclipse.jetty.servlets.DoSFilterTest.testRemotePortLoadIdCreationIpv6()
Expected: (is "[::192.9.5.5]:12345" or is "[0:0:0:0:0:0:c009:505]:12345")
     but: was "0:0:0:0:0:0:c009:505:12345"

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Copy link
Contributor

@sbordet sbordet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM apart a glitch in Request.formatAddrOrHost().


private String formatAddrOrHost(String name)
{
return _channel == null ? HostPort.normalizeHost(name) : _channel.formatAddrOrHost(name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_channel is a final field. Can it ever be null?
If it is only null in tests, you may want to add a comment about that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should only be null in tests, but we have a specific test to check it works with null.

Jetty 9.4.44 FROZEN automation moved this from Review in progress to Reviewer approved Sep 21, 2021
@gregw gregw merged commit 9b3fb19 into jetty-9.4.x Sep 21, 2021
Jetty 9.4.44 FROZEN automation moved this from Reviewer approved to Done Sep 21, 2021
@gregw gregw deleted the jetty-9.4.x-6860-Ipv6-format branch September 21, 2021 22:21
gregw added a commit that referenced this pull request Sep 21, 2021
Fix #6860 IPv6 format by adding an extensible HttpChannel method

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Co-authored-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Greg Wilkins <gregw@webtide.com>
# Conflicts:
#	jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java
#	jetty-server/src/main/java/org/eclipse/jetty/server/Request.java
#	jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java
#	jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java
gregw added a commit that referenced this pull request Sep 22, 2021
Fix #6860 IPv6 format by adding an extensible HttpChannel method

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Co-authored-by: Lachlan Roberts <lachlan@webtide.com>
gregw added a commit that referenced this pull request Sep 23, 2021
Fix #6860 IPv6 format by adding an extensible HttpChannel method

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Co-authored-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Greg Wilkins <gregw@webtide.com>
# Conflicts:
#	jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java
#	jetty-server/src/main/java/org/eclipse/jetty/server/Request.java
#	jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java
#	jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java
gregw added a commit that referenced this pull request Sep 23, 2021
Fix #6860 IPv6 format by adding an extensible HttpChannel method

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Co-authored-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Greg Wilkins <gregw@webtide.com>
# Conflicts:
#	jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java
#	jetty-server/src/main/java/org/eclipse/jetty/server/Request.java
#	jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java
#	jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
High Priority Sponsored This issue affects a user with a commercial support agreement
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

IPv6 format
3 participants