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/Session.php (1 issue)

1
<?php
2
3
namespace App;
4
5
/**
6
 * Session class.
7
 *
8
 * @package App
9
 *
10
 * @copyright YetiForce S.A.
11
 * @license   YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com)
12
 * @author    Mariusz Krzaczkowski <[email protected]>
13
 */
14
class Session
15
{
16
	/**
17
	 *  @var string Session path
18
	 */
19
	const SESSION_PATH = ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'cache' . \DIRECTORY_SEPARATOR . 'session';
20
21
	/**
22 1
	 * Session handler.
23
	 *
24 1
	 * @var \App\Session\Base
25 1
	 */
26
	public static $pool;
27
28
	/**
29
	 * Initialize session class.
30
	 */
31
	public static function init()
32
	{
33
		if (PHP_SESSION_ACTIVE === \session_status()) {
34
			return;
35
		}
36
		if (self::load()) {
37
			\session_set_save_handler(self::$pool, true);
38
		}
39
		\session_start();
40
	}
41
42
	/**
43
	 * Load session driver.
44 5
	 *
45
	 * @return bool
46 5
	 */
47
	public static function load(): bool
48
	{
49 5
		if (empty(self::$pool) && !empty(\Config\Performance::$SESSION_DRIVER)) {
50
			$className = '\App\Session\\' . \Config\Performance::$SESSION_DRIVER;
51
			self::$pool = new $className();
52
			return true;
53
		}
54
		return false;
55
	}
56
57
	/**
58
	 * Returns a session Item representing the specified key.
59 4
	 *
60
	 * @param string $key
61 4
	 *
62
	 * @return array|string
63
	 */
64 4
	public static function get($key)
65
	{
66
		if (empty(static::$pool)) {
67
			return $_SESSION[$key] ?? null;
68
		}
69
		return static::$pool->get($key);
70
	}
71
72
	/**
73
	 * Confirms if the session contains specified session item.
74
	 *
75 5
	 * @param string $key
76
	 *
77 5
	 * @return bool
78
	 */
79
	public static function has($key)
80 5
	{
81
		if (empty(static::$pool)) {
82
			return isset($_SESSION[$key]);
83
		}
84
		return static::$pool->has($key);
85
	}
86
87
	/**
88
	 * Session Save.
89
	 *
90
	 * @param string $key
91
	 * @param mixed  $value
92
	 *
93
	 * @return bool
94
	 */
95
	public static function set($key, $value = null)
96
	{
97
		if (empty(static::$pool)) {
98
			return $_SESSION[$key] = $value;
99
		}
100
		return static::$pool->set($key, $value);
0 ignored issues
show
Bug Best Practice introduced by
The expression return static::pool->set($key, $value) returns the type App\Session\Base which is incompatible with the documented return type boolean.
Loading history...
101
	}
102
103
	/**
104
	 * Removes the item from the session.
105
	 *
106
	 * @param string $key
107
	 *
108
	 * @return bool
109
	 */
110
	public static function delete($key)
111
	{
112
		if (empty(static::$pool)) {
113
			unset($_SESSION[$key]);
114
		}
115
		static::$pool->delete($key);
116
	}
117
118
	/**
119
	 * Update the current session id with a newly generated one.
120
	 *
121
	 * @see https://php.net/manual/en/function.session-regenerate-id.php
122
	 *
123
	 * @param bool $deleteOldSession
124
	 */
125
	public static function regenerateId($deleteOldSession = false)
126
	{
127
		if (empty(static::$pool)) {
128
			\session_regenerate_id($deleteOldSession);
129
		} else {
130
			static::$pool->regenerateId($deleteOldSession);
131
		}
132
	}
133
134
	/**
135
	 * Destroys all data registered to a session.
136
	 *
137
	 * @see https://php.net/manual/en/function.session-destroy.php
138
	 */
139
	public static function destroy()
140
	{
141
		$_SESSION = [];
142
		if (\PHP_SAPI !== 'cli' && !headers_sent()) {
143
			$params = session_get_cookie_params();
144
			setcookie(session_name(), '', time() - 42000,
145
				$params['path'], $params['domain'],
146
				$params['secure'], $params['httponly']
147
			);
148
		}
149
		\session_destroy();
150
	}
151
152
	/**
153
	 * Function to clean session. Removed old session.
154
	 *
155
	 * @return string[]
156
	 */
157
	public static function clean()
158
	{
159
		if (!empty(static::$pool)) {
160
			return static::$pool->clean();
161
		}
162
		return [];
163
	}
164
165
	/**
166
	 * Function to clean all session.
167
	 *
168
	 * @return int
169
	 */
170
	public static function cleanAll(): int
171
	{
172
		if (!empty(static::$pool)) {
173
			return static::$pool->cleanAll();
174
		}
175
		return 0;
176
	}
177
178
	/**
179
	 * Function to get session data by id.
180
	 *
181
	 * @param string $sessionId
182
	 *
183
	 * @return array
184
	 */
185
	public static function getById(string $sessionId): array
186
	{
187
		if (!empty(static::$pool)) {
188
			return static::$pool->getById($sessionId);
189
		}
190
		return [];
191
	}
192
}
193