line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::VirusScan::Engine::Command; |
2
|
15
|
|
|
15
|
|
50
|
use strict; |
|
15
|
|
|
|
|
20
|
|
|
15
|
|
|
|
|
340
|
|
3
|
15
|
|
|
15
|
|
55
|
use warnings; |
|
15
|
|
|
|
|
20
|
|
|
15
|
|
|
|
|
217
|
|
4
|
15
|
|
|
15
|
|
42
|
use Carp; |
|
15
|
|
|
|
|
17
|
|
|
15
|
|
|
|
|
556
|
|
5
|
|
|
|
|
|
|
|
6
|
15
|
|
|
15
|
|
4163
|
use File::VirusScan::Engine; |
|
15
|
|
|
|
|
34
|
|
|
15
|
|
|
|
|
119
|
|
7
|
15
|
|
|
15
|
|
643
|
use vars qw( @ISA ); |
|
15
|
|
|
|
|
16
|
|
|
15
|
|
|
|
|
3418
|
|
8
|
|
|
|
|
|
|
@ISA = qw( File::VirusScan::Engine ); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
__PACKAGE__->follow_best_practice(); |
11
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( qw( command args ) ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new |
14
|
|
|
|
|
|
|
{ |
15
|
105
|
|
|
105
|
1
|
195237
|
my ($class, $conf) = @_; |
16
|
|
|
|
|
|
|
|
17
|
105
|
100
|
|
|
|
311
|
if(!$conf->{command}) { |
18
|
15
|
|
|
|
|
269
|
croak "Must supply a 'command' config value for $class"; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# TODO document |
22
|
90
|
|
33
|
|
|
551
|
$conf->{args} ||= $class->default_arguments(); |
23
|
90
|
50
|
|
|
|
215
|
if( exists $conf->{'+args'} ) { |
24
|
0
|
|
|
|
|
0
|
push @{$conf->{args}}, @{ delete $conf->{'+args'} }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
90
|
|
|
|
|
642
|
return $class->SUPER::new( $conf ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub default_arguments |
31
|
|
|
|
|
|
|
{ |
32
|
6
|
|
|
6
|
0
|
19
|
return [ ]; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _run_commandline_scanner |
36
|
|
|
|
|
|
|
{ |
37
|
0
|
|
|
0
|
|
|
my ($self, $command, $match) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
$match = '.*' unless defined $match; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $fh = IO::File->new("$command |"); |
42
|
0
|
0
|
|
|
|
|
unless ($fh) { |
43
|
0
|
|
|
|
|
|
die "Could not execute '$command': $!"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $msg; |
47
|
0
|
|
|
|
|
|
while (<$fh>) { |
48
|
0
|
0
|
|
|
|
|
$msg .= $_ if /$match/oi; |
49
|
|
|
|
|
|
|
} |
50
|
0
|
|
|
|
|
|
$fh->close; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return ($? >> 8, $msg); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |