ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilVirusScannerICapRemoteAvClient Class Reference
+ Inheritance diagram for ilVirusScannerICapRemoteAvClient:
+ Collaboration diagram for ilVirusScannerICapRemoteAvClient:

Public Member Functions

 __construct ($a_scancommand, $a_cleancommand)
 ilVirusScannerICapAvClient constructor. More...
 
 scanFile ($a_filepath, $a_origname="")
 
- Public Member Functions inherited from ilVirusScannerICapRemote
 __construct ($a_scancommand, $a_cleancommand)
 ilVirusScannerICap constructor. More...
 
 options ($service)
 
 getRequest ($method, $service, $body=[], $headers=[])
 
 send ($request)
 
 getLastSocketError ()
 Get last error code from socket object. More...
 
 respMod ($service, $body=[], $headers=[])
 
 reqMod ($service, $body=[], $headers=[])
 
- 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...
 

Data Fields

const HEADER = 'headers'
 
const HEADER_VIOLATION_FOUND = 'X-Violations-Found'
 
const HEADER_INFECTION_FOUND = 'X-Infection-Found'
 
- Data Fields inherited from ilVirusScannerICapRemote
 $userAgent = 'PHP-CLIENT/0.1.0'
 
- Data Fields inherited from ilVirusScanner
 $type
 
 $scanZipFiles
 
 $scanCommand
 
 $cleanCommand
 
 $scanFilePath
 
 $scanFileOrigName
 
 $cleanFilePath
 
 $cleanFileOrigName
 
 $scanFileIsInfected
 
 $cleanFileIsCleaned
 
 $scanResult
 
 $cleanResult
 
 $ilias
 
 $lng
 
 $log
 

Protected Member Functions

 analyseHeader ($header)
 
- Protected Member Functions inherited from ilVirusScanner
 scanFileFromBuffer ($buffer)
 
 createBufferFile ($buffer)
 
 removeBufferFile ($bufferFile)
 

Detailed Description

Definition at line 5 of file class.ilVirusScannerICapRemoteAvClient.php.

Constructor & Destructor Documentation

◆ __construct()

ilVirusScannerICapRemoteAvClient::__construct (   $a_scancommand,
  $a_cleancommand 
)

ilVirusScannerICapAvClient constructor.

Parameters
$a_scancommand
$a_cleancommand

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

References ILIAS\GlobalScreen\Provider\__construct(), and ilVirusScannerICapRemote\options().

17  {
18  parent::__construct($a_scancommand, $a_cleancommand);
19  $this->options(IL_ICAP_AV_COMMAND);
20  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ analyseHeader()

ilVirusScannerICapRemoteAvClient::analyseHeader (   $header)
protected
Parameters
$header
Returns
bool

Definition at line 60 of file class.ilVirusScannerICapRemoteAvClient.php.

Referenced by scanFile().

61  {
62  $virus_found = false;
63  if (array_key_exists(self::HEADER, $header)) {
64  $header = $header[self::HEADER];
65  if (array_key_exists(self::HEADER_VIOLATION_FOUND, $header)) {
66  if ($header[self::HEADER_VIOLATION_FOUND] > 0) {
67  $virus_found = true;
68  }
69  }
70  if (array_key_exists(self::HEADER_INFECTION_FOUND, $header)) {
71  if (strlen($header[self::HEADER_INFECTION_FOUND]) > 0) {
72  $infection_split = preg_split('/;/', $header[self::HEADER_INFECTION_FOUND]);
73  foreach ($infection_split as $infection) {
74  $parts = preg_split('/=/', $infection);
75  if ($parts !== false &&
76  is_array($parts) &&
77  count($parts) > 0 &&
78  strlen($parts[0]) > 0) {
79  $this->log->warning(trim($parts[0]) . ': ' . trim($parts[1]));
80  }
81  }
82  $virus_found = true;
83  }
84  }
85  }
86  return $virus_found;
87  }
+ Here is the caller graph for this function:

◆ scanFile()

ilVirusScannerICapRemoteAvClient::scanFile (   $a_filepath,
  $a_origname = "" 
)
Parameters
$a_filepath
string$a_origname
Returns
bool|string

Definition at line 27 of file class.ilVirusScannerICapRemoteAvClient.php.

References $results, and analyseHeader().

28  {
29  $return_string = '';
30  if (file_exists($a_filepath)) {
31  if (is_readable($a_filepath)) {
32  $a_filepath = realpath($a_filepath);
33  $results = ($this->reqmod(
34  'avscan',
35  [
36  'req-hdr' => "POST /test HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n",
37  'req-body' => file_get_contents($a_filepath) //Todo: find a better way
38  ]
39  ));
40  if ($this->analyseHeader($results)) {
41  $return_string = sprintf('Virus found in file "%s"!', $a_filepath);
42  $this->log->warning($return_string);
43  }
44  } else {
45  $return_string = sprintf('File "%s" not readable.', $a_filepath);
46  $this->log->warning($return_string);
47  }
48  } else {
49  $return_string = sprintf('File "%s" not found.', $a_filepath);
50  $this->log->warning($return_string);
51  }
52  $this->log->info(sprintf('No virus found in file "%s".', $a_filepath));
53  return $return_string;
54  }
$results
+ Here is the call graph for this function:

Field Documentation

◆ HEADER

const ilVirusScannerICapRemoteAvClient::HEADER = 'headers'

Definition at line 7 of file class.ilVirusScannerICapRemoteAvClient.php.

◆ HEADER_INFECTION_FOUND

const ilVirusScannerICapRemoteAvClient::HEADER_INFECTION_FOUND = 'X-Infection-Found'

Definition at line 9 of file class.ilVirusScannerICapRemoteAvClient.php.

◆ HEADER_VIOLATION_FOUND

const ilVirusScannerICapRemoteAvClient::HEADER_VIOLATION_FOUND = 'X-Violations-Found'

Definition at line 8 of file class.ilVirusScannerICapRemoteAvClient.php.


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