Skip Menu |

This queue is for tickets about the Net-Whois-IANA CPAN distribution.

Report information
The Basics
Id: 42324
Status: resolved
Priority: 0/
Queue: Net-Whois-IANA

People
Owner: cpan [...] parparov.com
Requestors: jabra [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



The module does not consistently provide the CIDR information. I have written a patch will fixes this issue, in addition to adding a good deal of tests to verify that things are working properly. http://spl0it.org/files/patches/iana-cidr-update.patch Using the example from CPAN: #!/usr/bin/perl -w use strict; use Net::Whois::IANA; my $ip = '132.66.16.2'; my $iana = new Net::Whois::IANA; $iana->whois_query(-ip=>$ip); print "Country: " . $iana->country() . "\n";; print "Netname: " . $iana->netname() . "\n";; print "Descr: " . $iana->descr() . "\n";; print "Status: " . $iana->status() . "\n";; print "Source: " . $iana->source() . "\n";; print "Server: " . $iana->server() . "\n";; print "Inetnum: " . $iana->inetnum() . "\n";; print "CIDR: " . $iana->cidr() . "\n";; $ perl test.pl |grep CIDR CIDR: ARRAY(0x8489f64) This patches fixes the issue. $ patch -p0 < iana-cidr-update.patch patching file Net-Whois-IANA-0.23/IANA.pm patching file Net-Whois-IANA-0.23/t/afrinic.t patching file Net-Whois-IANA-0.23/t/apnic.t patching file Net-Whois-IANA-0.23/t/arin.t patching file Net-Whois-IANA-0.23/t/brnic.t patching file Net-Whois-IANA-0.23/t/ripe.t $ cd Net-Whois-IANA-0.23 $ ls Changes CREDITS IANA.pm Makefile.PL MANIFEST META.yml README t TODO $ perl Makefile.PL Checking if your kit is complete... Looks good Writing Makefile for Net::Whois::IANA $ make test cp IANA.pm blib/lib/Net/Whois/IANA.pm PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/afrinic....ok t/apnic......ok t/arin.......ok t/brnic......ok t/lacnic.....ok t/ripe.......ok All tests successful. Files=6, Tests=44, 4 wallclock secs ( 0.08 usr 0.01 sys + 0.92 cusr 0.10 csys = 1.11 CPU) ...install module... $ perl test.pl |grep CIDR CIDR: 132.66.0.0/16 Comments welcome. Regards, Jabra < jabra [shift 2] spl0it.org >
Have you attached your patch? R.
patch attached.
Subject: iana-cidr-update.patch
diff -ru Net-Whois-IANA-0.23/IANA.pm Net-Whois-IANA-0.23-new/IANA.pm --- Net-Whois-IANA-0.23/IANA.pm 2007-11-18 10:28:47.000000000 -0500 +++ Net-Whois-IANA-0.23-new/IANA.pm 2009-01-11 23:42:56.000000000 -0500 @@ -216,7 +216,7 @@ } else { $query{permission} = 'allowed'; - @{$query{cidr}} = Net::CIDR::range2cidr($query{inetnum}); + $query{cidr} = (Net::CIDR::range2cidr($query{inetnum})); } return %query; } @@ -263,7 +263,7 @@ } else { $query{permission} = 'allowed'; - $query{cidr} = [Net::CIDR::range2cidr($query{inetnum})]; + $query{cidr} = (Net::CIDR::range2cidr($query{inetnum})); } return %query; } @@ -322,7 +322,7 @@ $query{cidr} = [split(/\, /,$query{cidr})]; } else { - $query{cidr} = [$query{cidr}]; + $query{cidr} = ($query{cidr}); } } } @@ -361,6 +361,7 @@ close $sock; $query{descr} = $query{owner}; $query{netname} = $query{ownerid}; + $query{status} = $query{nettype}; $query{source} = 'LACNIC'; if ($query{inetnum}) { my ($zone, $span) = split(/\//,$query{inetnum}); @@ -368,8 +369,8 @@ if (scalar @atom < 4) { $zone .= '.0' x (4 - scalar @atom); } - $query{cidr} = [$zone . '/' . $span]; - $query{inetnum} = (Net::CIDR::cidr2range(@{$query{cidr}}))[0]; + $query{cidr} = ($zone . '/' . $span); + $query{inetnum} = (Net::CIDR::cidr2range($query{cidr}))[0]; } unless ($query{country}) { if ($query{nserver} =~ /\.(\w\w)$/) { @@ -413,7 +414,7 @@ } else { $query{permission} = 'allowed'; - @{$query{cidr}} = Net::CIDR::range2cidr($query{inetnum}); + $query{cidr} = (Net::CIDR::range2cidr($query{inetnum})); } return %query; } Only in Net-Whois-IANA-0.23-new/: Makefile Only in Net-Whois-IANA-0.23-new/: pm_to_blib diff -ru Net-Whois-IANA-0.23/t/afrinic.t Net-Whois-IANA-0.23-new/t/afrinic.t --- Net-Whois-IANA-0.23/t/afrinic.t 2005-06-22 04:32:14.000000000 -0400 +++ Net-Whois-IANA-0.23-new/t/afrinic.t 2009-01-11 23:50:56.000000000 -0500 @@ -1,8 +1,13 @@ -use Test::Simple tests=>2; +use Test::Simple tests=>8; use Net::Whois::IANA; my $iana = new Net::Whois::IANA; my $ip = '196.216.2.1'; $iana->whois_query(-ip=>$ip,-whois=>'afrinic'); ok(defined $iana); ok($iana->country() eq 'ZA'); - +ok($iana->descr() eq 'AfriNIC - Internal Use.'); +ok($iana->status() eq 'ASSIGNED PI'); +ok($iana->source() eq 'AFRINIC # Filtered'); +ok($iana->server() eq 'AFRINIC'); +ok($iana->inetnum() eq '196.216.2.0 - 196.216.3.255'); +ok($iana->cidr() eq '196.216.2.0/23'); diff -ru Net-Whois-IANA-0.23/t/apnic.t Net-Whois-IANA-0.23-new/t/apnic.t --- Net-Whois-IANA-0.23/t/apnic.t 2003-07-15 04:41:03.000000000 -0400 +++ Net-Whois-IANA-0.23-new/t/apnic.t 2009-01-11 23:54:32.000000000 -0500 @@ -1,8 +1,14 @@ -use Test::Simple tests=>2; +use Test::Simple tests=>9; use Net::Whois::IANA; my $iana = new Net::Whois::IANA; my $ip = '202.12.29.13'; $iana->whois_query(-ip=>$ip,-whois=>'apnic'); ok(defined $iana); ok($iana->country() eq 'AU'); - +ok($iana->netname() eq 'APNIC-AP'); +ok($iana->descr() eq 'Asia Pacific Network Information Center, Pty. Ltd.Level 1 - 33 Park Road.Milton QLD 4064Australia'); +ok($iana->status() eq 'ASSIGNED PORTABLE'); +ok($iana->source() eq 'APNIC'); +ok($iana->server() eq 'APNIC'); +ok($iana->inetnum() eq '202.12.28.0 - 202.12.29.255'); +ok($iana->cidr() eq '202.12.28.0/23'); diff -ru Net-Whois-IANA-0.23/t/arin.t Net-Whois-IANA-0.23-new/t/arin.t --- Net-Whois-IANA-0.23/t/arin.t 2003-07-15 04:40:52.000000000 -0400 +++ Net-Whois-IANA-0.23-new/t/arin.t 2009-01-11 23:31:39.000000000 -0500 @@ -1,8 +1,14 @@ -use Test::Simple tests=>2; +use Test::Simple tests=>9; use Net::Whois::IANA; my $iana = new Net::Whois::IANA; my $ip = '192.149.252.43'; $iana->whois_query(-ip=>$ip,-whois=>'arin'); ok(defined $iana); ok($iana->country() eq 'US'); - +ok($iana->netname() eq 'ARIN-NET'); +ok($iana->descr() eq 'American Registry for Internet Numbers'); +ok($iana->status() eq 'Direct Assignment'); +ok($iana->source() eq 'ARIN'); +ok($iana->server() eq 'ARIN'); +ok($iana->inetnum() eq '192.149.252.0 - 192.149.252.255'); +ok($iana->cidr() eq '192.149.252.0/24'); diff -ru Net-Whois-IANA-0.23/t/brnic.t Net-Whois-IANA-0.23-new/t/brnic.t --- Net-Whois-IANA-0.23/t/brnic.t 2007-11-17 07:50:30.000000000 -0500 +++ Net-Whois-IANA-0.23-new/t/brnic.t 2009-01-11 23:44:44.000000000 -0500 @@ -1,10 +1,12 @@ -use Test::Simple tests=>2; +use Test::Simple tests=>7; use Net::Whois::IANA; my $iana = new Net::Whois::IANA; my $ip = '200.160.2.15'; $iana->whois_query(-ip=>$ip,-whois=>'lacnic'); ok(defined $iana); -print $iana->{QUERY}{abuse}, " abuse\n"; -use Data::Dumper; ok($iana->country() eq 'BR'); - +ok($iana->netname() eq '005.506.560/0001-36'); +ok($iana->source() eq 'LACNIC'); +ok($iana->server() eq 'LACNIC'); +ok($iana->inetnum() eq '200.160.0.0-200.160.15.255'); +ok($iana->cidr() eq '200.160.0.0/20'); diff -ru Net-Whois-IANA-0.23/t/ripe.t Net-Whois-IANA-0.23-new/t/ripe.t --- Net-Whois-IANA-0.23/t/ripe.t 2004-09-28 04:47:44.000000000 -0400 +++ Net-Whois-IANA-0.23-new/t/ripe.t 2009-01-11 23:58:19.000000000 -0500 @@ -1,8 +1,14 @@ -use Test::Simple tests=>2; +use Test::Simple tests=>9; use Net::Whois::IANA; my $iana = new Net::Whois::IANA; my $ip = '193.0.0.135'; $iana->whois_query(-ip=>$ip,-whois=>'ripe'); ok(defined $iana); ok($iana->country() eq 'NL'); - +ok($iana->netname() eq 'RIPE-NCC'); +ok($iana->descr() eq 'RIPE Network Coordination CentreAmsterdam, Netherlands'); +ok($iana->status() eq 'ASSIGNED PI'); +ok($iana->source() eq 'RIPE # Filtered'); +ok($iana->server() eq 'RIPE'); +ok($iana->inetnum() eq '193.0.0.0 - 193.0.7.255'); +ok($iana->cidr() eq '193.0.0.0/21');
Fixed by changing the example usage, plus some cleanup. Thanks