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.

tests/unit/Controller/InstallTest.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\Tests\Controller;
3
4
use org\bovigo\vfs\vfsStream as Stream;
5
use org\bovigo\vfs\vfsStreamFile as StreamFile;
6
use org\bovigo\vfs\vfsStreamWrapper as StreamWrapper;
7
use Redaxscript\Controller;
8
use Redaxscript\Tests\TestCaseAbstract;
9
10
/**
11
 * InstallTest
12
 *
13
 * @since 3.0.0
14
 *
15
 * @package Redaxscript
16
 * @category Tests
17
 * @author Henry Ruhs
18
 * @author Balázs Szilágyi
19
 *
20
 * @covers Redaxscript\Controller\ControllerAbstract
21
 * @covers Redaxscript\Controller\Install
22
 *
23
 * @requires OS Linux
24
 */
25
26
class InstallTest extends TestCaseAbstract
27
{
28
	/**
29
	 * setUp
30
	 *
31
	 * @since 3.0.0
32
	 */
33
34
	public function setUp() : void
35
	{
36
		parent::setUp();
37
		Stream::setup('root');
38
		$file = new StreamFile('config.php');
39
		StreamWrapper::getRoot()->addChild($file);
40
	}
41
42
	/**
43
	 * tearDown
44
	 *
45
	 * @since 3.1.0
46
	 */
47
48
	public function tearDown() : void
49
	{
50
		$this->dropDatabase();
51
	}
52
53
	/**
54
	 * testProcess
55
	 *
56
	 * @since 3.0.0
57
	 *
58
	 * @param array $postArray
59
	 * @param string $method
60
	 * @param string $expect
61
	 *
62
	 * @dataProvider providerAutoloader
63
	 */
64
65
	public function testProcess(array $postArray = [], string $method = null, string $expect = null) : void
66
	{
67
		/* setup */
68
69
		$postArray['db-type'] = $postArray['db-type'] === '%CURRENT%' ? $this->_config->get('dbType') : $postArray['db-type'];
70
		$postArray['db-host'] = $postArray['db-host'] === '%CURRENT%' ? $this->_config->get('dbHost') : $postArray['db-host'];
71
		$postArray['db-name'] = $postArray['db-name'] === '%CURRENT%' ? $this->_config->get('dbName') : $postArray['db-name'];
72
		$postArray['db-user'] = $postArray['db-user'] === '%CURRENT%' ? $this->_config->get('dbUser') : $postArray['db-user'];
73
		$postArray['db-password'] = $postArray['db-password'] === '%CURRENT%' ? $this->_config->get('dbPassword') : $postArray['db-password'];
74
		$postArray['db-prefix'] = $postArray['db-prefix'] === '%CURRENT%' ? $this->_config->get('dbPrefix') : $postArray['db-prefix'];
75
		$this->_request->set('post', $postArray);
76
		$this->_config->init(Stream::url('root' . DIRECTORY_SEPARATOR . 'config.php'));
77
		if ($method)
0 ignored issues
show
Bug Best Practice introduced by
The expression $method of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
78
		{
79
			$installController = $this
80
				->getMockBuilder('Redaxscript\Controller\Install')
81
				->setConstructorArgs(
82
				[
83
					$this->_registry,
84
					$this->_request,
85
					$this->_language,
86
					$this->_config
87
				])
88
				->setMethods(
89
				[
90
					$method
91
				])
92
				->getMock();
93
94
			/* override */
95
96
			$installController
97
				->expects($this->any())
98
				->method($method);
99
		}
100
		else
101
		{
102
			$installController = new Controller\Install($this->_registry, $this->_request, $this->_language, $this->_config);
103
		}
104
105
		/* actual */
106
107
		$actual = $installController->process();
108
109
		/* compare */
110
111
		$this->assertEquals($expect, $actual);
112
	}
113
114
	/**
115
	 * testValidateDatabase
116
	 *
117
	 * @since 3.0.0
118
	 *
119
	 * @param array $postArray
120
	 * @param array $expectArray
121
	 *
122
	 * @dataProvider providerAutoloader
123
	 */
124
125
	public function testValidateDatabase(array $postArray = [], array $expectArray = []) : void
126
	{
127
		/* setup */
128
129
		$installController = new Controller\Install($this->_registry, $this->_request, $this->_language, $this->_config);
130
131
		/* actual */
132
133
		$actualArray = $this->callMethod($installController, '_validateDatabase',
134
		[
135
			$postArray
136
		]);
137
138
		/* compare */
139
140
		$this->assertEquals($expectArray, $actualArray);
141
	}
142
143
	/**
144
	 * testValidateAccount
145
	 *
146
	 * @since 3.0.0
147
	 *
148
	 * @param array $postArray
149
	 * @param array $expectArray
150
	 *
151
	 * @dataProvider providerAutoloader
152
	 */
153
154
	public function testValidateAccount(array $postArray = [], array $expectArray = []) : void
155
	{
156
		/* setup */
157
158
		$installController = new Controller\Install($this->_registry, $this->_request, $this->_language, $this->_config);
159
160
		/* actual */
161
162
		$actualArray = $this->callMethod($installController, '_validateAccount',
163
		[
164
			$postArray
165
		]);
166
167
		/* compare */
168
169
		$this->assertEquals($expectArray, $actualArray);
170
	}
171
172
	/**
173
	 * testInstall
174
	 *
175
	 * @since 3.0.0
176
	 *
177
	 * @param array $installArray
178
	 * @param bool $expect
179
	 *
180
	 * @dataProvider providerAutoloader
181
	 */
182
183
	public function testInstall(array $installArray = [], bool $expect = null) : void
184
	{
185
		/* setup */
186
187
		$installController = new Controller\Install($this->_registry, $this->_request, $this->_language, $this->_config);
188
189
		/* actual */
190
191
		$actual = $this->callMethod($installController, '_install',
192
		[
193
			$installArray
194
		]);
195
196
		/* compare */
197
198
		$this->assertEquals($expect, $actual);
199
	}
200
}
201