line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::VirusScan::Engine::Command; |
2
|
15
|
|
|
15
|
|
87
|
use strict; |
|
15
|
|
|
|
|
27
|
|
|
15
|
|
|
|
|
370
|
|
3
|
15
|
|
|
15
|
|
71
|
use warnings; |
|
15
|
|
|
|
|
23
|
|
|
15
|
|
|
|
|
273
|
|
4
|
15
|
|
|
15
|
|
60
|
use Carp; |
|
15
|
|
|
|
|
25
|
|
|
15
|
|
|
|
|
577
|
|
5
|
|
|
|
|
|
|
|
6
|
15
|
|
|
15
|
|
5092
|
use File::VirusScan::Engine; |
|
15
|
|
|
|
|
38
|
|
|
15
|
|
|
|
|
126
|
|
7
|
15
|
|
|
15
|
|
699
|
use vars qw( @ISA ); |
|
15
|
|
|
|
|
29
|
|
|
15
|
|
|
|
|
3724
|
|
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
|
90
|
|
|
90
|
1
|
331517
|
my ($class, $conf) = @_; |
16
|
|
|
|
|
|
|
|
17
|
90
|
100
|
|
|
|
269
|
if(!$conf->{command}) { |
18
|
15
|
|
|
|
|
237
|
croak "Must supply a 'command' config value for $class"; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# TODO document |
22
|
75
|
|
33
|
|
|
679
|
$conf->{args} ||= $class->default_arguments(); |
23
|
75
|
50
|
|
|
|
185
|
if( exists $conf->{'+args'} ) { |
24
|
0
|
|
|
|
|
0
|
push @{$conf->{args}}, @{ delete $conf->{'+args'} }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
75
|
|
|
|
|
543
|
return $class->SUPER::new( $conf ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub default_arguments |
31
|
|
|
|
|
|
|
{ |
32
|
5
|
|
|
5
|
0
|
18
|
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__ |