Issues (7)

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

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
/**
4
 * PHP Client for DDN Web Object Scalar (WOS) API
5
 *
6
 * @package Wosclient
7
 * @author  Casey McLaughlin <[email protected]>
8
 * @license http://opensource.org/licenses/MIT MIT
9
 * @link    https://github.com/caseyamcl/wosclient
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 *
14
 * ------------------------------------------------------------------
15
 */
16
17
namespace WosClient;
18
19
use Countable;
20
use Psr\Http\Message\ResponseInterface;
21
use Traversable;
22
use WosClient\Helper\ArrayToMetadataStringTrait;
23
24
/**
25
 * Class WosObjectMetadata
26
 *
27
 * @author Casey McLaughlin <[email protected]>
28
 */
29
class WosObjectMetadata implements \IteratorAggregate, WosObjectMetadataInterface
30
{
31
    use ArrayToMetadataStringTrait;
32
33
    /**
34
     * Unknown value
35
     */
36
    const UNKNOWN = null;
37
38
    /**
39
     * @var array
40
     */
41
    private $metadata;
42
43
    /**
44
     * @var int
45
     */
46
    private $objectSize;
47
48
    /**
49
     * WosObjectMetadata constructor.
50
     *
51
     * @param ResponseInterface $httpResponse
52
     */
53
    public function __construct(ResponseInterface $httpResponse)
54
    {
55
        $this->metadata   = json_decode('{' . $httpResponse->getHeaderLine('x-ddn-meta') . '}', true);
0 ignored issues
show
Documentation Bug introduced by
It seems like json_decode('{' . $httpR...ddn-meta') . '}', true) of type * is incompatible with the declared type array of property $metadata.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
56
        $this->objectSize = $httpResponse->hasHeader('x-ddn-length')
57
            ? (int) $httpResponse->getHeaderLine('x-ddn-length')
58
            : self::UNKNOWN;
59
    }
60
61
    /**
62
     * Return representation of the metadata as it would appear as a x-ddn-metadata value
63
     *
64
     * @return mixed
65
     */
66
    public function __toString()
67
    {
68
        return $this->metadataToString($this->toArray());
69
    }
70
71
    /**
72
     * @param string $key
73
     * @return mixed
74
     */
75
    public function get($key)
76
    {
77
        return $this->offsetGet($key);
78
    }
79
80
    /**
81
     * @param string $key
82
     * @return bool
83
     */
84
    public function has($key)
85
    {
86
        return $this->offsetExists($key);
87
    }
88
89
    /**
90
     * @return array|mixed[]
91
     */
92
    public function toArray()
93
    {
94
        return $this->metadata;
95
    }
96
97
    /**
98
     * Returns data length in BYTES if known, NULL otherwise
99
     *
100
     * @return int|null
101
     */
102
    public function getObjectSize()
103
    {
104
        return $this->objectSize;
105
    }
106
107
    /**
108
     * Whether a offset exists
109
     *
110
     * @link   http://php.net/manual/en/arrayaccess.offsetexists.php
111
     * @param  mixed $offset <p>
112
     *                      An offset to check for.
113
     *                      </p>
114
     * @return boolean true on success or false on failure.
115
     *                      </p>
116
     *                      <p>
117
     *                      The return value will be casted to boolean if non-boolean was returned.
118
     * @since  5.0.0
119
     */
120
    public function offsetExists($offset)
121
    {
122
        return array_key_exists($offset, $this->metadata);
123
    }
124
125
    /**
126
     * Offset to retrieve
127
     *
128
     * @link   http://php.net/manual/en/arrayaccess.offsetget.php
129
     * @param  mixed $offset <p>
130
     *                      The offset to retrieve.
131
     *                      </p>
132
     * @return mixed Can return all value types.
133
     * @since  5.0.0
134
     */
135
    public function offsetGet($offset)
136
    {
137
        return $this->metadata[$offset];
138
    }
139
140
    /**
141
     * Offset to set
142
     *
143
     * @link   http://php.net/manual/en/arrayaccess.offsetset.php
144
     * @param  mixed $offset <p>
145
     *                      The offset to assign the value to.
146
     *                      </p>
147
     * @param  mixed $value  <p>
148
     *                      The value to set.
149
     *                      </p>
150
     * @return void
151
     * @since  5.0.0
152
     */
153
    public function offsetSet($offset, $value)
154
    {
155
        throw new \RuntimeException("Cannot set $offset for WosObjectMetadata.  Metadata is immutable");
156
    }
157
158
    /**
159
     * Offset to unset
160
     *
161
     * @link   http://php.net/manual/en/arrayaccess.offsetunset.php
162
     * @param  mixed $offset <p>
163
     *                      The offset to unset.
164
     *                      </p>
165
     * @return void
166
     * @since  5.0.0
167
     */
168
    public function offsetUnset($offset)
169
    {
170
        throw new \RuntimeException("Cannot unset $offset for WosObjectMetadata.  Metadata is immutable");
171
    }
172
173
    /**
174
     * Retrieve an external iterator
175
     *
176
     * @link   http://php.net/manual/en/iteratoraggregate.getiterator.php
177
     * @return Traversable An instance of an object implementing <b>Iterator</b> or
178
     *        <b>Traversable</b>
179
     * @since  5.0.0
180
     */
181
    public function getIterator()
182
    {
183
        return new \ArrayIterator($this->metadata);
184
    }
185
186
    /**
187
     * Count elements of an object
188
     *
189
     * @link   http://php.net/manual/en/countable.count.php
190
     * @return int The custom count as an integer.
191
     *        </p>
192
     *        <p>
193
     *        The return value is cast to an integer.
194
     * @since  5.1.0
195
     */
196
    public function count()
197
    {
198
        return count($this->metadata);
199
    }
200
}
201