ILIAS  release_8 Revision v8.23
ilVirusScannerICapClient Class Reference
+ Inheritance diagram for ilVirusScannerICapClient:
+ Collaboration diagram for ilVirusScannerICapClient:

Public Member Functions

 __construct (string $scan_command, string $clean_command)
 
 scanFile (string $file_path, string $org_name="")
 
- Public Member Functions inherited from ilVirusScanner
 __construct (string $scan_command, string $clean_command)
 
 scanBuffer (string $buffer)
 
 scanFile (string $file_path, string $org_name="")
 
 logScanResult ()
 
 cleanFile (string $file_path, string $org_name="")
 
 logCleanResult ()
 
 fileCleaned ()
 
 getScanResult ()
 
 getCleanResult ()
 
 getScanMessage ()
 
 getCleanMessage ()
 
 getScanZipFiles ()
 

Protected Member Functions

 buildScanCommandArguments ($file='-')
 
- Protected Member Functions inherited from ilVirusScanner
 scanFileFromBuffer (string $buffer)
 
 createBufferFile (string $buffer)
 
 removeBufferFile (string $bufferFile)
 

Private Attributes

const HEADER_INFECTION_FOUND = 'X-Infection-Found'
 

Additional Inherited Members

- Static Public Member Functions inherited from ilVirusScanner
static virusHandling (string $a_file, string $a_orig_name='', bool $a_clean=true)
 
- Data Fields inherited from ilVirusScanner
string $type
 
bool $scanZipFiles
 
string $scanCommand
 
string $cleanCommand
 
string $scanFilePath
 
string $scanFileOrigName
 
string $cleanFilePath
 
string $cleanFileOrigName
 
bool $scanFileIsInfected
 
bool $cleanFileIsCleaned
 
string $scanResult
 
string $cleanResult
 
ilErrorHandling $error
 
ilLanguage $lng
 
ilLogger $log
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilVirusScannerICapClient::__construct ( string  $scan_command,
string  $clean_command 
)

Definition at line 25 of file class.ilVirusScannerICapClient.php.

References ILIAS\GlobalScreen\Provider\__construct().

26  {
27  parent::__construct($scan_command, $clean_command);
28  $this->scanCommand = IL_ICAP_CLIENT;
29  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ buildScanCommandArguments()

ilVirusScannerICapClient::buildScanCommandArguments (   $file = '-')
protected
Parameters
string$file
Returns
string

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

Referenced by scanFile().

36  {
37  return ' -i ' . IL_ICAP_HOST . ' -p ' . IL_ICAP_PORT . ' -v -s ' . IL_ICAP_AV_COMMAND . ' -f ' . $file;
38  }
+ Here is the caller graph for this function:

◆ scanFile()

ilVirusScannerICapClient::scanFile ( string  $file_path,
string  $org_name = "" 
)

Definition at line 40 of file class.ilVirusScannerICapClient.php.

References $out, buildScanCommandArguments(), ilShellUtil\escapeShellArg(), ilShellUtil\escapeShellCmd(), and ilShellUtil\execQuoted().

40  : string
41  {
42  $return_string = '';
43  if (file_exists($file_path)) {
44  if (is_readable($file_path)) {
45  $file_path = realpath($file_path);
46  $args = ilShellUtil::escapeShellArg($file_path);
47  $arguments = $this->buildScanCommandArguments($args) . " 2>&1";
48  $cmd = ilShellUtil::escapeShellCmd($this->scanCommand);
49  $out = ilShellUtil::execQuoted($cmd, $arguments);
50  $timeout = preg_grep('/failed\/timedout.*/', $out);
51  $virus_detected = preg_grep('/' . self::HEADER_INFECTION_FOUND . '.*/', $out);
52  if (is_array($virus_detected) && count($virus_detected) > 0) {
53  $return_string = sprintf('Virus detected in %s', $file_path);
54  $this->log->warning($return_string);
55 
56  } elseif (is_array($timeout) && count($timeout) > 0) {
57  $return_string = 'Cannot connect to icap server.';
58  $this->log->warning($return_string);
59  }
60  $this->scanResult = implode("\n", $out);
61  } else {
62  $return_string = sprintf('File "%s" not readable.', $file_path);
63  $this->log->info($return_string);
64  }
65  } else {
66  $return_string = sprintf('File "%s" not found.', $file_path);
67  $this->log->info($return_string);
68  }
69 
70  $this->log->info(sprintf('No virus found in file "%s".', $file_path));
71  return $return_string;
72  }
static escapeShellArg(string $a_arg)
$out
Definition: buildRTE.php:24
static execQuoted(string $cmd, ?string $args=null)
static escapeShellCmd(string $a_arg)
+ Here is the call graph for this function:

Field Documentation

◆ HEADER_INFECTION_FOUND

const ilVirusScannerICapClient::HEADER_INFECTION_FOUND = 'X-Infection-Found'
private

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


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