File Coverage

blib/lib/File/VirusScan/Engine/Command/Sophos/Savscan.pm
Criterion Covered Total %
statement 22 42 52.3
branch 0 12 0.0
condition 0 5 0.0
subroutine 8 9 88.8
pod 1 2 50.0
total 31 70 44.2


line stmt bran cond sub pod time code
1             package File::VirusScan::Engine::Command::Sophos::Savscan;
2 1     1   110804 use strict;
  1         10  
  1         31  
3 1     1   6 use warnings;
  1         3  
  1         29  
4 1     1   4 use Carp;
  1         1  
  1         63  
5              
6 1     1   360 use File::VirusScan::Engine::Command;
  1         3  
  1         8  
7 1     1   52 use vars qw( @ISA );
  1         1  
  1         44  
8             @ISA = qw( File::VirusScan::Engine::Command );
9              
10 1     1   6 use Cwd 'abs_path';
  1         2  
  1         47  
11              
12 1     1   555 use File::VirusScan::Result;
  1         2  
  1         327  
13              
14             sub default_arguments
15             {
16 5     5 0 55 return [qw( -f -mime -all -cab -oe -tnef -archive -ss)];
17             }
18              
19             sub scan
20             {
21 0     0 1   my ($self, $path) = @_;
22              
23 0           my $abs = abs_path($path);
24 0 0 0       if ($abs && $abs ne $path) {
25 0           $path = $abs;
26             }
27              
28 0           my ($exitcode, $scan_response) = eval { $self->_run_commandline_scanner(join(' ', $self->{command}, @{ $self->{args} }, $path, '2>&1'), qr/(?:>>> Virus)|(?:Password)|(?:Could not check)/,); };
  0            
  0            
29              
30 0 0         if($@) {
31 0           return File::VirusScan::Result->error($@);
32             }
33              
34 0 0         if(0 == $exitcode) {
35 0           return File::VirusScan::Result->clean();
36             }
37              
38 0 0         if(1 == $exitcode) {
39 0           return File::VirusScan::Result->error('Virus scan interrupted');
40             }
41              
42 0 0         if(2 == $exitcode) {
43              
44             # This is technically an error code, but Sophos chokes
45             # on a lot of M$ docs with this code, so we let it
46             # through...
47             # TODO: Legacy commment from MIMEDefang. Figure this
48             # out and see if this is sane behaviour.
49 0           return File::VirusScan::Result->clean();
50             }
51              
52 0 0         if(3 == $exitcode) {
53 0           my ($virus_name) = $scan_response =~ m/\s*>>> Virus '(\S+)'/;
54 0   0       $virus_name ||= 'unknown-Savscan-virus';
55 0           return File::VirusScan::Result->virus($virus_name);
56             }
57              
58 0           return File::VirusScan::Result->error("Unknown return code from savscan: $exitcode");
59             }
60              
61             1;
62             __END__