| 1 | package File::VirusScan::Engine::Command::NAI::Uvscan; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use File::VirusScan::Engine::Command; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use vars qw( @ISA ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | @ISA = qw( File::VirusScan::Engine::Command ); | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Cwd 'abs_path'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use File::VirusScan::Result; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | sub default_arguments | ||||||||||||||||||||||||||||
| 15 | 5 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
default_arguments: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 16 | 5 | return [ qw( --mime --noboot --secure --allole ) ]; | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | sub scan | ||||||||||||||||||||||||||||
| 20 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
scan: not called CC=18 SCAR=58.3
Pod
documented
| |||||||||||||||||||||||||||||
| 21 | 0 | my ($self, $path) = @_; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | my $abs = abs_path($path); | |||||||||||||||||||||||||||
| 24 | 0 | ▶ | if ($abs && $abs ne $path) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$abs and $abs ne $path
MC/DC0%0/2
$abs and $abs ne $path
$abs
$abs ne $path
Truth table0%0/3
A and B
A= $absB= $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/Found/,); }; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | if($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 0 | return File::VirusScan::Result->error($@); | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if(0 == $exitcode) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | return File::VirusScan::Result->clean(); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if(2 == $exitcode) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 0 | return File::VirusScan::Result->error('Driver integrity check failed'); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if(6 == $exitcode) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | # "A general problem occurred" -- idiot Windoze | ||||||||||||||||||||||||||||
| 45 | # programmers... nothing else to do but pass it on | ||||||||||||||||||||||||||||
| 46 | 0 | return File::VirusScan::Result->error('General problem occurred'); | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | if(8 == $exitcode) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 0 | return File::VirusScan::Result->error('Could not find a driver'); | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if(12 == $exitcode) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | return File::VirusScan::Result->error('Scanner tried to clean file, but failed'); | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if(13 == $exitcode) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | # Finally, the virus-hit case | ||||||||||||||||||||||||||||
| 60 | # | ||||||||||||||||||||||||||||
| 61 | # TODO: what if more than one virus found? | ||||||||||||||||||||||||||||
| 62 | # TODO: can/should we capture infected filenames? | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | # Sigh... stupid NAI can't have a standard message. Go | ||||||||||||||||||||||||||||
| 65 | # through hoops to get virus name. | ||||||||||||||||||||||||||||
| 66 | 0 | $scan_response =~ s/ !+//; | |||||||||||||||||||||||||||
| 67 | 0 | $scan_response =~ s/!+//; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | my $virus_name = ''; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | for ($scan_response) { | |||||||||||||||||||||||||||
| 72 | 0 | ▶ | m/Found: EICAR test file/i && do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 0 | $virus_name = 'EICAR-Test'; | |||||||||||||||||||||||||||
| 74 | 0 | last; | |||||||||||||||||||||||||||
| 75 | }; | ||||||||||||||||||||||||||||
| 76 | 0 | ▶ | m/^\s+Found the (\S+) .*virus/i && do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 0 | $virus_name = $1; | |||||||||||||||||||||||||||
| 78 | 0 | last; | |||||||||||||||||||||||||||
| 79 | }; | ||||||||||||||||||||||||||||
| 80 | 0 | ▶ | m/Found the (.*) trojan/i && do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | $virus_name = $1; | |||||||||||||||||||||||||||
| 82 | 0 | last; | |||||||||||||||||||||||||||
| 83 | }; | ||||||||||||||||||||||||||||
| 84 | 0 | ▶ | m/Found .* or variant (.*)/i && do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 0 | $virus_name = $1; | |||||||||||||||||||||||||||
| 86 | 0 | last; | |||||||||||||||||||||||||||
| 87 | }; | ||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if($virus_name eq '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 0 | $virus_name = 'unknown-NAI-virus'; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | return File::VirusScan::Result->virus($virus_name); | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if(19 == $exitcode) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 0 | return File::VirusScan::Result->error('Self-check failed'); | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if(102 == $exitcode) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 0 | return File::VirusScan::Result->error('User quit using --exit-on-error'); | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | return File::VirusScan::Result->error("Unknown return code from uvscan: $exitcode"); | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 1 | 1; | |||||||||||||||||||||||||||
| 109 | __END__ | ||||||||||||||||||||||||||||