Issues (4)

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/Value.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
namespace Colada\X;
4
5
use ArrayAccess;
6
use BadMethodCallException;
7
8
/**
9
 * Immutable value wrapper
10
 *
11
 * @author Alexey Shokov <[email protected]>
12
 */
13
class Value implements ArrayAccess, ValueWrapper
14
{
15
    /**
16
     * @var mixed
17
     */
18
    private $value;
19
20
    /**
21
     * @return \Closure
22
     */
23
    public static function getConstructorForValue()
24
    {
25
        return function ($value) {
26
            return new static($value);
27
        };
28
    }
29
30
    /**
31
     * @param mixed $value
32
     */
33
    public function __construct($value = null)
34
    {
35
        $this->value = $value;
36
    }
37
38
    /**
39
     * @return mixed
40
     */
41
    public function __getWrappedValue()
42
    {
43
        return $this->value;
44
    }
45
46
    /**
47
     * @param mixed $key
48
     *
49
     * @return static
50
     */
51 View Code Duplication
    public function offsetGet($key)
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...
52
    {
53
        if (is_array_accessible($this->value)) {
54
            return new static($this->value[$key]);
55
        }
56
57
        throw new BadMethodCallException('ArrayAccess unsupported for current value.');
58
    }
59
60
    /**
61
     * @param mixed $key
62
     *
63
     * @return void
64
     */
65
    public function offsetUnset($key)
66
    {
67
        if (is_array_accessible($this->value)) {
68
            unset($this->value[$key]);
69
70
            return;
71
        }
72
73
        throw new BadMethodCallException('ArrayAccess unsupported for current value.');
74
    }
75
76
    /**
77
     * @param mixed $key
78
     *
79
     * @return bool
80
     */
81
    public function offsetExists($key)
82
    {
83
        if (is_array_accessible($this->value)) {
84
            return isset($this->value[$key]);
85
        }
86
87
        throw new BadMethodCallException('ArrayAccess unsupported for current value.');
88
    }
89
90
    /**
91
     * @param mixed $key
92
     * @param mixed $value
93
     *
94
     * @return void
95
     */
96 View Code Duplication
    public function offsetSet($key, $value)
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...
97
    {
98
        if (is_array_accessible($this->value)) {
99
            $this->value[$key] = $value;
100
101
            return;
102
        }
103
104
        throw new BadMethodCallException('ArrayAccess unsupported for current value.');
105
    }
106
107
    /**
108
     * @param string $field
109
     *
110
     * @return static
111
     */
112
    public function __get($field)
113
    {
114
        if (is_object($this->value)) {
115
            return new static($this->value->$field);
116
        }
117
118
        throw new BadMethodCallException('__get() is unsupported for current value.');
119
    }
120
121
    /**
122
     * @param string $field
123
     * @param mixed $value
124
     *
125
     * @return void Result is always the assigned value.
126
     */
127
    public function __set($field, $value)
128
    {
129
        if (is_object($this->value)) {
130
            $this->value->$field = $value;
131
        }
132
133
        throw new BadMethodCallException('__set() is unsupported for current value.');
134
    }
135
136
    public function __isset($field)
137
    {
138
        if (is_object($this->value)) {
139
            return isset($this->value->$field);
140
        }
141
142
        throw new BadMethodCallException('__isset() is unsupported for current value.');
143
    }
144
145
    public function __unset($field)
146
    {
147
        if (is_object($this->value)) {
148
            unset($this->value->$field);
149
150
            return;
151
        }
152
153
        throw new BadMethodCallException('__unset() is unsupported for current value.');
154
    }
155
156
    /**
157
     * @param string $name
158
     * @param array $arguments
159
     *
160
     * @return static
161
     */
162
    public function __call($name, $arguments)
163
    {
164
        if (is_object($this->value) && is_callable([$this->value, $name])) {
165
            $method = [$this->value, $name];
166
        } else {
167
            throw new BadMethodCallException('Unknown method "' . $name . '"');
168
        }
169
170
        $result = call_user_func_array($method, $arguments);
171
172
        return new static($result);
173
    }
174
175
    /**
176
     * @return string
177
     */
178
    public function __toString()
179
    {
180
        // For objects without __toString() an exception will be thrown. This is OK, because the same will happen if
181
        // __toString() is called directly on them.
182
        return (string) $this->value;
183
    }
184
}
185