line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::VirusScan::Engine::Command::ClamAV::Clamscan; |
2
|
1
|
|
|
1
|
|
98470
|
use strict; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
24
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
4
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
367
|
use File::VirusScan::Engine::Command; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
44
|
use vars qw( @ISA ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
39
|
|
8
|
|
|
|
|
|
|
@ISA = qw( File::VirusScan::Engine::Command ); |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use Cwd 'abs_path'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
351
|
use File::VirusScan::Result; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
245
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub default_arguments |
15
|
|
|
|
|
|
|
{ |
16
|
5
|
|
|
5
|
0
|
30
|
return [qw(--stdout --no-summary --infected)]; |
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')); }; |
|
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
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# TODO: what if more than one virus found? |
41
|
|
|
|
|
|
|
# TODO: can/should we capture infected filenames? |
42
|
0
|
0
|
|
|
|
|
if($scan_response =~ m/: (.+) FOUND/) { |
|
|
0
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return File::VirusScan::Result->virus($1); |
44
|
|
|
|
|
|
|
} elsif($scan_response =~ m/: (.+) ERROR/) { |
45
|
0
|
|
|
|
|
|
my $err_detail = $1; |
46
|
0
|
|
|
|
|
|
return File::VirusScan::Result->error("clamscan error: $err_detail"); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return File::VirusScan::Result->error("Unknown return code from clamscan: $exitcode"); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
__END__ |