ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilVirusScannerPreProcessor Class Reference
+ Inheritance diagram for ilVirusScannerPreProcessor:
+ Collaboration diagram for ilVirusScannerPreProcessor:

Public Member Functions

 __construct (ilVirusScanner $scanner)
 
 process (FileStream $stream, Metadata $metadata)
 This method gets invoked by the file upload service to process the file with the help of the processor. More...
 

Protected Attributes

ilVirusScanner $scanner
 

Detailed Description

Definition at line 26 of file class.ilVirusScannerPreProcessor.php.

Constructor & Destructor Documentation

◆ __construct()

ilVirusScannerPreProcessor::__construct ( ilVirusScanner  $scanner)

Definition at line 30 of file class.ilVirusScannerPreProcessor.php.

References $scanner.

31  {
32  $this->scanner = $scanner;
33  }

Member Function Documentation

◆ process()

ilVirusScannerPreProcessor::process ( FileStream  $stream,
Metadata  $metadata 
)

This method gets invoked by the file upload service to process the file with the help of the processor.

If the return value is REJECTED, no further invocations of processors are done for the rejected file.

If the processor fails or returns an unexpected value, the file gets automatically rejected because the file could be dangerous to ILIAS.

Parameters
FileStream$streamThe stream of the file.
Metadata$metadataThe meta data of the uploaded file.
Returns
ProcessingStatus The new status of the file.

Implements ILIAS\FileUpload\Processor\PreProcessor.

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

36  {
37  $uri = $stream->getMetadata()["uri"];
38  // chmod($uri, 0755); // we must find a way e.g. ClamAV can read the file
39  if ($this->scanner->scanFile($uri) !== "") {
40  return new ProcessingStatus(ProcessingStatus::DENIED, 'Virus detected.');
41  }
42 
43  return new ProcessingStatus(ProcessingStatus::OK, 'No Virus detected.');
44  }

Field Documentation

◆ $scanner

ilVirusScanner ilVirusScannerPreProcessor::$scanner
protected

Definition at line 28 of file class.ilVirusScannerPreProcessor.php.

Referenced by __construct().


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