mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-50887 antivirus_clamav: Implement file scanning functionality.
This also removes runclamonupload config setting. It is implied that files will be scanned if plugin is enabled, no need to have a separate setting. In addition to that, some language strings are updated. It is 'ClamAV', not 'clam AV' (see http://www.clamav.net/index.html).
This commit is contained in:
parent
7d19e0e33d
commit
1a1d249a70
@ -26,11 +26,9 @@
|
||||
$string['configclamactlikevirus'] = 'Treat files like viruses';
|
||||
$string['configclamdonothing'] = 'Treat files as OK';
|
||||
$string['configclamfailureonupload'] = 'If you have configured clam to scan uploaded files, but it is configured incorrectly or fails to run for some unknown reason, how should it behave? If you choose \'Treat files like viruses\', they\'ll be moved into the quarantine area, or deleted. If you choose \'Treat files as OK\', the files will be moved to the destination directory like normal. Either way, admins will be alerted that clam has failed. If you choose \'Treat files like viruses\' and for some reason clam fails to run (usually because you have entered an invalid pathtoclam), ALL files that are uploaded will be moved to the given quarantine area, or deleted. Be careful with this setting.';
|
||||
$string['configpathtoclam'] = 'Path to clam AV. Probably something like /usr/bin/clamscan or /usr/bin/clamdscan. You need this in order for clam AV to run.';
|
||||
$string['configquarantinedir'] = 'If you want clam AV to move infected files to a quarantine directory, enter it here. It must be writable by the webserver. If you leave this blank, or if you enter a directory that doesn\'t exist or isn\'t writable, infected files will be deleted. Do not include a trailing slash.';
|
||||
$string['configrunclamavonupload'] = 'When enabled, clam AV will be used to scan all uploaded files.';
|
||||
$string['clamfailureonupload'] = 'On clam AV failure';
|
||||
$string['pathtoclam'] = 'clam AV path';
|
||||
$string['configpathtoclam'] = 'Path to ClamAV. Probably something like /usr/bin/clamscan or /usr/bin/clamdscan. You need this in order for ClamAV to run.';
|
||||
$string['configquarantinedir'] = 'If you want ClamAV to move infected files to a quarantine directory, enter it here. It must be writable by the webserver. If you leave this blank, or if you enter a directory that doesn\'t exist or isn\'t writable, infected files will be deleted. Do not include a trailing slash.';
|
||||
$string['clamfailureonupload'] = 'On ClamAV failure';
|
||||
$string['pathtoclam'] = 'ClamAV path';
|
||||
$string['pluginname'] = 'ClamAV antivirus';
|
||||
$string['quarantinedir'] = 'Quarantine directory';
|
||||
$string['runclamavonupload'] = 'Use clam AV on uploaded files';
|
||||
|
@ -31,4 +31,26 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class antivirus_clamav extends antivirus {
|
||||
/**
|
||||
* Are the necessary antivirus settings configured?
|
||||
*
|
||||
* @return bool True if all necessary config settings been entered
|
||||
*/
|
||||
public function is_configured() {
|
||||
return !empty($this->config->pathtoclam);
|
||||
}
|
||||
/**
|
||||
* Scan file, throws exception in case of infected file.
|
||||
*
|
||||
* Please note that the scanning engine must be able to access the file,
|
||||
* permissions of the file are not modified here!
|
||||
*
|
||||
* @param string $file Full path to the file.
|
||||
* @param bool $deleteinfected whether infected file needs to be deleted.
|
||||
* @throws moodle_exception If file is infected.
|
||||
* @return void
|
||||
*/
|
||||
public function scan_file($file, $deleteinfected) {
|
||||
// Here goes the scanning code.
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,6 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
$settings->add(new admin_setting_configcheckbox('antivirus_clamav/runclamonupload',
|
||||
new lang_string('runclamavonupload', 'antivirus_clamav'), new lang_string('configrunclamavonupload', 'antivirus_clamav'), 0));
|
||||
$settings->add(new admin_setting_configexecutable('antivirus_clamav/pathtoclam',
|
||||
new lang_string('pathtoclam', 'antivirus_clamav'), new lang_string('configpathtoclam', 'antivirus_clamav'), ''));
|
||||
$settings->add(new admin_setting_configdirectory('antivirus_clamav/quarantinedir',
|
||||
|
Loading…
x
Reference in New Issue
Block a user