ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilVirusScannerSetupConfig.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2019 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
7
9{
10 const VIRUS_SCANNER_NONE = "none";
11 const VIRUS_SCANNER_SOPHOS = "sophos";
12 const VIRUS_SCANNER_ANTIVIR = "antivir";
13 const VIRUS_SCANNER_CLAMAV = "clamav";
14 const VIRUS_SCANNER_ICAP = "icap";
15
19 protected $virus_scanner;
20
24 protected $path_to_scan;
25
29 protected $path_to_clean;
30
34 protected $icap_host;
35
39 protected $icap_port;
40
45
50
51 public function __construct(
52 string $virus_scanner,
53 ?string $path_to_scan,
54 ?string $path_to_clean,
55 ?string $icap_host,
56 ?string $icap_port,
57 ?string $icap_service_name,
58 ?string $icap_client_path
59 ) {
60 $scanners = [
66 ];
67 if (!in_array($virus_scanner, $scanners)) {
68 throw new \InvalidArgumentException(
69 "Unknown virus scanner: '$virus_scanner'"
70 );
71 }
72 if($virus_scanner === self::VIRUS_SCANNER_ICAP) {
73 $this->icap_host = $this->toLinuxConvention($icap_host);
74 $this->icap_port = $this->toLinuxConvention($icap_port);
75 $this->icap_service_name = $this->toLinuxConvention($icap_service_name);
76 $this->icap_client_path = $this->toLinuxConvention($icap_client_path);
77 } elseif ($virus_scanner !== self::VIRUS_SCANNER_NONE && (!$path_to_scan || !$path_to_clean)) {
78 throw new \InvalidArgumentException(
79 "Missing path to scan and/or clean commands for virus scanner."
80 );
81 }
82 $this->virus_scanner = $virus_scanner;
83 $this->path_to_scan = $this->toLinuxConvention($path_to_scan);
84 $this->path_to_clean = $this->toLinuxConvention($path_to_clean);
85 }
86
87 protected function toLinuxConvention(?string $p) : ?string
88 {
89 if (!$p) {
90 return null;
91 }
92 return preg_replace("/\\\\/", "/", $p);
93 }
94
95 public function getVirusScanner() : string
96 {
98 }
99
100 public function getPathToScan() : ?string
101 {
102 return $this->path_to_scan;
103 }
104
105 public function getPathToClean() : ?string
106 {
108 }
109
110 public function getIcapHost() : ?string
111 {
112 return $this->icap_host;
113 }
114
115 public function getIcapPort() : ?string
116 {
117 return $this->icap_port;
118 }
119
120 public function getIcapServiceName() : ?string
121 {
123 }
124
125 public function getIcapClientPath() : ?string
126 {
128 }
129}
An exception for terminatinating execution or to throw for unit testing.
A password is used as part of credentials for authentication.
Definition: Password.php:14
__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:11
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...