line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::VirusScan::Result; |
2
|
23
|
|
|
23
|
|
137
|
use strict; |
|
23
|
|
|
|
|
38
|
|
|
23
|
|
|
|
|
577
|
|
3
|
23
|
|
|
23
|
|
99
|
use warnings; |
|
23
|
|
|
|
|
38
|
|
|
23
|
|
|
|
|
482
|
|
4
|
23
|
|
|
23
|
|
193
|
use Carp; |
|
23
|
|
|
|
|
42
|
|
|
23
|
|
|
|
|
7580
|
|
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
|
|
|
8
|
}; |
16
|
2
|
|
|
|
|
8
|
return bless $self, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub error |
20
|
|
|
|
|
|
|
{ |
21
|
2
|
|
|
2
|
1
|
15
|
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
|
307
|
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
|
|
60
|
my ($class, @methods) = @_; |
75
|
23
|
|
|
23
|
|
178
|
no strict 'refs'; ## no critic (ProhibitNoStrict) |
|
23
|
|
|
|
|
67
|
|
|
23
|
|
|
|
|
2594
|
|
76
|
23
|
|
|
|
|
51
|
foreach my $name (@methods) { |
77
|
92
|
|
|
|
|
183
|
my $wrappername = "${class}::is_${name}"; |
78
|
92
|
50
|
|
|
|
104
|
if(!defined &{$wrappername}) { |
|
92
|
|
|
|
|
384
|
|
79
|
92
|
|
|
|
|
328
|
*{$wrappername} = sub { |
80
|
6
|
|
|
6
|
|
1128
|
my ($self) = @_; |
81
|
6
|
|
|
|
|
23
|
return ($self->{state} eq $name); |
82
|
92
|
|
|
|
|
230
|
}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
23
|
|
|
23
|
|
162
|
use strict 'refs'; |
|
23
|
|
|
|
|
63
|
|
|
23
|
|
|
|
|
1118
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
__END__ |