Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
antivirus_clamav\scanner Class Reference

Class implementing ClamAV antivirus. More...

Inheritance diagram for antivirus_clamav\scanner:
core\antivirus\scanner

Public Member Functions

 get_config ($property)
 Config get method. More...
 
 get_scanning_notice ()
 Get scanning notice. More...
 
 is_configured ()
 Are the necessary antivirus settings configured? More...
 
 message_admins ($notice)
 Email admins about antivirus scan outcomes. More...
 
 scan_data ($data)
 Scan data. More...
 
 scan_data_execute_socket ($data, $type)
 Scan data socket. More...
 
 scan_data_execute_unixsocket ($data)
 Scan data using Unix domain socket. More...
 
 scan_file ($file, $filename)
 Scan file. More...
 
 scan_file_execute_commandline ($file)
 Scan file using command line utility. More...
 
 scan_file_execute_socket ($file, $type)
 Scan file using sockets. More...
 
 scan_file_execute_unixsocket ($file)
 Scan file using Unix domain socket. More...
 

Public Attributes

const SCAN_RESULT_ERROR = 2
 Scanning result indicating the error.
 
const SCAN_RESULT_FOUND = 1
 Scanning result indicating that virus is found.
 
const SCAN_RESULT_OK = 0
 Scanning result indicating no virus found.
 

Protected Member Functions

 set_scanning_notice ($notice)
 Set scanning notice. More...
 

Protected Attributes

stdClass $config
 the config for antivirus
 
string $scanningnotice = ''
 scanning notice
 

Detailed Description

Class implementing ClamAV antivirus.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ get_config()

core\antivirus\scanner::get_config (   $property)
inherited

Config get method.

Parameters
string$propertyconfig property to get.
Return values
mixed
Exceptions
coding_exception

◆ get_scanning_notice()

core\antivirus\scanner::get_scanning_notice ( )
inherited

Get scanning notice.

Return values
string

◆ is_configured()

antivirus_clamav\scanner::is_configured ( )

Are the necessary antivirus settings configured?

Return values
boolTrue if all necessary config settings been entered

Reimplemented from core\antivirus\scanner.

◆ message_admins()

core\antivirus\scanner::message_admins (   $notice)
inherited

Email admins about antivirus scan outcomes.

Parameters
string$noticeThe body of the email to be sent.
Return values
void

◆ scan_data()

antivirus_clamav\scanner::scan_data (   $data)

Scan data.

Parameters
string$dataThe variable containing the data to scan.
Return values
intScanning result constant.

Reimplemented from core\antivirus\scanner.

◆ scan_data_execute_socket()

antivirus_clamav\scanner::scan_data_execute_socket (   $data,
  $type 
)

Scan data socket.

We are running INSTREAM command and passing data stream in chunks. The format of the chunk is: <length><data> where <length> is the size of the following data in bytes expressed as a 4 byte unsigned integer in network byte order and <data> is the actual chunk. Streaming is terminated by sending a zero-length chunk. Do not exceed StreamMaxLength as defined in clamd.conf, otherwise clamd will reply with INSTREAM size limit exceeded and close the connection.

Parameters
string$dataThe variable containing the data to scan.
string$typeEither 'tcpsocket' or 'unixsocket'
Return values
intScanning result constant.

◆ scan_data_execute_unixsocket()

antivirus_clamav\scanner::scan_data_execute_unixsocket (   $data)

Scan data using Unix domain socket.

Deprecated:
since Moodle 3.9 MDL-64075 - please do not use this function any more.
See also
antivirus_clamav::scanner::scan_data_execute_socket()
Parameters
string$dataThe variable containing the data to scan.
Return values
intScanning result constant.

◆ scan_file()

antivirus_clamav\scanner::scan_file (   $file,
  $filename 
)

Scan file.

This method is normally called from antivirus manager (core::antivirus::manager::scan_file).

Parameters
string$fileFull path to the file.
string$filenameName of the file (could be different from physical file if temp file is used).
Return values
intScanning result constant.

Reimplemented from core\antivirus\scanner.

◆ scan_file_execute_commandline()

antivirus_clamav\scanner::scan_file_execute_commandline (   $file)

Scan file using command line utility.

Parameters
string$fileFull path to the file.
Return values
intScanning result constant.

◆ scan_file_execute_socket()

antivirus_clamav\scanner::scan_file_execute_socket (   $file,
  $type 
)

Scan file using sockets.

Parameters
string$fileFull path to the file.
string$typeEither 'tcpsocket' or 'unixsocket'
Return values
intScanning result constant.

◆ scan_file_execute_unixsocket()

antivirus_clamav\scanner::scan_file_execute_unixsocket (   $file)

Scan file using Unix domain socket.

Deprecated:
since Moodle 3.9 MDL-64075 - please do not use this function any more.
See also
antivirus_clamav::scanner::scan_file_execute_socket()
Parameters
string$fileFull path to the file.
Return values
intScanning result constant.

◆ set_scanning_notice()

core\antivirus\scanner::set_scanning_notice (   $notice)
protectedinherited

Set scanning notice.

Parameters
string$noticenotice to set.
Return values
void

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