Tom,

FYI - The code below seems to work:

if($c->{enable_clamav_virus_scan})
   {
      &lmsg("MSG:'$fhash->{file_name_orig}': Scanning for viruses...");
      my $dir2 = $dir;
      $dir2=~s/\\/\\\\/g;
      my $clam = join '', `clamdscan "$dir2\\$fhash->{file_name}"`;
      &lmsg("CLAM('$dir\\$fhash->{file_name}'):$clam");
      if($clam!~/Infected files: 0/gis || $clam=~/FOUND/s)
      {
         unlink("$c->{target_dir}/$fhash->{file_name}");
         &lmsg("MSG:'$fhash->{file_name_orig}' contain virus. Skipping.");
         $fhash->{file_status}="contain virus";
         return $fhash;
      }
   }

Jeff

--

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tom Metro
Sent: Monday, November 05, 2007 1:13 PM
To: [email protected]
Subject: Re: [clamav-win32] Using ClamAV and Perl Upload script gives false
positives

jeffshead wrote:
>       my $clam = join '', `clamdscan --no-summary
> $c->{target_dir}/$fhash->{file_name}`;
> 
>       if($clam!~/command not found/ && $clam!~/$fhash->{file_name}: OK/)
>       {

I'd recommend examining the exit code ($?) returned by clamdscan (see 
"perldoc -f system" for more details), rather than trying to parse the 
text it prints to STDOUT. I haven't tried this with clamdscan, but most 
command line scanners indicate the result of their scan via an exit code.

More generally your approach won't catch errors clamdscan writes to 
STDERR, and I'm not sure your trap for m/command not found/ being sent 
to STDOUT will work. Have you tested it? The above man page I mentioned 
has more details on using the system function and trapping errors.

There is also a Perl module that provides a richer API for working with 
ClamAV. I believe it'll take the place of clamdscan and let you submit 
files directly to clamd.

  -Tom

-- 
Tom Metro
Venture Logic, Newton, MA, USA
"Enterprise solutions through open source."
Professional Profile: http://tmetro.venturelogic.com/
_______________________________________________
http://lists.clamav.net/cgi-bin/mailman/listinfo/clamav-win32

_______________________________________________
http://lists.clamav.net/cgi-bin/mailman/listinfo/clamav-win32

Reply via email to