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/Debuger.php (4 issues)

1
<?php
2
/**
3
 * Debugger basic file.
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
 */
11
12
namespace App;
13
14
use DebugBar\DataCollector;
15
16
/**
17
 * Debuger basic class.
18
 */
19
class Debuger
20
{
21
	/**
22
	 * @var \DebugBar\Debuger
0 ignored issues
show
The type DebugBar\Debuger 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...
23
	 */
24
	protected static $debugBar;
25
26
	/**
27
	 * Initiating debugging console.
28
	 *
29
	 * @return \App\DebugBar\Debuger
0 ignored issues
show
The type App\DebugBar\Debuger 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...
30
	 */
31
	public static function initConsole()
32 2
	{
33
		if (\App\Config::debug('DISPLAY_DEBUG_CONSOLE') && static::consoleIsActive()) {
34 2
			$debugbar = new Debug\DebugBar\DebugBar();
35 2
			$debugbar->addCollector(new DataCollector\PhpInfoCollector());
36 2
			$debugbar->addCollector(new DataCollector\ExceptionsCollector());
37 2
			$debugbar->addCollector(new DataCollector\RequestDataCollector());
38 2
			$debugbar->addCollector(new DataCollector\MemoryCollector());
39 2
			$debugbar->addCollector(new DataCollector\TimeDataCollector());
40 1
			if (\App\Config::debug('DISPLAY_LOGS_IN_CONSOLE')) {
41
				$debugbar->addCollector(new Debug\DebugBarLogs());
42 2
			}
43
			if (\App\Config::debug('DISPLAY_CONFIG_IN_CONSOLE')) {
44 2
				$debugbar->addCollector(new \DebugBar\DataCollector\ConfigCollector([
45
					'debug' => \App\Config::debug(),
46
					'developer' => \App\Config::developer(),
47
					'performance' => \App\Config::performance(),
48
					'api' => \App\Config::api(),
49
					'security' => \App\Config::security(),
50
					'search' => \App\Config::search(),
51
					'sounds' => \App\Config::sounds(),
52 1
					'relation' => \App\Config::relation(),
53
				]));
54 1
			}
55
			static::$debugBar = $debugbar;
0 ignored issues
show
Documentation Bug introduced by
It seems like $debugbar of type App\Debug\DebugBar\DebugBar is incompatible with the declared type DebugBar\Debuger of property $debugBar.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
56
		}
57
	}
58
59
	/**
60
	 * Get Debuger instance.
61
	 *
62 1
	 * @return \App\Debug\DebugBar\DebugBar
63
	 */
64 1
	public static function getDebugBar()
65
	{
66
		return static::$debugBar;
67
	}
68
69
	/**
70
	 * Checking is active debugging.
71
	 *
72 3
	 * @return bool
73
	 */
74 3
	public static function isDebugBar()
75
	{
76
		return isset(static::$debugBar);
77 1
	}
78
79 1
	public static function addLogs($message, $level, $traces)
80 1
	{
81
		if (isset(static::$debugBar['logs'])) {
82 1
			static::$debugBar['logs']->addMessage($message, $level, $traces);
83
		}
84
	}
85
86
	/**
87 1
	 * Initiating debugging.
88
	 */
89 1
	public static function init()
90 1
	{
91
		$targets = [];
92 1
		if (\App\Config::debug('LOG_TO_FILE')) {
93 1
			$levels = \App\Config::debug('LOG_LEVELS');
94 1
			$target = [
95
				'class' => 'App\Log\FileTarget',
96 1
			];
97
			if (false !== $levels) {
98 1
				$target['levels'] = $levels;
99 1
			}
100
			$targets['file'] = $target;
101 1
		}
102
		if (\App\Config::debug('LOG_TO_PROFILE')) {
103 1
			$levels = \App\Config::debug('LOG_LEVELS');
104 1
			$target = [
105
				'class' => 'App\Log\Profiling',
106 1
			];
107
			if (false !== $levels) {
108 1
				$target['levels'] = $levels;
109 1
			}
110
			$targets['profiling'] = $target;
111 1
		}
112
		\Yii::createObject([
113 1
			'class' => 'yii\log\Dispatcher',
114 1
			'traceLevel' => \App\Config::debug('LOG_TRACE_LEVEL'),
115 1
			'targets' => $targets,
116 1
		]);
117
	}
118 1
119
	/**
120
	 * Checking console is active.
121
	 *
122
	 * @return bool
123
	 */
124
	public static function consoleIsActive()
125 2
	{
126
		$ips = \Config\Debug::$DEBUG_CONSOLE_ALLOWED_IPS;
127 2
		if (false === $ips || (\is_string($ips) && RequestUtil::getRemoteIP(true) === $ips) || (\is_array($ips) && \in_array(RequestUtil::getRemoteIP(true), $ips))) {
128 2
			if (\Config\Debug::$DEBUG_CONSOLE_ALLOWED_USERS && !\in_array(\App\User::getCurrentUserRealId(), \Config\Debug::$DEBUG_CONSOLE_ALLOWED_USERS)) {
0 ignored issues
show
Bug Best Practice introduced by
The expression Config\Debug::DEBUG_CONSOLE_ALLOWED_USERS of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
129 2
				return false;
130
			}
131 1
			return true;
132
		}
133
		return false;
134
	}
135
136
	/**
137
	 * Generates a backtrace.
138
	 *
139
	 * @param int    $minLevel
140
	 * @param int    $maxLevel
141
	 * @param string $sep
142
	 *
143 6389
	 * @return string
144
	 */
145 6389
	public static function getBacktrace($minLevel = 1, $maxLevel = 0, $sep = '#')
146 6389
	{
147 6389
		$trace = '';
148 6389
		foreach (debug_backtrace() as $k => $v) {
149
			if ($k < $minLevel) {
150 6389
				continue;
151 6389
			}
152 6389
			$l = $k - $minLevel;
153 6389
			$args = '';
154 6389
			if (isset($v['args'])) {
155 6389
				foreach ($v['args'] as &$arg) {
156 6006
					if (!\is_array($arg) && !\is_object($arg) && !\is_resource($arg)) {
157 150
						$args .= var_export($arg, true);
158 150
					} elseif (\is_array($arg)) {
159 147
						$args .= '[';
160 147
						foreach ($arg as &$a) {
161 35
							$val = $a;
162 35
							if (\is_array($a) || \is_object($a) || \is_resource($a)) {
163 9
								$val = \gettype($a);
164
								if (\is_object($a)) {
165
									$val .= '(' . \get_class($a) . ')';
166 147
								}
167
							}
168 150
							$args .= $val . ',';
169
						}
170 6389
						$args = rtrim($args, ',') . ']';
171
					}
172 6389
					$args .= ',';
173
				}
174 6389
				$args = rtrim($args, ',');
175 6389
			}
176 6389
			$trace .= "$sep$l";
177
			if (isset($v['line'])) {
178 6389
				$trace .= " {$v['file']}:{$v['line']}";
179 6389
			}
180 6389
			$trace .= '  >>  ' . (isset($v['class']) ? $v['class'] . '->' : '') . "{$v['function']}($args)" . PHP_EOL;
181 6388
			unset($args, $val, $v, $k, $a);
182
			if (0 !== $maxLevel && $l >= $maxLevel) {
183
				break;
184 6389
			}
185
		}
186
		return rtrim(str_replace(ROOT_DIRECTORY . \DIRECTORY_SEPARATOR, '', $trace), PHP_EOL);
187
	}
188
}
189