Issues (3882)

Security Analysis    39 potential vulnerabilities

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting (9)
Response Splitting can be used to send arbitrary responses.
  File Manipulation (2)
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure (7)
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection (13)
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting (8)
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

app/Config.php (2 issues)

1
<?php
2
/**
3
 * Config main class.
4
 *
5
 * @package App
6
 *
7
 * @copyright YetiForce S.A.
8
 * @license   YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com)
9
 * @author    Mariusz Krzaczkowski <[email protected]>
10
 * @author    RadosÅ‚aw Skrzypczak <[email protected]>
11
 */
12
13
namespace App;
14
15
/**
16
 * Config main class.
17
 */
18
class Config
19
{
20
	/**
21
	 * Js environment variables.
22
	 *
23
	 * @var array
24
	 */
25
	private static $jsEnv = [];
26
27
	/**
28
	 * Get all js configuration in json.
29
	 *
30
	 * @throws \App\Exceptions\AppException
31
	 *
32 1
	 * @return string
33
	 */
34 1
	public static function getJsEnv()
35
	{
36
		return Json::encode(self::$jsEnv);
37
	}
38
39
	/**
40
	 * Get js configuration by key.
41
	 *
42
	 * @param string $key
43 1
	 *
44
	 * @return mixed
45 1
	 */
46 1
	public static function getJsEnvByKey(string $key)
47
	{
48
		return self::$jsEnv[$key] ?? null;
49
	}
50
51
	/**
52
	 * Set js environment variables.
53
	 *
54
	 * @param string $key
55
	 * @param mixed  $value
56
	 */
57
	public static function setJsEnv($key, $value)
58 43
	{
59
		self::$jsEnv[$key] = $value;
60 43
	}
61
62
	/**
63 43
	 * Gets main configuration.
64 43
	 *
65
	 * @param string|null $arg
66
	 * @param mixed       $default
67
	 *
68
	 * @throws \ReflectionException
69
	 *
70
	 * @return mixed
71
	 */
72
	public static function main(?string $arg = null, $default = null)
73
	{
74
		if ($arg && isset($GLOBALS[$arg])) {
75
			return $GLOBALS[$arg];
76
		}
77
		$class = '\\Config\\Main';
78 5801
		return self::get($class, $arg, $default);
79
	}
80 5801
81 5801
	/**
82
	 * Gets module configuration.
83
	 *
84
	 * @param string      $moduleName
85
	 * @param string|null $arg
86
	 * @param mixed       $default
87
	 *
88
	 * @throws \ReflectionException
89
	 *
90
	 * @return mixed
91
	 */
92
	public static function module(string $moduleName, ?string $arg = null, $default = null)
93
	{
94
		$class = "\\Config\\Modules\\$moduleName";
95 31
		return self::get($class, $arg, $default);
96
	}
97 31
98 31
	/**
99
	 * Gets component configuration.
100
	 *
101
	 * @param string      $component
102
	 * @param string|null $arg
103
	 * @param mixed       $default
104
	 *
105
	 * @throws \ReflectionException
106
	 *
107
	 * @return mixed
108
	 */
109
	public static function component(string $component, ?string $arg = null, $default = null)
110
	{
111 5792
		$class = "\\Config\\Components\\$component";
112
		return self::get($class, $arg, $default);
113 5792
	}
114 5792
115
	/**
116
	 * Gets performance configuration.
117
	 *
118
	 * @param string|null $arg
119
	 * @param mixed       $default
120
	 *
121
	 * @throws \ReflectionException
122
	 *
123
	 * @return mixed
124
	 */
125
	public static function performance(?string $arg = null, $default = null)
126
	{
127
		$class = '\\Config\\Performance';
128
		return self::get($class, $arg, $default);
129
	}
130
131
	/**
132
	 * Gets api configuration.
133
	 *
134
	 * @param string|null $arg
135
	 * @param mixed       $default
136
	 *
137
	 * @throws \ReflectionException
138
	 *
139
	 * @return mixed
140
	 */
141
	public static function api(?string $arg = null, $default = null)
142
	{
143 10
		$class = '\\Config\\Api';
144
		return self::get($class, $arg, $default);
145 10
	}
146 10
147
	/**
148
	 * Gets debug configuration.
149
	 *
150
	 * @param string|null $arg
151
	 * @param mixed       $default
152
	 *
153
	 * @throws \ReflectionException
154
	 *
155
	 * @return mixed
156
	 */
157
	public static function debug(?string $arg = null, $default = null)
158
	{
159 4
		$class = '\\Config\\Debug';
160
		return self::get($class, $arg, $default);
161 4
	}
162 4
163
	/**
164
	 * Gets developer configuration.
165
	 *
166
	 * @param string|null $arg
167
	 * @param mixed       $default
168
	 *
169
	 * @throws \ReflectionException
170
	 *
171
	 * @return mixed
172
	 */
173
	public static function developer(?string $arg = null, $default = null)
174
	{
175 29
		$class = '\\Config\\Developer';
176
		return self::get($class, $arg, $default);
177 29
	}
178 29
179
	/**
180
	 * Gets layout configuration.
181
	 *
182
	 * @param string|null $arg
183
	 * @param mixed       $default
184
	 *
185
	 * @throws \ReflectionException
186
	 *
187
	 * @return mixed
188
	 */
189
	public static function layout(?string $arg = null, $default = null)
190
	{
191
		$class = '\\Config\\Layout';
192
		return self::get($class, $arg, $default);
193
	}
194
195
	/**
196
	 * Gets security configuration.
197
	 *
198
	 * @param string|null $arg
199
	 * @param mixed       $default
200
	 *
201
	 * @throws \ReflectionException
202
	 *
203
	 * @return mixed
204
	 */
205
	public static function security(?string $arg = null, $default = null)
206
	{
207
		$class = '\\Config\\Security';
208
		return self::get($class, $arg, $default);
209
	}
210
211
	/**
212
	 * Gets search configuration.
213
	 *
214
	 * @param string|null $arg
215
	 * @param mixed       $default
216
	 *
217
	 * @throws \ReflectionException
218
	 *
219
	 * @return mixed
220
	 */
221
	public static function search(?string $arg = null, $default = null)
222
	{
223
		$class = '\\Config\\Search';
224
		return self::get($class, $arg, $default);
225
	}
226
227
	/**
228
	 * Gets sounds configuration.
229
	 *
230
	 * @param string|null $arg
231
	 * @param mixed       $default
232
	 *
233
	 * @throws \ReflectionException
234
	 *
235
	 * @return mixed
236
	 */
237
	public static function sounds(?string $arg = null, $default = null)
238
	{
239 9
		$class = '\\Config\\Sounds';
240
		return self::get($class, $arg, $default);
241 9
	}
242 9
243
	/**
244
	 * Gets relation configuration.
245
	 *
246
	 * @param string|null $arg
247
	 * @param mixed       $default
248
	 *
249
	 * @throws \ReflectionException
250
	 *
251
	 * @return mixed
252
	 */
253
	public static function relation(?string $arg = null, $default = null)
254
	{
255 4
		$class = '\\Config\\Relation';
256
		return self::get($class, $arg, $default);
257 4
	}
258 4
259
	/**
260
	 * Gets security keys configuration.
261
	 *
262
	 * @param string|null $arg
263
	 * @param mixed       $default
264
	 *
265
	 * @throws \ReflectionException
266
	 *
267
	 * @return mixed
268
	 */
269
	public static function securityKeys(?string $arg = null, $default = null)
270
	{
271
		$class = '\\Config\\SecurityKeys';
272 5878
		return self::get($class, $arg, $default);
273
	}
274 5878
275 5878
	/**
276 5878
	 * Gets database configuration.
277 2
	 *
278 2
	 * @param string|null $arg
279 2
	 * @param mixed       $default
280 1
	 *
281
	 * @throws \ReflectionException
282 5877
	 *
283 5877
	 * @return mixed
284 7
	 */
285 4
	public static function db(?string $arg = null, $default = null)
286
	{
287
		$class = '\\Config\\Db';
288 5878
		return self::get($class, $arg, $default);
289
	}
290
291
	/**
292
	 * Gets configuration for class.
293
	 *
294
	 * @param string      $class
295
	 * @param string|null $arg
296 9
	 * @param mixed       $default
297
	 *
298 9
	 * @throws \ReflectionException
299
	 *
300
	 * @return mixed
301 9
	 */
302
	public static function get(string $class, ?string $arg = null, $default = null)
303 9
	{
304 9
		$value = $default;
305 9
		if (\class_exists($class)) {
306
			if (null === $arg) {
307 9
				$object = (new \ReflectionClass($class));
308
				$value = $object->getStaticProperties();
309
				foreach ($object->getMethods() as $method) {
310
					$value[$method->getName()] = \call_user_func("{$class}::{$method->getName()}");
311
				}
312
			} elseif (isset($class::${$arg})) {
313
				$value = $class::${$arg};
314
			} elseif (\method_exists($class, $arg)) {
315
				$value = \call_user_func("{$class}::{$arg}");
316
			}
317
		}
318
		return $value;
319
	}
320
321
	/**
322
	 * Set config value.
323
	 *
324
	 * @return bool
325
	 */
326
	public static function set(): bool
327
	{
328
		if (4 === \func_num_args()) {
329
			[$component, $type, $key, $value] = \func_get_args();
330
			$component = ucfirst($component) . 's\\';
331
		} else {
332
			[$type, $key, $value] = \func_get_args();
333
			$type = ucfirst($type);
334
		}
335
		$class = '\Config\\' . ($component ?? '') . $type;
336
		if ($result = (class_exists($class) && isset($class::${$key}))) {
337
			$class::${$key} = $value;
338
		}
339
		return $result;
340
	}
341
342
	/**
343
	 * Get the maximum size of an uploaded file to the server taking into account CRM configuration and server settings.
344
	 *
345
	 * @param bool $checkMain
346
	 * @param bool $returnInMb
347
	 *
348
	 * @return int
349
	 */
350
	public static function getMaxUploadSize(bool $checkMain = true, bool $returnInMb = false): int
351
	{
352
		$size = \vtlib\Functions::parseBytes(ini_get('upload_max_filesize'));
353
		$maxPostSize = \vtlib\Functions::parseBytes(ini_get('post_max_size'));
354
		if ($maxPostSize < $size) {
355
			$size = $maxPostSize;
356
		}
357
		if ($checkMain && \Config\Main::$upload_maxsize < $size) {
0 ignored issues
show
The type Config\Main was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
358
			$size = (int) \Config\Main::$upload_maxsize;
359
		}
360
		if ($returnInMb) {
361
			$size = floor($size / 1048576);
362
		}
363
		return $size;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $size could return the type double which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
364
	}
365
}
366