line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::VirusScan::Engine::Command; |
2
|
15
|
|
|
15
|
|
87
|
use strict; |
|
15
|
|
|
|
|
26
|
|
|
15
|
|
|
|
|
372
|
|
3
|
15
|
|
|
15
|
|
62
|
use warnings; |
|
15
|
|
|
|
|
37
|
|
|
15
|
|
|
|
|
599
|
|
4
|
15
|
|
|
15
|
|
61
|
use Carp; |
|
15
|
|
|
|
|
25
|
|
|
15
|
|
|
|
|
612
|
|
5
|
|
|
|
|
|
|
|
6
|
15
|
|
|
15
|
|
4991
|
use File::VirusScan::Engine; |
|
15
|
|
|
|
|
44
|
|
|
15
|
|
|
|
|
129
|
|
7
|
15
|
|
|
15
|
|
757
|
use vars qw( @ISA ); |
|
15
|
|
|
|
|
29
|
|
|
15
|
|
|
|
|
3749
|
|
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
|
313674
|
my ($class, $conf) = @_; |
16
|
|
|
|
|
|
|
|
17
|
90
|
100
|
|
|
|
313
|
if(!$conf->{command}) { |
18
|
15
|
|
|
|
|
246
|
croak "Must supply a 'command' config value for $class"; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# TODO document |
22
|
75
|
|
33
|
|
|
727
|
$conf->{args} ||= $class->default_arguments(); |
23
|
75
|
50
|
|
|
|
234
|
if( exists $conf->{'+args'} ) { |
24
|
0
|
|
|
|
|
0
|
push @{$conf->{args}}, @{ delete $conf->{'+args'} }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
75
|
|
|
|
|
589
|
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__ |