Issues (150)

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

Labels
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
3
namespace AMQPAL;
4
5
use Traversable;
6
7
/**
8
 * Class AbstractOptions
9
 *
10
 * @package AMQPAL\Adapter
11
 */
12
abstract class AbstractOptions
13
{
14
    /**
15
     * Constructor
16
     *
17
     * @param  array|Traversable|null $options
18
     * @throws Exception\InvalidArgumentException
19
     * @throws Exception\BadMethodCallException
20
     */
21 25
    public function __construct($options = null)
22
    {
23 25
        if (null !== $options) {
24 20
            $this->setFromArray($options);
25
        }
26 25
    }
27
28
    /**
29
     * Set one or more configuration properties
30
     *
31
     * @param  array|Traversable|AbstractOptions $options
32
     * @throws Exception\InvalidArgumentException
33
     * @return AbstractOptions Provides fluent interface
34
     * @throws Exception\BadMethodCallException
35
     */
36 24
    public function setFromArray($options)
37
    {
38 24
        if ($options instanceof self) {
39
            $options = $options->toArray();
40
        }
41
42 24
        if (!is_array($options) && !$options instanceof Traversable) {
43
            throw new Exception\InvalidArgumentException(
44
                sprintf(
45
                    'Parameter provided to %s must be an %s, %s or %s',
46
                    __METHOD__,
47
                    'array',
48
                    'Traversable',
49
                    'Zend\Stdlib\AbstractOptions'
50
                )
51
            );
52
        }
53
54 24
        foreach ($options as $key => $value) {
55 24
            $this->__set($key, $value);
56
        }
57
58 24
        return $this;
59
    }
60
61
    /**
62
     * Cast to array
63
     *
64
     * @return array
65
     */
66
    public function toArray()
67
    {
68
        $array = [];
69
        $transform = function ($letters) {
70
            $letter = array_shift($letters);
71
            return '_' . strtolower($letter);
72
        };
73
        foreach ($this as $key => $value) {
0 ignored issues
show
The expression $this of type this<AMQPAL\AbstractOptions> is not traversable.
Loading history...
74
            $normalizedKey = preg_replace_callback('/([A-Z])/', $transform, $key);
75
            $array[$normalizedKey] = $value;
76
        }
77
        return $array;
78
    }
79
80
    /**
81
     * Set a configuration property
82
     *
83
     * @see ParameterObject::__set()
84
     * @param string $key
85
     * @param mixed $value
86
     * @throws Exception\BadMethodCallException
87
     * @return void
88
     */
89 24
    public function __set($key, $value)
90
    {
91 24
        $setter = 'set' . str_replace('_', '', $key);
92
93 24
        if (is_callable([$this, $setter])) {
94 24
            $this->{$setter}($value);
95
96 24
            return;
97
        }
98
99
        throw new Exception\BadMethodCallException(sprintf(
100
            'The option "%s" does not have a callable "%s" ("%s") setter method which must be defined',
101
            $key,
102
            'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))),
103
            $setter
104
        ));
105
    }
106
107
    /**
108
     * Get a configuration property
109
     *
110
     * @see ParameterObject::__get()
111
     * @param string $key
112
     * @throws Exception\BadMethodCallException
113
     * @return mixed
114
     */
115
    public function __get($key)
116
    {
117
        $getter = 'get' . str_replace('_', '', $key);
118
119
        if (is_callable([$this, $getter])) {
120
            return $this->{$getter}();
121
        }
122
123
        throw new Exception\BadMethodCallException(sprintf(
124
            'The option "%s" does not have a callable "%s" getter method which must be defined',
125
            $key,
126
            'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key)))
127
        ));
128
    }
129
130
    /**
131
     * Test if a configuration property is null
132
     * @see ParameterObject::__isset()
133
     * @param string $key
134
     * @return bool
135
     * @throws Exception\BadMethodCallException
136
     */
137
    public function __isset($key)
138
    {
139
        $getter = 'get' . str_replace('_', '', $key);
140
141
        return method_exists($this, $getter) && null !== $this->__get($key);
142
    }
143
144
    /**
145
     * Set a configuration property to NULL
146
     *
147
     * @see ParameterObject::__unset()
148
     * @param string $key
149
     * @throws Exception\InvalidArgumentException
150
     * @return void
151
     */
152
    public function __unset($key)
153
    {
154
        try {
155
            $this->__set($key, null);
156
        } catch (Exception\BadMethodCallException $e) {
157
            throw new Exception\InvalidArgumentException(
158
                'The class property $' . $key . ' cannot be unset as'
159
                . ' NULL is an invalid value for it',
160
                0,
161
                $e
162
            );
163
        }
164
    }
165
}
166