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

Labels
Severity

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\Model;
3
4
use Redaxscript\Db;
5
use Redaxscript\Model;
6
use Redaxscript\Tests\TestCaseAbstract;
7
8
/**
9
 * SearchTest
10
 *
11
 * @since 4.0.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @covers Redaxscript\Model\Search
18
 */
19
20
class SearchTest extends TestCaseAbstract
21
{
22
	/**
23
	 * setUp
24
	 *
25
	 * @since 4.0.0
26
	 */
27
28
	public function setUp() : void
29
	{
30
		parent::setUp();
31
		$installer = $this->installerFactory();
32
		$installer->init();
33
		$installer->rawCreate();
34
		$categoryOne = Db::forTablePrefix('categories')->create();
35
		$categoryOne
36
			->set(
37
			[
38
				'title' => 'Category One',
39
				'alias' => 'category-one',
40
				'keywords' => 'category, one'
41
			])
42
			->save();
43
		Db::forTablePrefix('categories')
44
			->create()
45
			->set(
46
			[
47
				'title' => 'Category Two',
48
				'alias' => 'category-two',
49
				'keywords' => 'category, two'
50
			])
51
			->save();
52
		$articleOne = Db::forTablePrefix('articles')->create();
53
		$articleOne
54
			->set(
55
			[
56
				'title' => 'Article One',
57
				'alias' => 'article-one',
58
				'keywords' => 'article, one',
59
				'category' => $categoryOne->id
60
			])
61
			->save();
62
		Db::forTablePrefix('articles')
63
			->create()
64
			->set(
65
			[
66
				'title' => 'Article Two',
67
				'alias' => 'article-two',
68
				'keywords' => 'article, one',
69
				'category' => $categoryOne->id
70
			])
71
			->save();
72
		Db::forTablePrefix('comments')
73
			->create()
74
			->set(
75
			[
76
				'author' => 'Comment One',
77
				'text' => 'Comment One',
78
				'article' => $articleOne->id
79
			])
80
			->save();
81
		Db::forTablePrefix('comments')
82
			->create()
83
			->set(
84
			[
85
				'author' => 'Comment Two',
86
				'text' => 'Comment Two',
87
				'article' => $articleOne->id
88
			])
89
			->save();
90
	}
91
92
	/**
93
	 * tearDown
94
	 *
95
	 * @since 4.0.0
96
	 */
97
98
	public function tearDown() : void
99
	{
100
		$this->dropDatabase();
101
	}
102
103
	/**
104
	 * testGetByTable
105
	 *
106
	 * @since 4.0.0
107
	 *
108
	 * @param string $table
109
	 * @param string $search
110
	 * @param string $language
111
	 * @param array $expectArray
112
	 *
113
	 * @dataProvider providerAutoloader
114
	 */
115
116
	public function testGetByTable(string $table = null, string $search = null, string $language = null, array $expectArray = []) : void
117
	{
118
		/* setup */
119
120
		$searchModel = new Model\Search();
121
122
		/* actual */
123
124
		$actualArray = [];
125
		$actualObject = $searchModel->getByTable($table, $search, $language);
126
127
		/* process search */
128
129
		foreach ($actualObject as $value)
0 ignored issues
show
The expression $actualObject of type object|null is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
130
		{
131
			$actualArray[] = $value->title ? : $value->author;
132
		}
133
134
		/* compare */
135
136
		$this->assertEquals($expectArray, $actualArray);
137
	}
138
139
	/**
140
	 * testCreateColumnArray
141
	 *
142
	 * @since 4.0.0
143
	 *
144
	 * @param string $table
145
	 * @param array $expectArray
146
	 *
147
	 * @dataProvider providerAutoloader
148
	 */
149
150
	public function testCreateColumnArray(string $table = null, array $expectArray = []) : void
151
	{
152
		/* setup */
153
154
		$searchModel = new Model\Search();
155
156
		/* actual */
157
158
		$actualArray = $this->callMethod($searchModel, '_createColumnArray',
159
		[
160
			$table
161
		]);
162
163
		/* compare */
164
165
		$this->assertEquals($expectArray, $actualArray);
166
	}
167
168
169
	/**
170
	 * testCreateLikeArray
171
	 *
172
	 * @since 4.0.0
173
	 *
174
	 * @param string $table
175
	 * @param string $search
176
	 * @param array $expectArray
177
	 *
178
	 * @dataProvider providerAutoloader
179
	 */
180
181
	public function testCreateLikeArray(string $table = null, string $search = null, array $expectArray = []) : void
182
	{
183
		/* setup */
184
185
		$searchModel = new Model\Search();
186
187
		/* actual */
188
189
		$actualArray = $this->callMethod($searchModel, '_createLikeArray',
190
		[
191
			$table,
192
			$search
193
		]);
194
195
		/* compare */
196
197
		$this->assertEquals($expectArray, $actualArray);
198
	}
199
}
200