line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::VirusScan::Result; |
2
|
23
|
|
|
23
|
|
149
|
use strict; |
|
23
|
|
|
|
|
44
|
|
|
23
|
|
|
|
|
584
|
|
3
|
23
|
|
|
23
|
|
96
|
use warnings; |
|
23
|
|
|
|
|
43
|
|
|
23
|
|
|
|
|
491
|
|
4
|
23
|
|
|
23
|
|
211
|
use Carp; |
|
23
|
|
|
|
|
43
|
|
|
23
|
|
|
|
|
7441
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my @STATES = qw( clean error virus suspicious ); |
7
|
|
|
|
|
|
|
__PACKAGE__->_make_accessors(@STATES); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new |
10
|
|
|
|
|
|
|
{ |
11
|
2
|
|
|
2
|
1
|
3
|
my ($class, $args) = @_; |
12
|
|
|
|
|
|
|
my $self = { |
13
|
|
|
|
|
|
|
state => $args->{state} || 'clean', |
14
|
|
|
|
|
|
|
data => $args->{data}, |
15
|
2
|
|
50
|
|
|
9
|
}; |
16
|
2
|
|
|
|
|
8
|
return bless $self, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub error |
20
|
|
|
|
|
|
|
{ |
21
|
2
|
|
|
2
|
1
|
14
|
my ($class, $err) = @_; |
22
|
2
|
|
|
|
|
7
|
return $class->new( |
23
|
|
|
|
|
|
|
{ |
24
|
|
|
|
|
|
|
state => 'error', |
25
|
|
|
|
|
|
|
data => $err, |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub virus |
31
|
|
|
|
|
|
|
{ |
32
|
0
|
|
|
0
|
1
|
0
|
my ($class, $vname) = @_; |
33
|
0
|
|
|
|
|
0
|
return $class->new( |
34
|
|
|
|
|
|
|
{ |
35
|
|
|
|
|
|
|
state => 'virus', |
36
|
|
|
|
|
|
|
data => $vname, |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub suspicious |
42
|
|
|
|
|
|
|
{ |
43
|
0
|
|
|
0
|
1
|
0
|
my ($class, $what) = @_; |
44
|
0
|
|
|
|
|
0
|
return $class->new( |
45
|
|
|
|
|
|
|
{ |
46
|
|
|
|
|
|
|
state => 'suspicious', |
47
|
|
|
|
|
|
|
data => $what, |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub clean |
53
|
|
|
|
|
|
|
{ |
54
|
0
|
|
|
0
|
1
|
0
|
my ($class) = @_; |
55
|
0
|
|
|
|
|
0
|
return $class->new({ state => 'clean', }); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub get_state |
59
|
|
|
|
|
|
|
{ |
60
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
61
|
0
|
|
|
|
|
0
|
return $self->{state}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub get_data |
65
|
|
|
|
|
|
|
{ |
66
|
2
|
|
|
2
|
1
|
372
|
my ($self) = @_; |
67
|
2
|
|
|
|
|
10
|
return $self->{data}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Generate is_XXX accessors for all valid states |
72
|
|
|
|
|
|
|
sub _make_accessors |
73
|
0
|
|
|
|
|
|
{ |
74
|
23
|
|
|
23
|
|
69
|
my ($class, @methods) = @_; |
75
|
23
|
|
|
23
|
|
180
|
no strict 'refs'; ## no critic (ProhibitNoStrict) |
|
23
|
|
|
|
|
64
|
|
|
23
|
|
|
|
|
2475
|
|
76
|
23
|
|
|
|
|
47
|
foreach my $name (@methods) { |
77
|
92
|
|
|
|
|
183
|
my $wrappername = "${class}::is_${name}"; |
78
|
92
|
50
|
|
|
|
134
|
if(!defined &{$wrappername}) { |
|
92
|
|
|
|
|
390
|
|
79
|
92
|
|
|
|
|
342
|
*{$wrappername} = sub { |
80
|
6
|
|
|
6
|
|
1461
|
my ($self) = @_; |
81
|
6
|
|
|
|
|
21
|
return ($self->{state} eq $name); |
82
|
92
|
|
|
|
|
268
|
}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
23
|
|
|
23
|
|
146
|
use strict 'refs'; |
|
23
|
|
|
|
|
60
|
|
|
23
|
|
|
|
|
1161
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
__END__ |