Issues (63)

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.

src/Serializer/Gateway/NativeArrayGateway.php (2 issues)

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
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license.
17
 */
18
namespace Elastification\Client\Serializer\Gateway;
19
20
/**
21
 * Represents a gateway to an array.
22
 *
23
 * This one is used when using the {@see Elastification\Client\Serializer\NativeJsonSerializer}.
24
 *
25
 * @package Elastification\Client\Serializer\Gateway
26
 * @author  Mario Mueller
27
 */
28
class NativeArrayGateway implements GatewayInterface
29
{
30
    /**
31
     * @var array
32
     */
33
    private $jsonData;
34
35
    /**
36
     * @param array $jsonData The raw data.
37
     */
38 192
    function __construct(array $jsonData)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
39
    {
40 192
        $this->jsonData = $jsonData;
41 192
    }
42
43
    /**
44
     * Whether a offset exists
45
     *
46
     * @link http://php.net/manual/en/arrayaccess.offsetexists.php
47
     *
48
     * @param mixed $offset An offset to check for.
49
     *
50
     * @return boolean true on success or false on failure.
51
     */
52 10
    public function offsetExists($offset)
53
    {
54 10
        return isset($this->jsonData[$offset]);
55
    }
56
57
    /**
58
     * Offset to retrieve
59
     *
60
     * @link http://php.net/manual/en/arrayaccess.offsetget.php
61
     *
62
     * @param mixed $offset The offset to retrieve.
63
     *
64
     * @return mixed Can return all value types.
65
     */
66 143 View Code Duplication
    public function offsetGet($offset)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
67
    {
68 143
        if (isset($this->jsonData[$offset])) {
69 142
            return GatewayFactory::factory($this->jsonData[$offset]);
70
        }
71
72 1
        return null;
73
    }
74
75
    /**
76
     * Offset to set
77
     *
78
     * @link http://php.net/manual/en/arrayaccess.offsetset.php
79
     *
80
     * @param mixed $offset The offset to assign the value to.
81
     * @param mixed $value  The value to set.
82
     *
83
     * @return void
84
     */
85 1
    public function offsetSet($offset, $value)
86
    {
87 1
        throw new \BadMethodCallException('The result set is immutable');
88
    }
89
90
    /**
91
     * Offset to unset
92
     *
93
     * @link http://php.net/manual/en/arrayaccess.offsetunset.php
94
     *
95
     * @param mixed $offset The offset to unset.
96
     *
97
     * @return void
98
     */
99 1
    public function offsetUnset($offset)
100
    {
101 1
        throw new \BadMethodCallException('The result set is immutable');
102
    }
103
104
    /**
105
     * Return the current element
106
     *
107
     * @link http://php.net/manual/en/iterator.current.php
108
     * @return mixed Can return any type.
109
     */
110 1
    public function current()
111
    {
112 1
        return current($this->jsonData);
113
    }
114
115
    /**
116
     * Move forward to next element
117
     *
118
     * @link http://php.net/manual/en/iterator.next.php
119
     * @return void Any returned value is ignored.
120
     */
121 1
    public function next()
122
    {
123 1
        next($this->jsonData);
124 1
    }
125
126
    /**
127
     * Return the key of the current element
128
     *
129
     * @link http://php.net/manual/en/iterator.key.php
130
     * @return mixed scalar on success, or null on failure.
131
     */
132 1
    public function key()
133
    {
134 1
        return key($this->jsonData);
135
    }
136
137
    /**
138
     * Checks if current position is valid
139
     *
140
     * @link http://php.net/manual/en/iterator.valid.php
141
     * @return boolean The return value will be casted to boolean and then evaluated.
142
     */
143 1
    public function valid()
144
    {
145 1
        return current($this->jsonData) ? true : false;
146
    }
147
148
    /**
149
     * Rewind the Iterator to the first element
150
     *
151
     * @link http://php.net/manual/en/iterator.rewind.php
152
     * @return void Any returned value is ignored.
153
     */
154 1
    public function rewind()
155
    {
156 1
        reset($this->jsonData);
157 1
    }
158
159
    /**
160
     * Count elements of an object
161
     *
162
     * @link http://php.net/manual/en/countable.count.php
163
     * @return int The custom count as an integer. The return value is cast to an integer.
164
     */
165 1
    public function count()
166
    {
167 1
        return sizeof($this->jsonData);
168
    }
169
170
    /**
171
     * Returns the original value.
172
     *
173
     * @return mixed
174
     * @author Mario Mueller
175
     */
176 80
    public function getGatewayValue()
177
    {
178 80
        return $this->jsonData;
179
    }
180
}
181