File Coverage

lib/Beekeeper/AnyEvent.pm
Criterion Covered Total %
statement 22 22 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod n/a
total 30 30 100.0


line stmt bran cond sub pod time code
1             package Beekeeper::AnyEvent;
2              
3 11     11   82 use strict;
  11         23  
  11         325  
4 11     11   56 use warnings;
  11         20  
  11         493  
5              
6             our $VERSION = '0.08';
7              
8 11     11   10926 use AnyEvent;
  11         57868  
  11         438  
9 11     11   7413 use AnyEvent::Socket;
  11         304904  
  11         1639  
10              
11              
12             USE_PERL_BACKEND: {
13              
14             # Prefer AnyEvent perl backend over default EV, as it is fast enough
15             # and it does not ignore exceptions thrown from within callbacks
16              
17             $ENV{'PERL_ANYEVENT_MODEL'} ||= 'Perl' unless $AnyEvent::MODEL;
18             }
19              
20             UNTAINT_IP_ADDR: {
21              
22 11     11   122 no strict 'refs';
  11         28  
  11         388  
23 11     11   63 no warnings 'redefine';
  11         22  
  11         2136  
24              
25             # Addresses resolved by AnyEvent::DNS are tainted, causing an "Insecure
26             # dependency in connect" error when running with taint mode enabled.
27             # These addresses can be blindly untainted before being passed to parse_ipv4
28             # and parse_ipv6 because these functions validate addresses properly
29              
30             my $parse_ipv4 = \&{'AnyEvent::Socket::parse_ipv4'};
31             *{'AnyEvent::Socket::parse_ipv4'} = sub ($) {
32 19     19   341 ($_[0]) = $_[0] =~ m/(.*)/s; # untaint addr
33 19         151 $parse_ipv4->(@_);
34             };
35              
36             my $parse_ipv6 = \&{'AnyEvent::Socket::parse_ipv6'};
37             *{'AnyEvent::Socket::parse_ipv6'} = sub ($) {
38 38     38   7309 ($_[0]) = $_[0] =~ m/(.*)/s; # untaint addr
39 38         212 $parse_ipv6->(@_);
40             };
41             }
42              
43             1;
44              
45             __END__