ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilVirusScannerSetupConfig.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
22
24{
25 public const VIRUS_SCANNER_NONE = 'none';
26 private const VIRUS_SCANNER_SOPHOS = 'sophos';
27 private const VIRUS_SCANNER_ANTIVIR = 'antivir';
28 private const VIRUS_SCANNER_CLAMAV = 'clamav';
29 public const VIRUS_SCANNER_ICAP = 'icap';
30
31 protected string $virus_scanner;
32
33 protected ?string $path_to_scan = null;
34
35 protected ?string $path_to_clean = null;
36
37 protected ?string $icap_host = null;
38
39 protected ?string $icap_port = null;
40
41 protected ?string $icap_service_name = null;
42
43 protected ?string $icap_client_path = null;
44
45 public function __construct(
46 string $virus_scanner,
47 ?string $path_to_scan,
48 ?string $path_to_clean,
49 ?string $icap_host,
50 ?string $icap_port,
51 ?string $icap_service_name,
52 ?string $icap_client_path
53 ) {
54 $scanners = [
60 ];
61 if (!in_array($virus_scanner, $scanners)) {
62 throw new InvalidArgumentException(
63 "Unknown virus scanner: '$virus_scanner'"
64 );
65 }
66 if ($virus_scanner === self::VIRUS_SCANNER_ICAP) {
67 $this->icap_host = $this->toLinuxConvention($icap_host);
68 $this->icap_port = $this->toLinuxConvention($icap_port);
69 $this->icap_service_name = $this->toLinuxConvention($icap_service_name);
70 $this->icap_client_path = $this->toLinuxConvention($icap_client_path);
71 } elseif ($virus_scanner !== self::VIRUS_SCANNER_NONE && (!$path_to_scan || !$path_to_clean)) {
72 throw new InvalidArgumentException(
73 'Missing path to scan and/or clean commands for virus scanner.'
74 );
75 }
76 $this->virus_scanner = $virus_scanner;
77 $this->path_to_scan = $this->toLinuxConvention($path_to_scan);
78 $this->path_to_clean = $this->toLinuxConvention($path_to_clean);
79 }
80
81 protected function toLinuxConvention(?string $p): ?string
82 {
83 if (!$p) {
84 return null;
85 }
86
87 return preg_replace("/\\\\/", '/', $p);
88 }
89
90 public function getVirusScanner(): string
91 {
93 }
94
95 public function getPathToScan(): ?string
96 {
98 }
99
100 public function getPathToClean(): ?string
101 {
103 }
104
105 public function getIcapHost(): ?string
106 {
107 return $this->icap_host;
108 }
109
110 public function getIcapPort(): ?string
111 {
112 return $this->icap_port;
113 }
114
115 public function getIcapServiceName(): ?string
116 {
118 }
119
120 public function getIcapClientPath(): ?string
121 {
123 }
124}
__construct(string $virus_scanner, ?string $path_to_scan, ?string $path_to_clean, ?string $icap_host, ?string $icap_port, ?string $icap_service_name, ?string $icap_client_path)
A configuration for the setup.
Definition: Config.php:27
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...