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/NativeObjectGateway.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
 * @package Elastification\Client\Serializer\Gateway
22
 * @author  Mario Mueller
23
 */
24
class NativeObjectGateway implements GatewayInterface
25
{
26
    /**
27
     * @var object
28
     */
29
    private $jsonData;
30
31
    /**
32
     * @var integer
33
     */
34
    private $propertyCount;
35
36
    /**
37
     * @var array<integer,integer|string>
38
     */
39
    private $properties;
40
41
    /**
42
     * @var integer
43
     */
44
    private $currentPointer = 0;
45
46
    /**
47
     * @param object $jsonData
48
     */
49 158
    function __construct($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...
50
    {
51 158
        $this->jsonData = $jsonData;
52 158
        $this->properties = array_keys(get_object_vars($jsonData));
53 158
        $this->propertyCount = sizeof($this->properties);
54 158
    }
55
56
    /**
57
     * (PHP 5 &gt;= 5.0.0)<br/>
58
     * Whether a offset exists
59
     *
60
     * @link http://php.net/manual/en/arrayaccess.offsetexists.php
61
     *
62
     * @param mixed $offset <p>
63
     *                      An offset to check for.
64
     *                      </p>
65
     *
66
     * @return boolean true on success or false on failure.
67
     * </p>
68
     * <p>
69
     * The return value will be casted to boolean if non-boolean was returned.
70
     */
71 7
    public function offsetExists($offset)
72
    {
73 7
        return isset($this->jsonData->{$offset});
74
    }
75
76
    /**
77
     * (PHP 5 &gt;= 5.0.0)<br/>
78
     * Offset to retrieve
79
     *
80
     * @link http://php.net/manual/en/arrayaccess.offsetget.php
81
     *
82
     * @param mixed $offset <p>
83
     *                      The offset to retrieve.
84
     *                      </p>
85
     *
86
     * @return mixed Can return all value types.
87
     */
88 144 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...
89
    {
90 144
        if (property_exists($this->jsonData, $offset)) {
91 143
            return GatewayFactory::factory($this->jsonData->$offset);
92
        }
93
94 1
        return null;
95
    }
96
97
    /**
98
     * (PHP 5 &gt;= 5.0.0)<br/>
99
     * Offset to set
100
     *
101
     * @link http://php.net/manual/en/arrayaccess.offsetset.php
102
     *
103
     * @param mixed $offset <p>
104
     *                      The offset to assign the value to.
105
     *                      </p>
106
     * @param mixed $value  <p>
107
     *                      The value to set.
108
     *                      </p>
109
     *
110
     * @return void
111
     */
112 1
    public function offsetSet($offset, $value)
113
    {
114 1
        throw new \BadMethodCallException('The result set is immutable');
115
    }
116
117
    /**
118
     * (PHP 5 &gt;= 5.0.0)<br/>
119
     * Offset to unset
120
     *
121
     * @link http://php.net/manual/en/arrayaccess.offsetunset.php
122
     *
123
     * @param mixed $offset <p>
124
     *                      The offset to unset.
125
     *                      </p>
126
     *
127
     * @return void
128
     */
129 1
    public function offsetUnset($offset)
130
    {
131 1
        throw new \BadMethodCallException('The result set is immutable');
132
    }
133
134
    /**
135
     * (PHP 5 &gt;= 5.0.0)<br/>
136
     * Return the current element
137
     *
138
     * @link http://php.net/manual/en/iterator.current.php
139
     * @return mixed Can return any type.
140
     */
141 1
    public function current()
142
    {
143 1
        $property = $this->properties[$this->currentPointer];
144
145 1
        return $this->jsonData->$property;
146
    }
147
148
    /**
149
     * (PHP 5 &gt;= 5.0.0)<br/>
150
     * Move forward to next element
151
     *
152
     * @link http://php.net/manual/en/iterator.next.php
153
     * @return void Any returned value is ignored.
154
     */
155 1
    public function next()
156
    {
157 1
        $this->currentPointer = $this->currentPointer + 1;
158 1
    }
159
160
    /**
161
     * (PHP 5 &gt;= 5.0.0)<br/>
162
     * Return the key of the current element
163
     *
164
     * @link http://php.net/manual/en/iterator.key.php
165
     * @return mixed scalar on success, or null on failure.
166
     */
167 1
    public function key()
168
    {
169 1
        return $this->properties[$this->currentPointer];
170
    }
171
172
    /**
173
     * (PHP 5 &gt;= 5.0.0)<br/>
174
     * Checks if current position is valid
175
     *
176
     * @link http://php.net/manual/en/iterator.valid.php
177
     * @return boolean The return value will be casted to boolean and then evaluated.
178
     *       Returns true on success or false on failure.
179
     */
180 1
    public function valid()
181
    {
182 1
        return isset($this->properties[$this->currentPointer]);
183
    }
184
185
    /**
186
     * (PHP 5 &gt;= 5.0.0)<br/>
187
     * Rewind the Iterator to the first element
188
     *
189
     * @link http://php.net/manual/en/iterator.rewind.php
190
     * @return void Any returned value is ignored.
191
     */
192 1
    public function rewind()
193
    {
194 1
        $this->currentPointer = 0;
195 1
    }
196
197
    /**
198
     * (PHP 5 &gt;= 5.1.0)<br/>
199
     * Count elements of an object
200
     *
201
     * @link http://php.net/manual/en/countable.count.php
202
     * @return int The custom count as an integer.
203
     *       </p>
204
     *       <p>
205
     *       The return value is cast to an integer.
206
     */
207 1
    public function count()
208
    {
209 1
        return $this->propertyCount;
210
    }
211
212
    /**
213
     * Returns the original value.
214
     *
215
     * @return mixed
216
     * @author Mario Mueller
217
     */
218 4
    public function getGatewayValue()
219
    {
220 4
        return $this->jsonData;
221
    }
222
}
223