line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Audit::Version; |
2
|
4
|
|
|
4
|
|
68115
|
use strict; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
120
|
|
3
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
136
|
|
4
|
4
|
|
|
4
|
|
895
|
use version; |
|
4
|
|
|
|
|
3991
|
|
|
4
|
|
|
|
|
37
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "1.001"; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
2
|
|
|
2
|
0
|
3700
|
my $class = shift; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
|
|
5
|
my $self = {}; |
12
|
2
|
|
|
|
|
5
|
bless $self, $class; |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
|
|
5
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
0
|
BEGIN { |
18
|
4
|
|
|
4
|
|
515
|
use version; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
14
|
|
19
|
|
|
|
|
|
|
my $ops = { |
20
|
21
|
|
|
|
|
41
|
'<' => sub { $_[0] < 0 }, |
21
|
6
|
|
|
|
|
15
|
'<=' => sub { $_[0] <= 0 }, |
22
|
2
|
|
|
|
|
5
|
'==' => sub { $_[0] == 0 }, |
23
|
7
|
|
|
|
|
17
|
'>' => sub { $_[0] > 0 }, |
24
|
24
|
|
|
|
|
52
|
'>=' => sub { $_[0] >= 0 }, |
25
|
2
|
|
|
|
|
7
|
'!=' => sub { $_[0] != 0 }, |
26
|
4
|
|
|
4
|
|
462
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub in_range { |
29
|
64
|
|
|
64
|
0
|
129
|
my( $self, $version, $range ) = @_; |
30
|
64
|
|
|
|
|
129
|
my( @original ) = ($version, $range); |
31
|
64
|
100
|
100
|
|
|
229
|
return unless defined $version && defined $range; |
32
|
62
|
|
|
|
|
199
|
my @ands = split /\s*,\s*/, $range; |
33
|
|
|
|
|
|
|
|
34
|
62
|
100
|
|
|
|
90
|
return unless defined( $version = eval { version->parse($version) } ); |
|
62
|
|
|
|
|
364
|
|
35
|
|
|
|
|
|
|
|
36
|
60
|
|
|
|
|
104
|
my $result = 1; |
37
|
|
|
|
|
|
|
|
38
|
60
|
|
|
|
|
111
|
foreach my $and (@ands) { |
39
|
64
|
|
|
|
|
317
|
my( $op, $range_version ) = $and =~ m/^(<=|<|>=|>|==|!=)?\s*([^\s]+)$/; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
return |
42
|
64
|
100
|
|
|
|
109
|
unless defined( $range_version = eval { version->parse($range_version) } ); |
|
64
|
|
|
|
|
327
|
|
43
|
|
|
|
|
|
|
|
44
|
62
|
100
|
|
|
|
134
|
$op = '>=' unless defined $op; |
45
|
62
|
50
|
|
|
|
123
|
unless( exists $ops->{$op} ) { $result = 0; last; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
46
|
|
|
|
|
|
|
|
47
|
4
|
|
|
4
|
|
1701
|
no warnings qw(numeric); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
382
|
|
48
|
62
|
|
|
|
|
211
|
$result = $ops->{$op}->( version::vcmp($version, $range_version) ); |
49
|
62
|
100
|
|
|
|
194
|
last if $result == 0; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
58
|
|
|
|
|
233
|
return $result; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub affected_versions { |
57
|
1
|
|
|
1
|
0
|
7
|
my( $self, $available_versions, $range ) = @_; |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
3
|
my @affected_versions; |
60
|
1
|
|
|
|
|
2
|
foreach my $version (@$available_versions) { |
61
|
3
|
100
|
|
|
|
7
|
if ( $self->in_range( $version, $range ) ) { |
62
|
2
|
|
|
|
|
5
|
push @affected_versions, $version; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
13
|
return @affected_versions; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |