line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::VirusScan::Engine::Daemon::Trend::Trophie; |
2
|
1
|
|
|
1
|
|
48092
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
4
|
1
|
|
|
1
|
|
3
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
63
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
263
|
use File::VirusScan::Engine::Daemon; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
30
|
use vars qw( @ISA ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
8
|
|
|
|
|
|
|
@ISA = qw( File::VirusScan::Engine::Daemon ); |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
368
|
use IO::Socket::UNIX; |
|
1
|
|
|
|
|
8474
|
|
|
1
|
|
|
|
|
4
|
|
11
|
1
|
|
|
1
|
|
363
|
use Cwd 'abs_path'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
293
|
use File::VirusScan::Result; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
490
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new |
16
|
|
|
|
|
|
|
{ |
17
|
9
|
|
|
9
|
1
|
10835
|
my ($class, $conf) = @_; |
18
|
|
|
|
|
|
|
|
19
|
9
|
100
|
|
|
|
42
|
if(!$conf->{socket_name}) { |
20
|
1
|
|
|
|
|
11
|
croak "Must supply a 'socket_name' config value for $class"; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
8
|
|
|
|
|
12
|
my $self = { socket_name => $conf->{socket_name}, }; |
24
|
|
|
|
|
|
|
|
25
|
8
|
|
|
|
|
30
|
return bless $self, $class; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _get_socket |
29
|
|
|
|
|
|
|
{ |
30
|
1
|
|
|
1
|
|
955
|
my ($self) = @_; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
8
|
my $sock = IO::Socket::UNIX->new(Peer => $self->{socket_name}); |
33
|
1
|
50
|
|
|
|
265
|
if(!defined $sock) { |
34
|
1
|
|
|
|
|
16
|
croak "Error: Could not connect to sophie daemon at $self->{socket_name}"; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
0
|
return $sock; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub scan |
41
|
|
|
|
|
|
|
{ |
42
|
1
|
|
|
1
|
1
|
731
|
my ($self, $path) = @_; |
43
|
|
|
|
|
|
|
|
44
|
1
|
50
|
|
|
|
28
|
if(abs_path($path) ne $path) { |
45
|
1
|
|
|
|
|
7
|
return File::VirusScan::Result->error("Path $path is not absolute"); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $sock = eval { $self->_get_socket }; |
|
0
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
if($@) { |
50
|
0
|
|
|
|
|
|
return File::VirusScan::Result->error($@); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
if(!$sock->print("$path\n")) { |
54
|
0
|
|
|
|
|
|
$sock->close; |
55
|
0
|
|
|
|
|
|
return File::VirusScan::Result->error("Could not get trophie to scan $path"); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
|
if(!$sock->flush) { |
59
|
0
|
|
|
|
|
|
$sock->close; |
60
|
0
|
|
|
|
|
|
return File::VirusScan::Result->error("Could not get trophie to scan $path"); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $scan_response; |
64
|
0
|
|
|
|
|
|
my $rc = $sock->sysread($scan_response, 256); |
65
|
0
|
|
|
|
|
|
$sock->close(); |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
if(!$rc) { |
68
|
0
|
|
|
|
|
|
return File::VirusScan::Result->error("Did not get response from trophie while scanning $path"); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
if($scan_response =~ m/^0/) { |
72
|
0
|
|
|
|
|
|
return File::VirusScan::Result->clean(); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
if($scan_response =~ m/^1/) { |
76
|
0
|
|
|
|
|
|
my ($virus_name) = $scan_response =~ /^1:(.*)$/; |
77
|
0
|
|
0
|
|
|
|
$virus_name ||= 'Unknown-trophie-virus'; |
78
|
0
|
|
|
|
|
|
return File::VirusScan::Result->virus($virus_name); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
0
|
|
|
|
|
if($scan_response =~ m/^-1:(.*)$/) { |
82
|
0
|
|
|
|
|
|
my $error_message = $1; |
83
|
0
|
|
0
|
|
|
|
$error_message ||= 'unknown error'; |
84
|
0
|
|
|
|
|
|
return File::VirusScan::Result->error($error_message); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
return File::VirusScan::Result->error('Unknown response from trophie'); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
__END__ |