ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 (string $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 
)

Reimplemented from ilVirusScanner.

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

26 {
27 parent::__construct($scan_command, $clean_command);
28 $this->scanCommand = IL_ICAP_CLIENT;
29 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildScanCommandArguments()

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

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

31 : string
32 {
33 return ' -i ' . IL_ICAP_HOST . ' -p ' . IL_ICAP_PORT . ' -v -s ' . IL_ICAP_AV_COMMAND . ' -f ' . $file;
34 }

Referenced by scanFile().

+ Here is the caller graph for this function:

◆ scanFile()

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

Reimplemented from ilVirusScanner.

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

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

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

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