Adds DrWeb virus scanner to MailScanner (#228)

This commit is contained in:
asuweb 2018-09-28 21:52:07 +01:00 committed by Shawn Iverson
parent 5083b4e0f0
commit 4367b27ff7
4 changed files with 86 additions and 0 deletions

View file

@ -684,6 +684,7 @@ Virus Scanning = yes
# avg from www.grisoft.com
# generic Other virus scanner: edit the generic-wrapper and generic-autoupdate
# to fit your own needs. The output spec is in generic-wrapper, or
# drweb from www.drweb.com (note: this is a commercial scanner)
# none No virus scanning at all.
#
#

View file

@ -28,3 +28,4 @@ generic /usr/lib/MailScanner/wrapper/generic-wrapper /dev/null
sophos /usr/lib/MailScanner/wrapper/sophos-wrapper /opt/sophos-av
sophossavi /bin/false /tmp
none /bin/false /dev/null
drweb /usr/lib/MailScanner/wrapper/drweb-wrapper /usr/bin

View file

@ -0,0 +1,35 @@
#!/bin/sh
#
# DrWeb wrapper
# 2003-11-13 Konrad Madej <kmadej@nask.pl>
# 2018-09-28 Alan Urquhart <alan@asuweb.co.uk> - Modified for MailScanner v5
#
PackageDir=$1
shift
prog=drweb-ctl
if [ "x$1" = "x-IsItInstalled" ]; then
[ -x ${PackageDir}/$prog ] && exit 0
exit 1
fi
# Remove last arg (subdir) from options
for i in $@
do
if [ -n "$last" ]
then
if [ -n "$opts" ]
then
opts="$opts $last"
else
opts="$last"
fi
fi
last=$i
done
subdir=$last
echo exec $PackageDir/$prog $opts scan "$subdir"
exec $PackageDir/$prog $opts scan "$subdir"

View file

@ -206,6 +206,17 @@ my %Scanners = (
SupportScanning => $S_SUPPORTED,
SupportDisinfect => $S_SUPPORTED,
},
"drweb" => {
Name => 'DrWeb',
Lock => 'drwebBusy.lock',
CommonOptions => '',
DisinfectOptions => '-cu',
ScanOptions => '',
InitParser => \&InitDrwebParser,
ProcessOutput => \&ProcessDrwebOutput,
SupportScanning => $S_SUPPORTED,
SupportDisinfect => $S_NONE,
},
);
# Initialise the Sophos SAVI library if we are using it.
@ -1161,6 +1172,11 @@ sub InitEsetsParser {
;
}
# Initialise any state variables the DrWeb output parser uses
sub InitDrwebParser {
;
}
# These functions must be called with, in order:
# * The line of output from the scanner
# * The MessageBatch object the reports are written to
@ -1882,6 +1898,39 @@ sub ProcessEsetsOutput {
return 1;
}
# Parse the output of the DrWeb output.
# Konrad Madej <kmadej@nask.pl>
# Modified 2018-09-28 - Alan Urquhart <alan@asuweb.co.uk>
sub ProcessDrwebOutput {
my($line, $infections, $types, $BaseDir, $Name) = @_;
my $report;
chomp $line;
return 0 unless $line =~ /^(.+)\s+infected\s+with\s+(.*)$/i;
my ($file, $virus) = ($1, $2);
my $logout = $line;
$logout =~ s/\s{20,}/ /g;
# Sample output:
#
# /var/spool/MailScanner/incoming/19551/1/neicar.com - infected with EICAR Test File (NOT a Virus!)
# Remove path elements before /./, // if any and
# , >, $BaseDir leaving just id/part/rest
$file =~ s/\/\.\//\//g;
$file =~ s/\/\//\//g;
$file =~ s/^>+//g;
$file =~ s/^$BaseDir//;
$file =~ s/^\///g;
my($id, $part, @rest) = split(/\//, $file);
#Removed trailing "-" which causes MailScanner to print empty string
$part = substr $part,0,-2;
my $notype = substr($part,1);
$logout =~ s/\Q$part\E/$notype/;
$report = $Name . ': ' if $Name;
$infections->{"$id"}{"$part"} .= "$report$notype was infected by $virus" . "\n";
$types->{"$id"}{"$part"} .= "v"; # it's a real virus
MailScanner::Log::InfoLog("DrWeb::INFECTED::$virus");
return 1;
}
# Generate a list of all the virus scanners that are installed. It may
# include extras that are not installed in the case where there are
# scanners whose name includes a version number and we could not tell