| 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
| |||||||||||||||||||||
| 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
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
| |||||||||||||||||||||
| 23 | 75 | ▶ | if( exists $conf->{'+args'} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 0 | my $fh = IO::File->new("$command |"); | |||||||||||||||||||
| 42 | 0 | ▶ | unless ($fh) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 43 | 0 | die "Could not execute '$command': $!"; | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 0 | my $msg; | |||||||||||||||||||
| 47 | 0 | ▶ | while (<$fh>) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 48 | 0 | ▶ | $msg .= $_ if /$match/oi; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | 0 | $fh->close; | |||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 0 | return ($? >> 8, $msg); | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 15 | 1; | |||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | __END__ | ||||||||||||||||||||