Skip to content

Fix CIDR validation logic to properly validate /8 masks#21

Closed
NiklavsE wants to merge 5 commits intomiddlewares:masterfrom
NiklavsE:improve-cidr-validation
Closed

Fix CIDR validation logic to properly validate /8 masks#21
NiklavsE wants to merge 5 commits intomiddlewares:masterfrom
NiklavsE:improve-cidr-validation

Conversation

@NiklavsE
Copy link
Copy Markdown

@NiklavsE NiklavsE commented Sep 24, 2025

This PR improves the isInCIDR function, as the previous logic did not properly match valid IPv4 CIDR blocks such as x.0.0.0/8.
The comparison approach was adapted from Symfony HttpFoundation IpUtils.
The logic still only supports Ipv4.

@NiklavsE NiklavsE changed the title improve CIDR validation logic Fix CIDR validation logic to properly validate /8 masks Sep 24, 2025
@NiklavsE NiklavsE marked this pull request as ready for review September 24, 2025 07:07
@oscarotero oscarotero requested a review from filisko September 25, 2025 19:51
@oscarotero
Copy link
Copy Markdown
Member

@filisko Can you take a look to this PR? Thank you!

@NiklavsE
Copy link
Copy Markdown
Author

@filisko, could you please review this?
Thanks.

@filisko
Copy link
Copy Markdown
Member

filisko commented Oct 30, 2025

@NiklavsE hi, thanks for the PR. Currently we use GH actions as our CI. Were you aware of that?

Sorry for the late reply, when I checked these changes a month ago, I played with the code to see if the old and new tests were really doing something and I wasn't very convinced (obviously, for edge cases), that's why I didn't approve it right away. Maybe I should check again.

On your side, could you do some checks the same way I did?

thanks! will check this these days.

@NiklavsE NiklavsE closed this Feb 3, 2026
@NiklavsE NiklavsE deleted the improve-cidr-validation branch February 3, 2026 07:43
Copy link
Copy Markdown
Member

@filisko filisko left a comment

Choose a reason for hiding this comment

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

thank you @NiklavsE ! keep supporting us!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants