Issues (12)

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

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 SubjectivePHPTest\Spl\Traits;
3
4
/**
5
 * @coversDefaultClass SubjectivePHP\Spl\Traits\ArrayAccessTrait
6
 */
7
class ArrayAccessTraitTest extends \PHPUnit\Framework\TestCase
8
{
9
    /**
10
     * Verify basic behavior of offsetSet().
11
     *
12
     * @test
13
     * @covers ::offsetSet
14
     *
15
     * @return void
16
     */
17
    public function offsetSet()
18
    {
19
        $object = new SimpleObject();
20
        $object['foo'] = 'bar';
21
        $object[] = 123;
22
23
        $this->assertSame(
24
            [
25
                'foo' => 'bar',
26
                0 => 123,
27
            ],
28
            $object->getContainer()
29
        );
30
    }
31
32
    /**
33
     * Verify behavior of offsetSet() with key which is not a string or an integer.
34
     *
35
     * @test
36
     * @covers ::offsetSet
37
     * @expectedException \InvalidArgumentException
38
     * @expectedExceptionMessage $offset must be an integer or string
39
     *
40
     * @return void
41
     */
42
    public function offsetSetInvalidKey()
43
    {
44
        $object = new SimpleObject();
45
        /** @scrutinizer ignore-call */ $object->offsetSet(new \StdClass(), 'weeee!');
0 ignored issues
show
new \StdClass() is of type object<stdClass>, but the function expects a string|integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
46
    }
47
48
    /**
49
     * Verify basic behavior of offsetExists().
50
     *
51
     * @test
52
     * @covers ::offsetExists
53
     *
54
     * @return void
55
     */
56
    public function offsetExists()
57
    {
58
        $object = new SimpleObject(['foo' => 'bar']);
59
        $this->assertTrue($object->offsetExists('foo'));
60
    }
61
62
    /**
63
     * Verify behavior of offsetExists() with key that is not an integer or string.
64
     *
65
     * @test
66
     * @covers ::offsetExists
67
     *
68
     * @return void
69
     */
70
    public function offsetExistsInvalidKey()
71
    {
72
        $object = new SimpleObject(['foo' => 'bar']);
73
        $this->assertFalse($object->offsetExists(true));
74
    }
75
76
    /**
77
     * Verify basic behavior of offsetUnset().
78
     *
79
     * @test
80
     * @covers ::offsetUnset
81
     *
82
     * @return void
83
     */
84
    public function offsetUnset()
85
    {
86
        $object = new SimpleObject(['foo' => 'bar']);
87
        $this->assertSame(['foo' => 'bar'], $object->getContainer());
88
        unset($object['foo']);
89
        $this->assertSame([], $object->getContainer());
90
    }
91
92
    /**
93
     * Verify behavior of offsetGet() with key that is not an integer or string.
94
     *
95
     * @test
96
     * @covers ::offsetGet
97
     *
98
     * @return void
99
     */
100
    public function offsetGet()
101
    {
102
        $object = new SimpleObject(['foo' => 'bar']);
103
        $this->assertSame('bar', $object['foo']);
104
    }
105
106
    /**
107
     * Verify behavior of offsetGet() with key which is not a string or an integer.
108
     *
109
     * @test
110
     * @covers ::offsetGet
111
     * @expectedException \InvalidArgumentException
112
     * @expectedExceptionMessage $offset must be an integer or string
113
     *
114
     * @return void
115
     */
116
    public function offsetGetInvalidKey()
117
    {
118
        $object = new SimpleObject();
119
        /** @scrutinizer ignore-call */ $object->offsetGet(new \StdClass());
0 ignored issues
show
new \StdClass() is of type object<stdClass>, but the function expects a integer|string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
120
    }
121
}
122