line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::Fetch::HostBlockList; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
67575
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
17
|
|
5
|
1
|
|
|
1
|
|
13
|
use 5.008004; |
|
1
|
|
|
|
|
4
|
|
6
|
1
|
|
|
1
|
|
6
|
use Alien::Build::Plugin 2.64; |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
507
|
use URI; |
|
1
|
|
|
|
|
3887
|
|
|
1
|
|
|
|
|
238
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Reject any Alien::Build fetch requests going to hosts in the block list |
10
|
|
|
|
|
|
|
our $VERSION = '0.02'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has '+block_hosts' => sub { [ |
14
|
|
|
|
|
|
|
defined $ENV{ALIEN_BUILD_HOST_BLOCK} |
15
|
|
|
|
|
|
|
? split /,/, $ENV{ALIEN_BUILD_HOST_BLOCK} |
16
|
|
|
|
|
|
|
: () |
17
|
|
|
|
|
|
|
] }; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init |
20
|
|
|
|
|
|
|
{ |
21
|
1
|
|
|
1
|
1
|
103
|
my($self, $meta) = @_; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
2
|
my %blocked = map { $_ => 1 } @{ $self->block_hosts }; |
|
2
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
2
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$meta->around_hook( fetch => sub { |
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
3
|
|
10138
|
my $orig = shift; |
28
|
3
|
|
|
|
|
6
|
my $build = shift; |
29
|
3
|
|
66
|
|
|
10
|
my $url = $_[0] || $build->meta_prop->{start_url}; |
30
|
|
|
|
|
|
|
|
31
|
3
|
50
|
|
|
|
20
|
if($url =~ /:/) |
32
|
|
|
|
|
|
|
{ |
33
|
3
|
|
|
|
|
12
|
my $url = URI->new($url); |
34
|
3
|
50
|
|
|
|
7259
|
if($url->scheme ne 'file') |
35
|
|
|
|
|
|
|
{ |
36
|
3
|
|
|
|
|
144
|
my $host = eval { $url->host }; |
|
3
|
|
|
|
|
9
|
|
37
|
3
|
50
|
|
|
|
101
|
die "unable to determine host from $url: $@" if $@; |
38
|
3
|
100
|
|
|
|
29
|
die "The host $host is in the block list" if $blocked{$host}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
3
|
$orig->($build, @_); |
43
|
1
|
|
|
|
|
7
|
}); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |