VirusScan/Engine/Command.pm

filter: Statementstmt 66.6% 26 / 39 Branchbran 25.0% 3 / 12 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 87.5% 7 / 8 Podpod 50.0% 1 / 2 totaltotal 57.5% 38 / 66 CC 8 SCAR 24.6
CC
8
Cov
56%
_run_commandline_scanner
30.0
new
4.8
BEGIN
1.0
CRAP 11.7
« VirusScan/Engine/Command/BitDefender/BDC.pm ↑ Summary VirusScan/Engine.pm »
1 package File::VirusScan::Engine::Command;
2 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 15 ▶use File::VirusScan::Engine;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 15 ▶use vars qw( @ISA );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 15 @ISA = qw( File::VirusScan::Engine );
9  
10 15 __PACKAGE__->follow_best_practice();
11 15 __PACKAGE__->mk_accessors( qw( command args ) );
12  
13 sub new
14 90 ▶{
Subroutine new: called CC=4 SCAR=15.8
Pod documented
15 90 my ($class, $conf) = @_;
16  
17 90 ▶ if(!$conf->{command}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($conf->{"command"}) 15 75 90
18 15 croak "Must supply a 'command' config value for $class";
19 }
20  
21 # TODO document
22 75 ▶ $conf->{args} ||= $class->default_arguments();
Condition33%1/3
$conf->{"args"} ||= $class->default_arguments
l!l&&r!l&&!r
0750
MC/DC0%0/2
$conf->{"args"} ||= $class->default_arguments
$conf->{"args"} $class->default_arguments
Truth table33%1/3
A ||= B
A= $conf->{"args"}B= $class->default_arguments
ABresult
1X1
011
000
23 75 ▶ if( exists $conf->{'+args'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $conf->{"+args"}) 0 75 75
24 0 push @{$conf->{args}}, @{ delete $conf->{'+args'} };
25 }
26  
27 75 return $class->SUPER::new( $conf );
28 }
29  
30 sub default_arguments
31 5 ▶{
Subroutine default_arguments: called CC=1 SCAR=0.0
Pod undocumented
32 5 return [ ];
33 }
34  
35 sub _run_commandline_scanner
36 0 ▶{
Subroutine _run_commandline_scanner: not called CC=5 SCAR=34.0
37 0 my ($self, $command, $match) = @_;
38  
39 0 ▶ $match = '.*' unless defined $match;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $match 0 0 0
40  
41 0 my $fh = IO::File->new("$command |");
42 0 ▶ unless ($fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fh) 0 0 0
43 0 die "Could not execute '$command': $!";
44 }
45  
46 0 my $msg;
47 0 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
48 0 ▶ $msg .= $_ if /$match/oi;
Branch: 1 branch
BranchTrueFalseTotal
if /$match/io 0 0 0
49 }
50 0 $fh->close;
51  
52 0 return ($? >> 8, $msg);
53 }
54  
55 15 1;
56  
57 __END__
« VirusScan/Engine/Command/BitDefender/BDC.pm ↑ Summary VirusScan/Engine.pm »