ILIAS  release_8 Revision v8.24
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 private 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 return preg_replace("/\\\\/", "/", $p);
87 }
88
89 public function getVirusScanner(): string
90 {
92 }
93
94 public function getPathToScan(): ?string
95 {
97 }
98
99 public function getPathToClean(): ?string
100 {
102 }
103
104 public function getIcapHost(): ?string
105 {
106 return $this->icap_host;
107 }
108
109 public function getIcapPort(): ?string
110 {
111 return $this->icap_port;
112 }
113
114 public function getIcapServiceName(): ?string
115 {
117 }
118
119 public function getIcapClientPath(): ?string
120 {
122 }
123}
__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...