-
-
Notifications
You must be signed in to change notification settings - Fork 294
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
Additional IP range validations #1152
Conversation
It's possible for the network to be udp4 or udp6. This is rather unlikely to occur, but since we're given the network anyway as part of the Sanitize function getting called we might as well check for it.
The net and netip packages diverge in that net.ParseIP will consider an IPv4-mapped address to be an IPv4 address and as such it would get caught by the IPv4Reserved list. However, netip considers it an IPv6 address, so we need to ensure the mapped range is in IPv6Reserved.
This includes a number of tests for /32's explicitly called out in the registry to ensure we always consider those invalid.
This test feels a little redundant now: gotosocial/internal/httpclient/client_test.go Line 141 in e6cd81b
But it's also a little underspecified given what it tests for: gotosocial/internal/httpclient/client_test.go Lines 33 to 43 in e6cd81b
I'm not sure what to do about that one, because retaining at least one test to ensure the Sanitizer is properly hooked up is valuable. |
Leave it for now. As you say it checks the sanitizer is at least hooked up correctly :) |
If you're happy with everything here @daenney I'll merge this. Looks good to me, and thank you for the contribution! |
Good to go from my side! (also wow you're fast, I was not expecting a review at this time on a weekend) |
I work on this project outside my main job so more often than not you'll probably find me working at odd hours :'). Also your code is well written and easily reviewable! |
Commits are individually reviewable.
Since I was looking at this code yesterday I decided to take another pass through it:
/32
's on v4