line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::VirusScan::Result; |
2
|
23
|
|
|
23
|
|
78
|
use strict; |
|
23
|
|
|
|
|
24
|
|
|
23
|
|
|
|
|
605
|
|
3
|
23
|
|
|
23
|
|
77
|
use warnings; |
|
23
|
|
|
|
|
25
|
|
|
23
|
|
|
|
|
631
|
|
4
|
23
|
|
|
23
|
|
69
|
use Carp; |
|
23
|
|
|
|
|
22
|
|
|
23
|
|
|
|
|
5761
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my @STATES = qw( clean error virus suspicious ); |
7
|
|
|
|
|
|
|
__PACKAGE__->_make_accessors(@STATES); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new |
10
|
|
|
|
|
|
|
{ |
11
|
22
|
|
|
22
|
1
|
44
|
my ($class, $args) = @_; |
12
|
22
|
|
50
|
|
|
145
|
my $self = { |
13
|
|
|
|
|
|
|
state => $args->{state} || 'clean', |
14
|
|
|
|
|
|
|
data => $args->{data}, |
15
|
|
|
|
|
|
|
}; |
16
|
22
|
|
|
|
|
101
|
return bless $self, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub error |
20
|
|
|
|
|
|
|
{ |
21
|
22
|
|
|
22
|
1
|
66
|
my ($class, $err) = @_; |
22
|
22
|
|
|
|
|
166
|
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
|
22
|
|
|
22
|
1
|
349
|
my ($self) = @_; |
67
|
22
|
|
|
|
|
129
|
return $self->{data}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Generate is_XXX accessors for all valid states |
72
|
|
|
|
|
|
|
sub _make_accessors |
73
|
|
|
|
|
|
|
{ |
74
|
23
|
|
|
23
|
|
41
|
my ($class, @methods) = @_; |
75
|
23
|
|
|
23
|
|
102
|
no strict 'refs'; ## no critic (ProhibitNoStrict) |
|
23
|
|
|
|
|
31
|
|
|
23
|
|
|
|
|
1856
|
|
76
|
23
|
|
|
|
|
35
|
foreach my $name (@methods) { |
77
|
92
|
|
|
|
|
117
|
my $wrappername = "${class}::is_${name}"; |
78
|
92
|
50
|
|
|
|
55
|
if(!defined &{$wrappername}) { |
|
92
|
|
|
|
|
349
|
|
79
|
92
|
|
|
|
|
292
|
*{$wrappername} = sub { |
80
|
26
|
|
|
26
|
|
8437
|
my ($self) = @_; |
81
|
26
|
|
|
|
|
264
|
return ($self->{state} eq $name); |
82
|
92
|
|
|
|
|
165
|
}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
23
|
|
|
23
|
|
232
|
use strict 'refs'; |
|
23
|
|
|
|
|
36
|
|
|
23
|
|
|
|
|
789
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
__END__ |