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

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
 * ModelAbstractTest
10
 *
11
 * @since 4.0.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @covers Redaxscript\Model\ModelAbstract
18
 */
19
20
class ModelAbstractTest 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
		 Db::forTablePrefix('articles')
35
			->create()
36
			->set(
37
			[
38
				'title' => 'Article One',
39
				'alias' => 'article-one'
40
			])
41
			->save();
42
		Db::forTablePrefix('articles')
43
			->create()
44
			->set(
45
			[
46
				'title' => 'Article Two',
47
				'alias' => 'article-two'
48
			])
49
			->save();
50
	}
51
52
	/**
53
	 * tearDown
54
	 *
55
	 * @since 4.0.0
56
	 */
57
58
	public function tearDown() : void
59
	{
60
		$this->dropDatabase();
61
	}
62
63
	/**
64
	 * testGetById
65
	 *
66
	 * @since 4.0.0
67
	 *
68
	 * @param int $id
69
	 * @param string $expect
70
	 *
71
	 * @dataProvider providerAutoloader
72
	 */
73
74
	public function testGetById(int $id = null, string $expect = null) : void
75
	{
76
		/* setup */
77
78
		$articleModel = new Model\Article();
79
80
		/* actual */
81
82
		$actual = $articleModel->getById($id)->alias ?? null;
83
84
		/* compare */
85
86
		$this->assertEquals($expect, $actual);
87
	}
88
89
	/**
90
	 * testGetById
91
	 *
92
	 * @since 4.0.0
93
	 *
94
	 * @param array $expectArray
95
	 *
96
	 * @dataProvider providerAutoloader
97
	 */
98
99
	public function testGetAll(array $expectArray = []) : void
100
	{
101
		/* setup */
102
103
		$articleModel = new Model\Article();
104
105
		/* actual */
106
107
		$actualArray = [];
108
		$actualObject = $articleModel->getAll();
109
110
		/* process articles */
111
112
		foreach ($actualObject as $value)
0 ignored issues
show
The expression $actualObject of type array|object<IdiormResultSet>|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...
113
		{
114
			$actualArray[] = $value->alias ?? null;
115
		}
116
117
		/* compare */
118
119
		$this->assertEquals($expectArray, $actualArray);
120
	}
121
122
	/**
123
	 * testQuery
124
	 *
125
	 * @since 4.0.0
126
	 *
127
	 * @param array $expectArray
128
	 *
129
	 * @dataProvider providerAutoloader
130
	 */
131
132
	public function testQuery(array $expectArray = []) : void
133
	{
134
		/* setup */
135
136
		$articleModel = new Model\Article();
137
138
		/* actual */
139
140
		$actualArray = $articleModel->query()->findFlatArray('id');
141
142
		/* compare */
143
144
		$this->assertEquals($expectArray, $actualArray);
145
	}
146
147
	/**
148
	 * testClearCache
149
	 *
150
	 * @since 4.0.0
151
	 */
152
153
	public function testClearCache() : void
154
	{
155
		/* setup */
156
157
		$articleModel = new Model\Article();
158
159
		/* actual */
160
161
		$actual = $articleModel->clearCache();
0 ignored issues
show
Are you sure the assignment to $actual is correct as $articleModel->clearCache() (which targets Redaxscript\Model\ModelAbstract::clearCache()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
162
163
		/* compare */
164
165
		$this->assertNull($actual);
166
	}
167
}
168