Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[HttpFoundation] Add IpUtils::isPrivateIp#49726

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:6.3fromdanielburger1337:6.3
Mar 20, 2023
Merged

[HttpFoundation] Add IpUtils::isPrivateIp#49726

nicolas-grekas merged 1 commit intosymfony:6.3fromdanielburger1337:6.3
Mar 20, 2023

Conversation

@danielburger1337
Copy link
Contributor

@danielburger1337danielburger1337 commentedMar 18, 2023
edited
Loading

QA
Branch?6.3
Bug fix?no
New feature?yes
Deprecations?no
TicketsN/A
LicenseMIT
Doc PRsymfony/symfony-docs#18102

This is only my second PR for this project, so I hope I followed all the guidelines correctly.
Recently I had more and more use cases where I had to make exceptions (mostly rate limiting) for private IP ranges.

Symfony currently does not provide an easy way to check if an IP is private or public but implements such logic internally (private constant) for theNoPrivateNetworkHttpClient.

This PR intents to make the private subnet list reusable by adding it toIpUtils.

In the original PR of the NoPrivateNetworkHttpClient it was also briefly mentioned that this constant may have value when made public.#35566 (comment)

I think symfony should and always should have exposed this constant.

GromNaN, sstok, and andreybolonin reacted with thumbs up emoji
@carsonbotcarsonbot added this to the6.3 milestoneMar 18, 2023
@carsonbotcarsonbot changed the titleAdd IpUtils::PRIVATE_SUBNETS constant[HttpFoundation] Add IpUtils::PRIVATE_SUBNETS constantMar 18, 2023
Copy link
Member

@GromNaNGromNaN left a comment
edited
Loading

Choose a reason for hiding this comment

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

Yes, providing a way to check if an IP address is public or private is a good idea and should be included in the framework. You would use the constant like this?

IpUtils::checkIp($ip, IpUtils::PRIVATE_SUBNETS);

I wonder if we shouldn't add a new public method instead: it would be more intuitive for users. This would allow for more logic in the future if needed and prevent potential confusion. Developers who are not familiar with network ranges may not understand the purpose of the constant or how it should be used, which could lead to security errors in their code.

@danielburger1337
Copy link
ContributorAuthor

danielburger1337 commentedMar 18, 2023
edited
Loading

I wonder if we shouldn't add a new public method instead: it would be more intuitive for users. This would allow for more logic in the future if needed and prevent potential confusion. Developers who are not familiar with network ranges may not understand the purpose of the constant or how it should be used, which could lead to security errors in their code.

Something along the lines of the following could be added:

IpUtils::isPrivateIp(string$requestIp)

If we can agree that the method should be added, I will add it to the PR. I don't know too much about network ranges but I should be able to reuse the tests from theNoPrivateNetworkHttpClient where this logic originates.

GromNaN and danielburger1337 reacted with thumbs up emoji

@danielburger1337danielburger1337 changed the title[HttpFoundation] Add IpUtils::PRIVATE_SUBNETS constant[HttpFoundation] Add IpUtils::isPrivateIpMar 20, 2023
Copy link
Member

@GromNaNGromNaN left a comment

Choose a reason for hiding this comment

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

Thanks.

@nicolas-grekas
Copy link
Member

Thank you@danielburger1337.

danielburger1337 reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas merged commit38b5992 intosymfony:6.3Mar 20, 2023
OskarStark added a commit to symfony/symfony-docs that referenced this pull requestMar 21, 2023
This PR was squashed before being merged into the 6.3 branch.Discussion----------Add IpUtils::isPrivateIp docsReferencessymfony/symfony#49726Commits-------990596e Add IpUtils::isPrivateIp docs
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof left review comments

@GromNaNGromNaNGromNaN approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

6.3

Development

Successfully merging this pull request may close these issues.

5 participants

@danielburger1337@nicolas-grekas@GromNaN@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp