Stud.IP  5.4
Virusscanner Class Reference

Static Public Member Functions

static scan (string $path)
 

Data Fields

const SCANRESULT_UNCHECKED = -1
 
const SCANRESULT_CLEAN = 0
 
const SCANRESULT_INFECTED = 1
 

Protected Member Functions

 __construct ()
 
 connect ()
 
 readFile (string $path)
 
 sendContent ($handle, string $content)
 
 finalize ($handle)
 

Static Protected Attributes

static $instance
 

Detailed Description

Abstraction for checking files with an external virus scanner. Supports connections via TCP or socket and is focused on using ClamAV at the moment. Derived from https://github.com/nextcloud/files_antivirus

Author
Thomas Hackl hackl.nosp@m.@dat.nosp@m.a-que.nosp@m.st.d.nosp@m.e
Sebastian Biller s.bil.nosp@m.ler@.nosp@m.tu-br.nosp@m.auns.nosp@m.chwei.nosp@m.g.de GPL 2 or later
Since
5.3

Constructor & Destructor Documentation

◆ __construct()

__construct ( )
finalprotected

Finalized constructor so that the instantition in scan() will never fail.

Member Function Documentation

◆ connect()

connect ( )
protected

Establishes a connection to virus scanner via socket or TCP, depending on Stud.IP configuration.

Returns
resource|null

◆ finalize()

finalize (   $handle)
protected

All file chunks have been sent: we now signal the end of the stream by sending a "0". Afterwarda, the response we got from virus scanner is parsed and (in case something was found) the name of the virus is returned.

Parameters
resource$handle
Returns
array

◆ readFile()

readFile ( string  $path)
protected

Get contents of the file to scan.

Parameters
string$path
Returns
resource

◆ scan()

static scan ( string  $path)
static

Scans the given path for viruses.

Parameters
string$path
Returns
array Contains the found virus signature, error message or is an empty array on successful scan

◆ sendContent()

sendContent (   $handle,
string  $content 
)
protected

Send some content to the virus scanner.

Parameters
resource$handle
string$content
Returns
int

Field Documentation

◆ $instance

$instance
staticprotected

◆ SCANRESULT_CLEAN

const SCANRESULT_CLEAN = 0

◆ SCANRESULT_INFECTED

const SCANRESULT_INFECTED = 1

◆ SCANRESULT_UNCHECKED

const SCANRESULT_UNCHECKED = -1

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