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/Extra.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
use function strtotime;
9
10
/**
11
 * children class to process the admin extra request
12
 *
13
 * @since 4.0.0
14
 *
15
 * @package Redaxscript
16
 * @category Controller
17
 * @author Henry Ruhs
18
 */
19
20
class Extra extends ControllerAbstract
21
{
22
	/**
23
	 * process the class
24
	 *
25
	 * @since 4.0.0
26
	 *
27
	 * @param string $action action to process
28
	 *
29
	 * @return string
30
	 */
31
32 10
	public function process(string $action = null) : string
33
	{
34 10
		$postArray = $this->_normalizePost($this->_sanitizePost());
35 10
		$validateArray = $this->_validatePost($postArray);
36 10
		$myName = $this->_registry->get('myName');
37 10
		$now = $this->_registry->get('now');
38
39
		/* validate post */
40
41 10
		if ($validateArray)
42
		{
43 6
			return $this->_error(
44
			[
45 6
				'route' => $this->_getErrorRoute($postArray),
46 6
				'message' => $validateArray
47
			]);
48
		}
49
50
		/* handle create */
51
52 4
		if ($action === 'create')
53
		{
54
			$createArray =
55
			[
56 1
				'title' => $postArray['title'],
57 1
				'alias' => $postArray['alias'],
58 1
				'author' => $myName,
59 1
				'text' => $postArray['text'],
60 1
				'language' => $postArray['language'],
61 1
				'sibling' => $postArray['sibling'],
62 1
				'category' => $postArray['category'],
63 1
				'article' => $postArray['article'],
64 1
				'headline' => $postArray['headline'],
65 1
				'status' => $postArray['date'] > $now ? 2 : $postArray['status'],
66 1
				'rank' => $postArray['rank'],
67 1
				'access' => $postArray['access'],
68 1
				'date' => $postArray['date'] ? : $now
69
			];
70 1
			if ($this->_create($createArray))
71
			{
72 1
				return $this->_success(
73
				[
74 1
					'route' => $this->_getSuccessRoute($postArray),
75 1
					'timeout' => 2
76
				]);
77
			}
78
		}
79
80
		/* handle update */
81
82 3
		if ($action === 'update')
83
		{
84
			$updateArray =
85
			[
86 2
				'title' => $postArray['title'],
87 2
				'alias' => $postArray['alias'],
88 2
				'author' => $myName,
89 2
				'text' => $postArray['text'],
90 2
				'language' => $postArray['language'],
91 2
				'sibling' => $postArray['sibling'],
92 2
				'category' => $postArray['category'],
93 2
				'article' => $postArray['article'],
94 2
				'headline' => $postArray['headline'],
95 2
				'status' => $postArray['date'] > $now ? 2 : $postArray['status'],
96 2
				'rank' => $postArray['rank'],
97 2
				'access' => $postArray['access'],
98 2
				'date' => $postArray['date'] ? : $now
99
			];
100 2
			if ($this->_update($postArray['id'], $updateArray))
101
			{
102 2
				return $this->_success(
103
				[
104 2
					'route' => $this->_getSuccessRoute($postArray),
105 2
					'timeout' => 2
106
				]);
107
			}
108
		}
109
110
		/* handle error */
111
112 1
		return $this->_error(
113
		[
114 1
			'route' => $this->_getErrorRoute($postArray)
115
		]);
116
	}
117
118
	/**
119
	 * sanitize the post
120
	 *
121
	 * @since 4.0.0
122
	 *
123
	 * @return array
124
	 */
125
126 10
	protected function _sanitizePost() : array
127
	{
128 10
		$aliasFilter = new Filter\Alias();
129 10
		$htmlFilter = new Filter\Html();
130 10
		$numberFilter = new Filter\Number();
131 10
		$specialFilter = new Filter\Special();
132 10
		$textFilter= new Filter\Text();
133 10
		$toggleFilter = new Filter\Toggle();
134
135
		/* sanitize post */
136
137
		return
138
		[
139 10
			'id' => $numberFilter->sanitize($this->_request->getPost('id')),
140 10
			'title' => $textFilter->sanitize($this->_request->getPost('title')),
141 10
			'alias' => $aliasFilter->sanitize($this->_request->getPost('alias')),
142 10
			'text' => $htmlFilter->sanitize($this->_request->getPost('text'), $this->_registry->get('filter')),
143 10
			'language' => $specialFilter->sanitize($this->_request->getPost('language')),
144 10
			'sibling' => $numberFilter->sanitize($this->_request->getPost('sibling')),
145 10
			'category' => $numberFilter->sanitize($this->_request->getPost('category')),
146 10
			'article' => $numberFilter->sanitize($this->_request->getPost('article')),
147 10
			'headline' => $toggleFilter->sanitize($this->_request->getPost('headline')),
148 10
			'status' => $toggleFilter->sanitize($this->_request->getPost('status')),
149 10
			'rank' => $numberFilter->sanitize($this->_request->getPost('rank')),
150 10
			'access' => json_encode($this->_request->getPost('access')),
151 10
			'date' => strtotime($this->_request->getPost('date'))
152
		];
153
	}
154
155
	/**
156
	 * validate the post
157
	 *
158
	 * @since 4.0.0
159
	 *
160
	 * @param array $postArray array of the post
161
	 *
162
	 * @return array
163
	 */
164
165 10
	protected function _validatePost(array $postArray = []) : array
166
	{
167 10
		$nameValidator = new Validator\Name();
168 10
		$aliasValidator = new Validator\Alias();
169 10
		$extraModel = new Admin\Model\Extra();
170 10
		$validateArray = [];
171
172
		/* validate post */
173
174 10
		if (!$postArray['title'])
175
		{
176 5
			$validateArray[] = $this->_language->get('title_empty');
177
		}
178 5
		else if (!$nameValidator->validate($postArray['title']))
179
		{
180 1
			$validateArray[] = $this->_language->get('title_incorrect');
181
		}
182 10
		if (!$postArray['alias'])
183
		{
184 4
			$validateArray[] = $this->_language->get('alias_empty');
185
		}
186 6
		else if (!$aliasValidator->validate($postArray['alias']))
187
		{
188 1
			$validateArray[] = $this->_language->get('alias_incorrect');
189
		}
190 5
		else if (!$extraModel->isUniqueByIdAndAlias($postArray['id'], $postArray['alias']))
191
		{
192 1
			$validateArray[] = $this->_language->get('alias_exists');
193
		}
194 10
		if (!$postArray['text'])
195
		{
196 6
			$validateArray[] = $this->_language->get('extra_empty');
197
		}
198 10
		return $validateArray;
199
	}
200
201
	/**
202
	 * create the extra
203
	 *
204
	 * @since 4.0.0
205
	 *
206
	 * @param array $createArray array of the create
207
	 *
208
	 * @return bool
209
	 */
210
211 1
	protected function _create(array $createArray = []) : bool
212
	{
213 1
		$extraModel = new Admin\Model\Extra();
214 1
		return $extraModel->createByArray($createArray);
215
	}
216
217
	/**
218
	 * update the extra
219
	 *
220
	 * @since 4.0.0
221
	 *
222
	 * @param int $extraId identifier of the extra
223
	 * @param array $updateArray array of the update
224
	 *
225
	 * @return bool
226
	 */
227
228 2
	protected function _update(int $extraId = null, array $updateArray = []) : bool
229
	{
230 2
		$extraModel = new Admin\Model\Extra();
231 2
		return $extraModel->updateByIdAndArray($extraId, $updateArray);
232
	}
233
234
	/**
235
	 * get success route
236
	 *
237
	 * @since 4.0.0
238
	 *
239
	 * @param array $postArray array of the post
240
	 *
241
	 * @return string
242
	 */
243
244 3
	protected function _getSuccessRoute(array $postArray = []) : string
245
	{
246 3
		if ($this->_registry->get('extrasEdit') && $postArray['id'])
247
		{
248 1
			return 'admin/view/extras#row-' . $postArray['id'];
249
		}
250 2
		if ($this->_registry->get('extrasEdit') && $postArray['alias'])
251
		{
252 1
			$extraModel = new Admin\Model\Extra();
253 1
			$extraId = $extraModel->getByAlias($postArray['alias'])?->id;
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_OBJECT_OPERATOR
Loading history...
254 1
			if ($extraId)
255
			{
256 1
				return 'admin/view/extras#row-' . $extraId;
257
			}
258
			return 'admin/view/extras';
259
		}
260 1
		return 'admin';
261
	}
262
263
	/**
264
	 * get error route
265
	 *
266
	 * @since 4.0.0
267
	 *
268
	 * @param array $postArray array of the post
269
	 *
270
	 * @return string
271
	 */
272
273 7
	protected function _getErrorRoute(array $postArray = []) : string
274
	{
275 7
		if ($this->_registry->get('extrasEdit') && $postArray['id'])
276
		{
277 2
			return 'admin/edit/extras/' . $postArray['id'];
278
		}
279 5
		if ($this->_registry->get('extrasNew'))
280
		{
281 4
			return 'admin/new/extras';
282
		}
283 1
		return 'admin';
284
	}
285
}
286