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/Process.php (2 issues)

1
<?php
2
/**
3
 * Process 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
 * Process class.
17
 */
18
class Process
19
{
20
	/**
21
	 * Request start time.
22
	 *
23
	 * @var int
24
	 */
25
	public static $startTime;
26
27
	/**
28
	 * Request mode.
29
	 *
30
	 * @var string
31
	 */
32
	public static $requestMode;
33
34
	/**
35
	 * CRM root directory.
36
	 *
37
	 * @var string
38
	 */
39
	public static $rootDirectory;
40
41
	/**
42
	 * Request process type.
43
	 *
44
	 * @var string
45
	 */
46
	public static $processType;
47
48
	/**
49
	 * Request process name.
50
	 *
51
	 * @var string
52
	 */
53
	public static $processName;
54
55
	/**
56
	 * List of events.
57
	 *
58
	 * @var array
59
	 */
60
	private static $events = [];
61
62
	/**
63
	 * Initialization of events.
64
	 *
65
	 * @return void
66
	 */
67
	public static function init(): void
68
	{
69
		self::$events = Session::get('processEvents') ?? [];
0 ignored issues
show
Documentation Bug introduced by
It seems like App\Session::get('processEvents') ?? array() can also be of type string. However, the property $events is declared as type array. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
70
	}
71
72
	/**
73
	 * Add event.
74
	 *
75
	 * App\Process::addEvent([
76
	 *	'name' => 'notify test',
77
	 *	'execution' => 'once',
78
	 *	'type' => 'notify',
79
	 *	'notify' => [
80
	 *		'text' => 'test',
81
	 *		'type' => 'info' // alert, notice, info, success, error
82
	 *	]
83
	 * ]);
84
	 * alert, notice, info, success, error
85
	 *
86
	 * @param array $event
87
	 *
88
	 * @return void
89
	 */
90
	public static function addEvent(array $event): void
91
	{
92
		if (empty($event['name']) || empty($event['type'])) {
93
			throw new Exceptions\AppException('Incorrect data');
94
		}
95
		if (empty($event['priority'])) {
96
			$event['priority'] = 5;
97
		}
98
		if (empty($event['execution'])) {
99
			$event['execution'] = 'constant';
100
		}
101
		self::$events[$event['name']] = $event;
102
		self::writeSession();
103
	}
104
105
	/**
106
	 * Remove event.
107
	 *
108
	 * @param string $name
109
	 *
110
	 * @return void
111
	 */
112
	public static function removeEvent(string $name): void
113
	{
114
		if (isset(self::$events[$name])) {
115
			unset(self::$events[$name]);
116
			self::writeSession();
117
		}
118
	}
119
120
	/**
121
	 * Has event.
122
	 *
123
	 * @param string $name
124
	 *
125
	 * @return bool
126
	 */
127
	public static function hasEvent(string $name): bool
128
	{
129
		return isset(self::$events[$name]);
130
	}
131
132
	/**
133
	 * Get events.
134
	 *
135
	 * @return array
136
	 */
137
	public static function getEvents(): array
138
	{
139
		$events = [];
140
		$writeSession = false;
141
		foreach (self::$events as $name => $row) {
142
			$events[] = $row;
143
			if ('once' === $row['execution']) {
144
				unset(self::$events[$name]);
145
				$writeSession = true;
146
			}
147
		}
148
		if ($writeSession) {
149
			self::writeSession();
150
		}
151
		$priority = array_column($events, 'priority');
152
		array_multisort($priority, SORT_DESC, $events);
0 ignored issues
show
App\SORT_DESC cannot be passed to array_multisort() as the parameter $rest expects a reference. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

152
		array_multisort($priority, /** @scrutinizer ignore-type */ SORT_DESC, $events);
Loading history...
153
		return $events;
154
	}
155
156
	/**
157
	 * Write session data.
158
	 *
159
	 * @return void
160
	 */
161
	private static function writeSession(): void
162
	{
163
		Session::set('processEvents', self::$events);
164
	}
165
}
166