Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Data-Validate-IP CPAN distribution.

Report information
The Basics
Id: 83081
Status: resolved
Priority: 0/
Queue: Data-Validate-IP

People
Owner: Nobody in particular
Requestors: OSCHWALD [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in:
  • 0.15-TRIAL
  • 0.16-TRIAL
  • 0.17
  • 0.18



Subject: is_public_ipv4 should not include reserved ranges
Download (untitled) / with headers
text/plain 118b
is_public_ipv4 returns true for many reserved ranges, e.g., 240.0.0.0/4 and 0.0.0.0/8, which makes it of limited use.
The attached diff should exclude unroutable reserved ranges.
Subject: is_public_fix.diff
Download is_public_fix.diff
text/x-diff 2.4k
diff -ru Data-Validate-IP-0.14/lib/Data/Validate/IP.pm ../Data-Validate-IP-0.14/lib/Data/Validate/IP.pm --- Data-Validate-IP-0.14/lib/Data/Validate/IP.pm 2011-01-06 06:29:26.000000000 -0800 +++ ../Data-Validate-IP-0.14/lib/Data/Validate/IP.pm 2013-01-31 20:36:15.418590406 -0800 @@ -13,6 +13,11 @@ use constant MULTICAST => [qw(224.0.0.0/4)]; use constant LINKLOCAL => [qw(169.254.0.0/16)]; +# Other unroutable reserved ranges +use constant UNROUTABLE => [qw(0.0.0.0/8 100.64.0.0/10 192.0.0.0/29 + 198.18.0.0/15 198.51.100.0/24 203.0.113.0/24 + 240.0.0.0/4) ]; + our @ISA = qw(Exporter); # Items to export into callers namespace by default. Note: do not export @@ -765,8 +770,7 @@ =item I<Notes, Exceptions, & Bugs> The function does not make any attempt to check whether an ip -actually exists or could truly route. This is true for any -non- private/testnet/loopback ip. +actually exists or could truly route. =back @@ -797,7 +801,7 @@ return $MASK{$type} if (defined $MASK{$type}); my @masks; if ($type eq 'public') { - @masks = (LOOPBACK, TESTNET, PRIVATE,MULTICAST,LINKLOCAL); + @masks = (LOOPBACK, TESTNET, PRIVATE,MULTICAST,LINKLOCAL, UNROUTABLE); } elsif ($type eq 'loopback') { @masks = (LOOPBACK); } elsif ($type eq 'private') { diff -ru Data-Validate-IP-0.14/t/Data-Validate-IP.t ../Data-Validate-IP-0.14/t/Data-Validate-IP.t --- Data-Validate-IP-0.14/t/Data-Validate-IP.t 2011-01-06 06:42:15.000000000 -0800 +++ ../Data-Validate-IP-0.14/t/Data-Validate-IP.t 2013-01-31 20:35:25.918591334 -0800 @@ -5,7 +5,7 @@ # change 'tests => 1' to 'tests => last_test_to_print'; -use Test::More tests => 50; +use Test::More tests => 52; BEGIN { use_ok('Data::Validate::IP', qw(is_ipv4 is_innet_ipv4 is_ipv6 is_private_ipv4 is_loopback_ipv4 is_testnet_ipv4 is_public_ipv4 is_multicast_ipv4 is_linklocal_ipv4 is_linklocal_ipv6) ) }; ######################### @@ -38,6 +38,10 @@ is (is_public_ipv4('216.17.184.1'), '216.17.184.1', 'is_public_ipv4 216.17.184.1'); is (is_public_ipv4('192.168.0.1'), undef, 'is_public_ipv4 192.168.0.1'); +is (is_public_ipv4('245.1.1.1'), undef, 'is_public_ipv4 245.1.1.1'); +is (is_public_ipv4('0.0.0.0'), undef, 'is_public_ipv4 0.0.0.0'); + + is (is_multicast_ipv4('224.0.0.1'), '224.0.0.1', 'is_multicast_ipv4 224.0.0.1'); is (is_multicast_ipv4('216.17.184.1'), undef, 'is_multicast_ipv4 216.17.184.1');


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.