Identifier/Plugin/Google.pm

filter: Statementstmt 64.5% 20 / 31 Branchbran n/a Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 85.7% 6 / 7 Podpod 66.6% 2 / 3 totaltotal 63.0% 29 / 46 CC 3 SCAR 8.5
CC
3
Cov
62%
refresh
6.0
new
2.1
BEGIN
1.0
CRAP 2.3
« Identifier/Regex.pm ↑ Summary Identifier/Plugin/Facebook.pm »
1 #===============================================================================
2 # PODNAME: Net::IP::Identifier::Plugin::Google
3 # ABSTRACT: identify Google (AS15169) owned IP addresses
4 #
5 # AUTHOR: Reid Augustin (REID)
6 # EMAIL: reid@hellosix.com
7 # CREATED: Mon Oct 6 14:01:00 PDT 2014
8 #===============================================================================
9  
10 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 #_ENTITY_REGEX_ google|postini
15  
16 package Net::IP::Identifier::Plugin::Google;
17  
18 1 ▶use Role::Tiny::With;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 with qw( Net::IP::Identifier_Role );
20  
21 1 our $VERSION = '0.111'; # VERSION
22  
23 2 ▶sub new {
Subroutine new: called CC=2 SCAR=7.2
Pod documented
24 2 my ($class, %opts) = @_;
25  
26 2 my $self = {};
27 2 ▶ bless $self, (ref $class || $class);
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
28  
29 # List of known Google (AS15169) IP blocks as of May 2015
30 2 $self->ips(
31 # 17 Network Blocks
32 '8.8.4.0/24',
33 '8.8.8.0/24',
34 '64.18.0.0/20',
35 '64.233.160.0/19',
36 '66.102.0.0/20',
37 '66.249.64.0/19',
38 '72.14.192.0/18',
39 '74.125.0.0/16',
40 '173.194.0.0/16',
41 '207.126.144.0/20',
42 '209.85.128.0/17',
43 '216.239.32.0/19',
44 '2001:4860::/32',
45 '2404:6800::/32',
46 '2607:f8b0::/32',
47 '2800:3f0::/32',
48 '2c0f:fb50::/32',
49 );
50 # NOTE: jwhois 207.126.144.0 - 207.126.159.255 and
51 # 64.18.0.0 - 64.18.15.255 indicate Postini, which is 'Google email
52 # security and archiving services'
53 # NOTE: 2a00:1450:4000::/36 is returned by the refresh method suggested
54 # by Google (see below), but "jwhois 2a00:1450:4000::" indicates it's
55 # unassigned.
56 2 return $self;
57 }
58  
59 5 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
Pod undocumented
60 5 return 'Google';
61 }
62  
63 0 ▶sub refresh {
Subroutine refresh: not called CC=2 SCAR=17.9
Pod documented
64 0 my ($self) = @_;
65  
66 0 my $google_DNS = '8.8.8.8'; # public Goodle DNS server _NO_CHECK_
67 # from https://support.google.com/a/answer/60764?hl=en
68 0 my $spf = `nslookup -q=TXT _spf.google.com $google_DNS`;
69 #print "$spf\n";
70 0 my (@blocks) = $spf =~ m/ include:(\S+)/g;
71 0 my @cidrs;
72 0 for my $block (@blocks) {
73 0 my $net_blocks = `nslookup -q=TXT $block $google_DNS`;
74 #print $net_blocks;
75 0 push @cidrs, $net_blocks =~ m/ ip.:(\S+)/g;
76 }
77 # not included in the above algorithm for some reason
78 0 unshift @cidrs, '8.8.8.0/24', '8.8.4.0/24'; # _NO_CHECK_
79 0 delete $self->{ips};
80 0 $self->ips(@cidrs);
81 #print join "\n", '', @cidrs, '';
82 }
83  
84 1 1;
85  
86 __END__
« Identifier/Regex.pm ↑ Summary Identifier/Plugin/Facebook.pm »