line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Audit::Version; |
2
|
3
|
|
|
3
|
|
68215
|
use strict; |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
84
|
|
3
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
79
|
|
4
|
3
|
|
|
3
|
|
883
|
use version; |
|
3
|
|
|
|
|
4016
|
|
|
3
|
|
|
|
|
18
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "1.001"; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
2
|
|
|
2
|
0
|
3512
|
my $class = shift; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
|
|
4
|
my $self = {}; |
12
|
2
|
|
|
|
|
5
|
bless $self, $class; |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
|
|
4
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
0
|
BEGIN { |
18
|
3
|
|
|
3
|
|
379
|
use version; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
11
|
|
19
|
|
|
|
|
|
|
my $ops = { |
20
|
21
|
|
|
|
|
66
|
'<' => sub { $_[0] < 0 }, |
21
|
6
|
|
|
|
|
13
|
'<=' => sub { $_[0] <= 0 }, |
22
|
2
|
|
|
|
|
5
|
'==' => sub { $_[0] == 0 }, |
23
|
7
|
|
|
|
|
18
|
'>' => sub { $_[0] > 0 }, |
24
|
24
|
|
|
|
|
54
|
'>=' => sub { $_[0] >= 0 }, |
25
|
2
|
|
|
|
|
5
|
'!=' => sub { $_[0] != 0 }, |
26
|
3
|
|
|
3
|
|
356
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub in_range { |
29
|
64
|
|
|
64
|
0
|
131
|
my( $self, $version, $range ) = @_; |
30
|
64
|
|
|
|
|
120
|
my( @original ) = ($version, $range); |
31
|
64
|
100
|
100
|
|
|
253
|
return unless defined $version && defined $range; |
32
|
62
|
|
|
|
|
194
|
my @ands = split /\s*,\s*/, $range; |
33
|
|
|
|
|
|
|
|
34
|
62
|
100
|
|
|
|
92
|
return unless defined( $version = eval { version->parse($version) } ); |
|
62
|
|
|
|
|
367
|
|
35
|
|
|
|
|
|
|
|
36
|
60
|
|
|
|
|
111
|
my $result = 1; |
37
|
|
|
|
|
|
|
|
38
|
60
|
|
|
|
|
100
|
foreach my $and (@ands) { |
39
|
64
|
|
|
|
|
338
|
my( $op, $range_version ) = $and =~ m/^(<=|<|>=|>|==|!=)?\s*([^\s]+)$/; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
return |
42
|
64
|
100
|
|
|
|
105
|
unless defined( $range_version = eval { version->parse($range_version) } ); |
|
64
|
|
|
|
|
328
|
|
43
|
|
|
|
|
|
|
|
44
|
62
|
100
|
|
|
|
130
|
$op = '>=' unless defined $op; |
45
|
62
|
50
|
|
|
|
126
|
unless( exists $ops->{$op} ) { $result = 0; last; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
46
|
|
|
|
|
|
|
|
47
|
3
|
|
|
3
|
|
1194
|
no warnings qw(numeric); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
301
|
|
48
|
62
|
|
|
|
|
231
|
$result = $ops->{$op}->( version::vcmp($version, $range_version) ); |
49
|
62
|
100
|
|
|
|
226
|
last if $result == 0; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
58
|
|
|
|
|
240
|
return $result; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub affected_versions { |
57
|
1
|
|
|
1
|
0
|
5
|
my( $self, $available_versions, $range ) = @_; |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
2
|
my @affected_versions; |
60
|
1
|
|
|
|
|
3
|
foreach my $version (@$available_versions) { |
61
|
3
|
100
|
|
|
|
6
|
if ( $self->in_range( $version, $range ) ) { |
62
|
2
|
|
|
|
|
5
|
push @affected_versions, $version; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
5
|
return @affected_versions; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |