19 declare(strict_types=1);
25 public function __construct(
string $scan_command,
string $clean_command)
28 $this->type =
'clamav';
29 $this->scanZipFiles =
true;
43 $functions = [
'proc_open',
'proc_close'];
45 foreach ($functions as $func) {
46 if (function_exists($func)) {
70 if (!is_resource($process)) {
74 fwrite($pipes[0], $buffer);
77 $detectionReport = stream_get_contents($pipes[1]);
80 $errorReport = stream_get_contents($pipes[2]);
83 $return = proc_close($process);
90 return $this->scanCommand .
' ' . self::ADD_SCAN_PARAMS .
' ' . $file;
97 return ' ' . self::ADD_SCAN_PARAMS .
' ' . $file;
103 return preg_match(
'/FOUND/', $detectionReport);
106 public function scanFile(
string $file_path,
string $org_name =
''): string
108 $this->scanFilePath = $file_path;
109 $this->scanFileOrigName = $org_name;
111 $currentPermission = fileperms($file_path);
112 $perm = $currentPermission | 0640;
113 chmod($file_path, $perm);
115 $a_filepath = realpath($file_path);
116 if (file_exists($file_path)) {
121 $this->scanResult = implode(
"\n",
$out);
123 if ($perm != $currentPermission) {
124 chmod($a_filepath, $currentPermission);
128 $this->scanFileIsInfected =
true;
132 $this->scanFileIsInfected =
false;
137 $return_error =
'ERROR (Virus Scanner failed): ' 139 .
'; Path=' . $a_filepath;
140 $this->log->write($return_error);
141 return $return_error;
hasDetections(string $detectionReport)
scanBuffer(string $buffer)
static escapeShellArg(string $a_arg)
scanFileFromBuffer(string $buffer)
processBufferScan(string $buffer)
static execQuoted(string $cmd, ?string $args=null)
scanFile(string $file_path, string $org_name='')
static escapeShellCmd(string $a_arg)
buildScanCommandArguments($file='-')
buildScanCommand(string $file='-')
__construct(Container $dic, ilPlugin $plugin)
__construct(string $scan_command, string $clean_command)