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

Update cidr.go #258

Merged
merged 5 commits into from
Nov 30, 2023
Merged

Update cidr.go #258

merged 5 commits into from
Nov 30, 2023

Conversation

hexagr
Copy link
Contributor

@hexagr hexagr commented Oct 20, 2023

Currently, the "-ip-format" flag for case 5 does not properly work. For example, as reflected in ticket 221, the command echo '127.0.0.1' | mapcidr -ip-format 5 incorrectly returns the value 281472812449793 when it should return the value 2130706433

This pull request fixes the function "IPToInteger" to correctly convert both IPv4 and IPv6 addresses to their respective integer representations.

Currently, the "-ip-format" flag for case 5 does not properly work. For example, as reflected in ticket 221, the command `echo '127.0.0.1' | mapcidr -ip-format 5` incorrectly returns the value `281472812449793` when it should return the value 
`2130706433`

This pull request fixes the function "IPToInteger" to correctly convert both IPv4 and IPv6 addresses to their respective integer representations.
@hexagr
Copy link
Contributor Author

hexagr commented Oct 22, 2023

One test failed, but it's because of asn. At first I thought asn_test.go was broken and needed to be refactored until I saw your remark on asnmap ticket 198. An issue with the API. Hopefully that gets resolved soon.

But on the other hand, I double checked the pull requests I sent and tested the build with the fix for the IPToInteger function, and it passes the integration tests you've provided.

integration-test % ./integration-test 
Running test cases for "Slice CIDRs by given host count"
[✓] Test "Slice CIDRs by given host count" passed!
Running test cases for "CIDR Arggregation"
[✓] Test "CIDR Arggregation" passed!
Running test cases for "CIDR Arggregation(file)"
[✓] Test "CIDR Arggregation(file)" passed!
Running test cases for "Match IP's(args) from CIDR"
[✓] Test "Match IP's(args) from CIDR" passed!
Running test cases for "IPRange IP count"
[✓] Test "IPRange IP count" passed!
Running test cases for "IPs Sort (descending order)"
[✓] Test "IPs Sort (descending order)" passed!
Running test cases for "IPRange & CIDR Count"
[✓] Test "IPRange & CIDR Count" passed!
Running test cases for "CIDR Exapansion"
[✓] Test "CIDR Exapansion" passed!
Running test cases for "use as library - cidr as IP net test"
[✓] Test "use as library - cidr as IP net test" passed!
Running test cases for "Multiple IPRange Aggregation"
[✓] Test "Multiple IPRange Aggregation" passed!
Running test cases for "Slice IPRange by given CIDR count"
[✓] Test "Slice IPRange by given CIDR count" passed!
Running test cases for "Slice IPRange by given host count"
[✓] Test "Slice IPRange by given host count" passed!
Running test cases for "CIDR IP Count"
[✓] Test "CIDR IP Count" passed!
Running test cases for "Filter IP's(file) from IPRange"
[✓] Test "Filter IP's(file) from IPRange" passed!
Running test cases for "IPRange Shuffle Port IPs"
[✓] Test "IPRange Shuffle Port IPs" passed!
Running test cases for "IPRange & CIDR Aggregation"
[✓] Test "IPRange & CIDR Aggregation" passed!
Running test cases for "IPRange & CIDR Expansion"
[✓] Test "IPRange & CIDR Expansion" passed!
Running test cases for "use as library - cidr from IP range test"
[✓] Test "use as library - cidr from IP range test" passed!
Running test cases for "CIDR Reverse Sort (descending order)"
[✓] Test "CIDR Reverse Sort (descending order)" passed!
Running test cases for "Slice CIDRs by given CIDR count"
[✓] Test "Slice CIDRs by given CIDR count" passed!
Running test cases for "CIDR Skip Base"
[✓] Test "CIDR Skip Base" passed!
Running test cases for "CIDR Shuffle Multiple Port IPs"
[✓] Test "CIDR Shuffle Multiple Port IPs" passed!
Running test cases for "Multiple IPRange Exapansion"
[✓] Test "Multiple IPRange Exapansion" passed!
Running test cases for "IPRange Sort (ascending order)"
[✓] Test "IPRange Sort (ascending order)" passed!
Running test cases for "use as library - ip test"
[✓] Test "use as library - ip test" passed!
Running test cases for "Multiple CIDR Exapansion"
[✓] Test "Multiple CIDR Exapansion" passed!
Running test cases for "CIDR Shuffle Port IPs"
[✓] Test "CIDR Shuffle Port IPs" passed!
Running test cases for "Match IP's(args) from IPRange"
[✓] Test "Match IP's(args) from IPRange" passed!
Running test cases for "IPRange Reverse Sort (descending order)"
[✓] Test "IPRange Reverse Sort (descending order)" passed!
Running test cases for "IPRange Shuffle IPs"
[✓] Test "IPRange Shuffle IPs" passed!
Running test cases for "CIDR Sort (ascending order)"
[✓] Test "CIDR Sort (ascending order)" passed!
Running test cases for "Match IP's(file) from CIDR"
[✓] Test "Match IP's(file) from CIDR" passed!
Running test cases for "Filter IP's(args) from CIDR"
[✓] Test "Filter IP's(args) from CIDR" passed!
Running test cases for "IPRange Aggregation"
[✓] Test "IPRange Aggregation" passed!
Running test cases for "Convert IPs to IPv6 from IPRange"
[✓] Test "Convert IPs to IPv6 from IPRange" passed!
Running test cases for "IPRange Skip Base"
[✓] Test "IPRange Skip Base" passed!
Running test cases for "IPRange Shuffle Multiple Port IPs"
[✓] Test "IPRange Shuffle Multiple Port IPs" passed!
Running test cases for "OutputFile case"
[✓] Test "OutputFile case" passed!
Running test cases for "CIDR Appox Arggregation(file)"
[✓] Test "CIDR Appox Arggregation(file)" passed!
Running test cases for "CIDR Skip Broadcast"
[✓] Test "CIDR Skip Broadcast" passed!
Running test cases for "IPRange Exapansion"
[✓] Test "IPRange Exapansion" passed!
Running test cases for "IPs Sort (ascending order)"
[✓] Test "IPs Sort (ascending order)" passed!
Running test cases for "IPRange & CIDR Aggregation(file)"
[✓] Test "IPRange & CIDR Aggregation(file)" passed!
Running test cases for "Convert IPs to IPv6"
[✓] Test "Convert IPs to IPv6" passed!
Running test cases for "CIDR Shuffle IPs"
[✓] Test "CIDR Shuffle IPs" passed!
Running test cases for "IPRange Skip Broadcast"
[✓] Test "IPRange Skip Broadcast" passed!
Running test cases for "IPRange & CIDR convert IPs to IPv6"
[✓] Test "IPRange & CIDR convert IPs to IPv6" passed!
Running test cases for "Filter IP's(file) from CIDR"
[✓] Test "Filter IP's(file) from CIDR" passed!

@Mzack9999 Mzack9999 self-requested a review November 30, 2023 17:37
@Mzack9999 Mzack9999 merged commit d8b431b into projectdiscovery:main Nov 30, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants