ILIAS  release_7 Revision v7.30-3-g800a261c036
ilVirusScannerAntiVir Class Reference

Interface to the AntiVir virus protector. More...

+ Inheritance diagram for ilVirusScannerAntiVir:
+ Collaboration diagram for ilVirusScannerAntiVir:

Public Member Functions

 __construct ($a_scancommand, $a_cleancommand)
 Constructor public. More...
 
 scanFile ($a_filepath, $a_origname="")
 scan a file for viruses More...
 
- Public Member Functions inherited from ilVirusScanner
 __construct ($a_scancommand, $a_cleancommand)
 Constructor public. More...
 
 scanBuffer ($buffer)
 
 scanFile ($a_filepath, $a_origname="")
 scan a file for viruses needs to be redefined in child classes here it simulates a scan "infected.txt" or "cleanable.txt" are expected to be infected More...
 
 cleanFile ($a_filepath, $a_origname="")
 clean an infected file needs to be redefined in child classes here it simulates a clean "cleanable.txt" is expected to be cleanable More...
 
 fileCleaned ()
 returns wether file has been cleaned successfully or not More...
 
 logScanResult ()
 write the result of the last scan to the log public More...
 
 logCleanResult ()
 write the result of the last clean to the log public More...
 
 getScanResult ()
 get the pure output of the external scan More...
 
 getCleanResult ()
 get the pure output of the external scan More...
 
 getScanMessage ()
 get a located message with the result from the last scan More...
 
 getCleanMessage ()
 get a located message with the result from the last clean More...
 
 getScanZipFiles ()
 get info if class can scan ZIP files More...
 

Additional Inherited Members

- Data Fields inherited from ilVirusScanner
 $type
 
 $scanZipFiles
 
 $scanCommand
 
 $cleanCommand
 
 $scanFilePath
 
 $scanFileOrigName
 
 $cleanFilePath
 
 $cleanFileOrigName
 
 $scanFileIsInfected
 
 $cleanFileIsCleaned
 
 $scanResult
 
 $cleanResult
 
 $ilias
 
 $lng
 
 $log
 
- Protected Member Functions inherited from ilVirusScanner
 scanFileFromBuffer ($buffer)
 
 createBufferFile ($buffer)
 
 removeBufferFile ($bufferFile)
 

Detailed Description

Interface to the AntiVir virus protector.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$
Deprecated:
since ILIAS 7.0, the last update for the virus database was 2016

Definition at line 14 of file class.ilVirusScannerAntiVir.php.

Constructor & Destructor Documentation

◆ __construct()

ilVirusScannerAntiVir::__construct (   $a_scancommand,
  $a_cleancommand 
)

Constructor public.

Parameters
stringvirus scanner command

Definition at line 21 of file class.ilVirusScannerAntiVir.php.

References ILIAS\GlobalScreen\Provider\__construct().

22  {
23  parent::__construct($a_scancommand, $a_cleancommand);
24  $this->type = "antivir";
25  $this->scanZipFiles = true;
26  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ scanFile()

ilVirusScannerAntiVir::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

Definition at line 35 of file class.ilVirusScannerAntiVir.php.

References $out, ilVirusScanner\$scanResult, ilUtil\escapeShellArg(), ilUtil\escapeShellCmd(), ilUtil\execQuoted(), and ilVirusScanner\logScanResult().

36  {
37  // This function should:
38  // - call the external scanner for a_filepath
39  // - set scanFilePath to a_filepath
40  // - set scanFileOrigName to a_origname
41  // - set scanFileIsInfected according the scan result
42  // - set scanResult to the scanner output message
43  // - call logScanResult() if file is infected
44  // - return the scanResult, if file is infected
45  // - return an empty string, if file is not infected
46 
47  $this->scanFilePath = $a_filepath;
48  $this->scanFileOrigName = $a_origname;
49 
50  // Call of antivir command
51  $a_filepath = realpath($a_filepath);
52  $cmd = ilUtil::escapeShellCmd($this->scanCommand);
53  $args = ilUtil::escapeShellArg(" " . $a_filepath . " ");
54  $out = ilUtil::execQuoted($cmd, $args);
55  $this->scanResult = implode("\n", $out);
56 
57  // sophie could be called
58  if (preg_match('/ALERT:/', $this->scanResult)) {
59  $this->scanFileIsInfected = true;
60  $this->logScanResult();
61  return $this->scanResult;
62  } else {
63  $this->scanFileIsInfected = false;
64  return "";
65  }
66 
67  // antivir has failed (todo)
68  $this->log->write("ERROR (Virus Scanner failed): "
69  . $this->scanResult
70  . "; COMMAMD=" . $cmd);
71  }
logScanResult()
write the result of the last scan to the log public
static escapeShellCmd($a_arg)
escape shell cmd
static execQuoted($cmd, $args=null)
exec command and fix spaces on windows
static escapeShellArg($a_arg)
+ Here is the call graph for this function:

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