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   79 use strict;
  11         23  
  11         311  
4 11     11   55 use warnings;
  11         23  
  11         441  
5              
6             our $VERSION = '0.10';
7              
8 11     11   10580 use AnyEvent;
  11         57067  
  11         390  
9 11     11   6954 use AnyEvent::Socket;
  11         298902  
  11         1579  
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   142 no strict 'refs';
  11         26  
  11         381  
23 11     11   74 no warnings 'redefine';
  11         29  
  11         2128  
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   359 ($_[0]) = $_[0] =~ m/(.*)/s; # untaint addr
33 19         126 $parse_ipv4->(@_);
34             };
35              
36             my $parse_ipv6 = \&{'AnyEvent::Socket::parse_ipv6'};
37             *{'AnyEvent::Socket::parse_ipv6'} = sub ($) {
38 38     38   6998 ($_[0]) = $_[0] =~ m/(.*)/s; # untaint addr
39 38         200 $parse_ipv6->(@_);
40             };
41             }
42              
43             1;
44              
45             __END__