line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Audit::Version; |
2
|
4
|
|
|
4
|
|
67749
|
use strict; |
|
4
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
120
|
|
3
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
104
|
|
4
|
4
|
|
|
4
|
|
868
|
use version; |
|
4
|
|
|
|
|
3886
|
|
|
4
|
|
|
|
|
25
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "1.001"; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
2
|
|
|
2
|
0
|
3424
|
my $class = shift; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
|
|
4
|
my $self = {}; |
12
|
2
|
|
|
|
|
4
|
bless $self, $class; |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
|
|
4
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
0
|
BEGIN { |
18
|
4
|
|
|
4
|
|
482
|
use version; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
14
|
|
19
|
|
|
|
|
|
|
my $ops = { |
20
|
21
|
|
|
|
|
43
|
'<' => sub { $_[0] < 0 }, |
21
|
6
|
|
|
|
|
14
|
'<=' => sub { $_[0] <= 0 }, |
22
|
2
|
|
|
|
|
6
|
'==' => sub { $_[0] == 0 }, |
23
|
7
|
|
|
|
|
16
|
'>' => sub { $_[0] > 0 }, |
24
|
24
|
|
|
|
|
46
|
'>=' => sub { $_[0] >= 0 }, |
25
|
2
|
|
|
|
|
34
|
'!=' => sub { $_[0] != 0 }, |
26
|
4
|
|
|
4
|
|
465
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub in_range { |
29
|
64
|
|
|
64
|
0
|
131
|
my( $self, $version, $range ) = @_; |
30
|
64
|
|
|
|
|
127
|
my( @original ) = ($version, $range); |
31
|
64
|
100
|
100
|
|
|
236
|
return unless defined $version && defined $range; |
32
|
62
|
|
|
|
|
185
|
my @ands = split /\s*,\s*/, $range; |
33
|
|
|
|
|
|
|
|
34
|
62
|
100
|
|
|
|
102
|
return unless defined( $version = eval { version->parse($version) } ); |
|
62
|
|
|
|
|
357
|
|
35
|
|
|
|
|
|
|
|
36
|
60
|
|
|
|
|
105
|
my $result = 1; |
37
|
|
|
|
|
|
|
|
38
|
60
|
|
|
|
|
106
|
foreach my $and (@ands) { |
39
|
64
|
|
|
|
|
312
|
my( $op, $range_version ) = $and =~ m/^(<=|<|>=|>|==|!=)?\s*([^\s]+)$/; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
return |
42
|
64
|
100
|
|
|
|
111
|
unless defined( $range_version = eval { version->parse($range_version) } ); |
|
64
|
|
|
|
|
328
|
|
43
|
|
|
|
|
|
|
|
44
|
62
|
100
|
|
|
|
131
|
$op = '>=' unless defined $op; |
45
|
62
|
50
|
|
|
|
124
|
unless( exists $ops->{$op} ) { $result = 0; last; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
46
|
|
|
|
|
|
|
|
47
|
4
|
|
|
4
|
|
1573
|
no warnings qw(numeric); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
369
|
|
48
|
62
|
|
|
|
|
238
|
$result = $ops->{$op}->( version::vcmp($version, $range_version) ); |
49
|
62
|
100
|
|
|
|
195
|
last if $result == 0; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
58
|
|
|
|
|
221
|
return $result; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub affected_versions { |
57
|
1
|
|
|
1
|
0
|
7
|
my( $self, $available_versions, $range ) = @_; |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
2
|
my @affected_versions; |
60
|
1
|
|
|
|
|
2
|
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
|
|
|
|
|
17
|
return @affected_versions; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |