19 declare(strict_types=1);
23 public function __construct(
string $scan_command,
string $clean_command)
26 $this->type =
'sophos';
27 $this->scanZipFiles =
true;
30 public function scanFile(
string $file_path,
string $org_name =
''): string
32 $this->scanFilePath = $file_path;
33 $this->scanFileOrigName = $org_name;
37 $a_filepath = realpath($file_path);
40 $cmd .=
' ' . $args .
' 2>&1';
41 exec($cmd,
$out, $ret);
42 $this->scanResult = implode(
"\n",
$out);
45 if ((
int) $ret === 0) {
46 if (preg_match(
'/FILE INFECTED/', $this->scanResult)) {
47 $this->scanFileIsInfected =
true;
52 $this->scanFileIsInfected =
false;
58 'ERROR (Virus Scanner failed): ' 67 $cmd = $this->cleanCommand .
' -ss -archive ' . $file_path .
' 2>&1';
68 exec($cmd,
$out, $ret);
69 $this->scanResult = implode(
"\n",
$out) .
' [' . $ret .
']';
76 if ((
int) $ret === 0) {
77 $this->cleanFileIsCleaned =
false;
79 } elseif ((
int) $ret === 3) {
80 $this->scanFileIsInfected =
true;
85 $this->error->raiseError(
86 $this->
lng->txt(
'virus_scan_error') .
' ' 87 . $this->
lng->txt(
'virus_scan_message') .
' ' 93 public function cleanFile(
string $file_path,
string $org_name =
''): string
95 $this->cleanFilePath = $file_path;
96 $this->cleanFileOrigName = $org_name;
105 $cmd = $this->cleanCommand .
' -di -nc -ss -eec -archive ' . $file_path .
' 2>&1';
106 exec($cmd,
$out, $ret);
107 $this->cleanResult = implode(
"\n",
$out) .
' [' . $ret .
']';
123 if ((
int) $ret === 20) {
124 $this->cleanFileIsCleaned =
true;
128 $this->cleanFileIsCleaned =
false;
__construct(string $scan_command, string $clean_command)
static escapeShellArg(string $a_arg)
static escapeShellCmd(string $a_arg)
__construct(Container $dic, ilPlugin $plugin)
cleanFile(string $file_path, string $org_name='')
scanFile(string $file_path, string $org_name='')