Issues (201)

Security Analysis    no request data  

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

  Cross-Site Scripting
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.
  File Exposure
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.
  File Manipulation
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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  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.
  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.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
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.

includes/Admin/Controller/Module.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Redaxscript\Admin\Controller;
3
4
use Redaxscript\Admin;
5
use Redaxscript\Filter;
6
use Redaxscript\Validator;
7
use function json_encode;
8
9
/**
10
 * children class to process the admin module request
11
 *
12
 * @since 4.0.0
13
 *
14
 * @package Redaxscript
15
 * @category Controller
16
 * @author Henry Ruhs
17
 */
18
19
class Module extends ControllerAbstract
20
{
21
	/**
22
	 * process the class
23
	 *
24
	 * @since 4.0.0
25
	 *
26
	 * @param string $action action to process
27
	 *
28
	 * @return string
29
	 */
30
31 6
	public function process(string $action = null) : string
32
	{
33 6
		$postArray = $this->_normalizePost($this->_sanitizePost());
34 6
		$validateArray = $this->_validatePost($postArray);
35
36
		/* validate post */
37
38 6
		if ($validateArray)
0 ignored issues
show
Bug Best Practice introduced by
The expression $validateArray 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...
39
		{
40 3
			return $this->_error(
41
			[
42 3
				'route' => $this->_getErrorRoute($postArray),
43 3
				'message' => $validateArray
44
			]);
45
		}
46
47
		/* handle update */
48
49 3
		if ($action === 'update')
50
		{
51
			$updateArray =
52
			[
53 2
				'name' => $postArray['name'],
54 2
				'description' => $postArray['description'],
55 2
				'status' => $postArray['status'],
56 2
				'access' => $postArray['access']
57
			];
58 2
			if ($this->_update($postArray['id'], $updateArray))
59
			{
60 2
				return $this->_success(
61
				[
62 2
					'route' => $this->_getSuccessRoute($postArray),
63 2
					'timeout' => 2
64
				]);
65
			}
66
		}
67
68
		/* handle error */
69
70 1
		return $this->_error(
71
		[
72 1
			'route' => $this->_getErrorRoute($postArray)
73
		]);
74
	}
75
76
	/**
77
	 * sanitize the post
78
	 *
79
	 * @since 4.0.0
80
	 *
81
	 * @return array
82
	 */
83
84 6
	protected function _sanitizePost() : array
85
	{
86 6
		$numberFilter = new Filter\Number();
87 6
		$textFilter = new Filter\Text();
88 6
		$toggleFilter = new Filter\Toggle();
89
90
		/* sanitize post */
91
92
		return
93
		[
94 6
			'id' => $numberFilter->sanitize($this->_request->getPost('id')),
95 6
			'name' => $textFilter->sanitize($this->_request->getPost('name')),
96 6
			'description' => $textFilter->sanitize($this->_request->getPost('description')),
97 6
			'status' => $toggleFilter->sanitize($this->_request->getPost('status')),
98 6
			'access' => json_encode($this->_request->getPost('access'))
99
		];
100
	}
101
102
	/**
103
	 * validate the post
104
	 *
105
	 * @since 4.0.0
106
	 *
107
	 * @param array $postArray array of the post
108
	 *
109
	 * @return array
110
	 */
111
112 6
	protected function _validatePost(array $postArray = []) : array
113
	{
114 6
		$nameValidator = new Validator\Name();
115 6
		$validateArray = [];
116
117
		/* validate post */
118
119 6
		if (!$postArray['name'])
120
		{
121 3
			$validateArray[] = $this->_language->get('name_empty');
122
		}
123 3
		else if (!$nameValidator->validate($postArray['name']))
124
		{
125
			$validateArray[] = $this->_language->get('name_incorrect');
126
		}
127 6
		return $validateArray;
128
	}
129
130
	/**
131
	 * update the module
132
	 *
133
	 * @since 4.0.0
134
	 *
135
	 * @param int $moduleId identifier of the module
136
	 * @param array $updateArray array of the update
137
	 *
138
	 * @return bool
139
	 */
140
141 2
	protected function _update(int $moduleId = null, array $updateArray = []) : bool
142
	{
143 2
		$moduleModel = new Admin\Model\Module();
144 2
		return $moduleModel->updateByIdAndArray($moduleId, $updateArray);
145
	}
146
147
	/**
148
	 * get success route
149
	 *
150
	 * @since 4.0.0
151
	 *
152
	 * @param array $postArray array of the post
153
	 *
154
	 * @return string
155
	 */
156
157 2
	protected function _getSuccessRoute(array $postArray = []) : string
158
	{
159 2
		if ($this->_registry->get('modulesEdit'))
160
		{
161 1
			if ($postArray['id'])
162
			{
163 1
				return 'admin/view/modules#row-' . $postArray['id'];
164
			}
165
			return 'admin/view/modules';
166
		}
167 1
		return 'admin';
168
	}
169
170
	/**
171
	 * get error route
172
	 *
173
	 * @since 4.0.0
174
	 *
175
	 * @param array $postArray array of the post
176
	 *
177
	 * @return string
178
	 */
179
180 4
	protected function _getErrorRoute(array $postArray = []) : string
181
	{
182 4
		if ($this->_registry->get('modulesEdit'))
183
		{
184 3
			if ($postArray['id'])
185
			{
186 2
				return 'admin/edit/modules/' . $postArray['id'];
187
			}
188 1
			return 'admin/view/modules';
189
		}
190 1
		return 'admin';
191
	}
192
}
193