ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilVirusScannerSophos Class Reference

Interface to the sophos virus protector. More...

+ Inheritance diagram for ilVirusScannerSophos:
+ Collaboration diagram for ilVirusScannerSophos:

Public Member Functions

 ilVirusScannerSophos ($a_scancommand, $a_cleancommand)
 Constructor public.
 scanFile ($a_filepath, $a_origname="")
 scan a file for viruses
 cleanFile ($a_filepath, $a_origname="")
 clean an infected file
- Public Member Functions inherited from ilVirusScanner
 ilVirusScanner ($a_scancommand, $a_cleancommand)
 Constructor public.
 fileCleaned ()
 returns wether file has been cleaned successfully or not
 logScanResult ()
 write the result of the last scan to the log
 logCleanResult ()
 write the result of the last clean to the log
 getScanResult ()
 get the pure output of the external scan
 getCleanResult ()
 get the pure output of the external scan
 getScanMessage ()
 get a located message with the result from the last scan
 getCleanMessage ()
 get a located message with the result from the last clean
 getScanZipFiles ()
 get info if class can scan ZIP files

Additional Inherited Members

- Data Fields inherited from ilVirusScanner
 $type
 $scanZipFiles
 $scanCommand
 $cleanCommand
 $scanFilePath
 $scanFileOrigName
 $cleanFilePath
 $cleanFileOrigName
 $scanFileIsInfected
 $cleanFileIsCleaned
 $scanResult
 $cleanResult
 $ilias
 $lng
 $log

Detailed Description

Interface to the sophos virus protector.

Author
Fred Neumann fred..nosp@m.neum.nosp@m.ann@f.nosp@m.im.u.nosp@m.ni-er.nosp@m.lang.nosp@m.en.de
Version
Id:
class.ilVirusScannerSophos.php 20150 2009-06-08 18:02:33Z akill

Definition at line 16 of file class.ilVirusScannerSophos.php.

Member Function Documentation

ilVirusScannerSophos::cleanFile (   $a_filepath,
  $a_origname = "" 
)

clean an infected file

Parameters
stringpath of file to check
stringoriginal name of the file to check
Returns
string clean message (empty if not cleaned) public

Reimplemented from ilVirusScanner.

Definition at line 121 of file class.ilVirusScannerSophos.php.

References ilVirusScanner\$cleanResult, $cmd, $out, $ret, and ilVirusScanner\logCleanResult().

{
// This function should:
// - call the external cleaner
// - set cleanFilePath to a_filepath
// - set cleanFileOrigName to a_origname
// - set cleanFileIsCleaned according the clean result
// - set cleanResult to the cleaner output message
// - call logCleanResult in any case
// - return the cleanResult, if file is cleaned
// - return an empty string, if file is not cleaned
$this->cleanFilePath = $a_filepath;
$this->cleanFileOrigName = $a_origname;
// Call of sweep from Sophos (www.sophos.com)
// -di: Disinfect infected items
// -nc: Don't ask for confirmation before disinfection/deletion
// -ss: Don't display anything except on error or virus
// -eec: Use extended error codes
// -archive: sweep inside archives
$cmd = $this->cleanCommand . " -di -nc -ss -eec -archive " . $a_filepath . " 2>&1";
exec($cmd, $out, $ret);
$this->cleanResult = implode("\n", $out). " [". $ret. "]";
// always log the result from a clean attempt
$this->logCleanResult();
// Extended error codes from sweep:
// 0 If no errors are encountered and no viruses are found.
// 8 If survivable errors have occurred.
// 12 If compressed files have been found and decompressed.
// 16 If compressed files have been found and not decompressed.
// 20 If viruses have been found and disinfected.
// 24 If viruses have been found and not disinfected.
// 28 If viruses have been found in memory.
// 32 If there has been an integrity check failure.
// 36 If unsurvivable errors have occurred.
// 40 If execution has been interrupted.
if ($ret == 20)
{
$this->cleanFileIsCleaned = true;
}
else
{
$this->cleanFileIsCleaned = false;
return "";
}
}

+ Here is the call graph for this function:

ilVirusScannerSophos::ilVirusScannerSophos (   $a_scancommand,
  $a_cleancommand 
)

Constructor public.

Parameters
stringvirus scanner command

Definition at line 23 of file class.ilVirusScannerSophos.php.

References ilVirusScanner\ilVirusScanner().

{
$this->ilVirusScanner($a_scancommand, $a_cleancommand);
$this->type = "sophos";
$this->scanZipFiles = true;
}

+ Here is the call graph for this function:

ilVirusScannerSophos::scanFile (   $a_filepath,
  $a_origname = "" 
)

scan a file for viruses

Parameters
stringpath of file to check
stringoriginal name of the file to ckeck
Returns
string virus message (empty if not infected) public

Reimplemented from ilVirusScanner.

Definition at line 38 of file class.ilVirusScannerSophos.php.

References $cmd, $out, $ret, ilVirusScanner\$scanResult, and ilVirusScanner\logScanResult().

{
// This function should:
// - call the external scanner for a_filepath
// - set scanFilePath to a_filepath
// - set scanFileOrigName to a_origname
// - set scanFileIsInfected according the scan result
// - set scanResult to the scanner output message
// - call logScanResult() if file is infected
// - return the scanResult, if file is infected
// - return an empty string, if file is not infected
$this->scanFilePath = $a_filepath;
$this->scanFileOrigName = $a_origname;
// Call of scan_file from Sophie (www.vanja.com/tools/sophie)
// sophie must run as a process
$cmd = $this->scanCommand . " " . $a_filepath. " 2>&1";
exec($cmd, $out, $ret);
$this->scanResult = implode("\n", $out);
// sophie could be called
if ($ret == 0)
{
if (ereg("FILE INFECTED", $this->scanResult))
{
$this->scanFileIsInfected = true;
$this->logScanResult();
}
else
{
$this->scanFileIsInfected = false;
return "";
}
}
// sophie has failed (probably the daemon doesn't run)
$this->log->write("ERROR (Virus Scanner failed): "
. $this->scanResult
. "; COMMAMD=" . $cmd);
// try fallback: scan by cleaner command (sweep)
// -ss: Don't display anything except on error or virus
// -archive: sweep inside archives
unset($out, $ret);
$cmd = $this->cleanCommand . " -ss -archive " . $a_filepath . " 2>&1";
exec($cmd, $out, $ret);
$this->scanResult = implode("\n", $out). " [". $ret. "]";
// error codes from sweep:
// 0 If no errors are encountered and no viruses are found.
// 1 If the user interrupts SWEEP (usually by pressing control-C) or kills the process.
// 2 If some error preventing further execution is discovered.
// 3 If viruses or virus fragments are discovered.
if ($ret == 0)
{
$this->scanFileIsCleaned = false;
return "";
}
else if ($ret == 3)
{
$this->scanFileIsInfected = true;
$this->logScanResult();
}
else
{
$this->ilias->raiseError($this->lng->txt("virus_scan_error")." "
. $this->lng->txt("virus_scan_message")." "
$this->ilias->error_obj->WARNING);
}
}

+ Here is the call graph for this function:


The documentation for this class was generated from the following file: