Issues (37)

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.

lib/Metadata/PropertyMetadata.php (4 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 Flying\Struct\Metadata;
4
5
/**
6
 * Structure property metadata storage class
7
 */
8
class PropertyMetadata implements MetadataInterface
9
{
10
    /**
11
     * Hash for property object
12
     *
13
     * @var string
14
     */
15
    protected $hash;
16
    /**
17
     * Property name
18
     *
19
     * @var string
20
     */
21
    private $name;
22
    /**
23
     * Class name for property object
24
     *
25
     * @var string
26
     */
27
    private $class;
28
    /**
29
     * Configuration options for property object
30
     *
31
     * @var array
32
     */
33
    private $config = [];
34
35
    /**
36
     * Class constructor
37
     *
38
     * @param string $name  OPTIONAL Property name
39
     * @param string $class OPTIONAL Class name for property object
40
     * @param array $config OPTIONAL Configuration options for property object
41
     * @throws \InvalidArgumentException
42
     */
43 209
    public function __construct($name = null, $class = null, $config = null)
44
    {
45 209
        if ($name !== null) {
46 186
            $this->setName($name);
47 186
        }
48 209
        if ($class !== null) {
49 182
            $this->setClass($class);
50 182
        }
51 209
        if ($config !== null) {
52 182
            $this->setConfig($config);
53 182
        }
54 209
    }
55
56
    /**
57
     * Defined by Serializable interface
58
     *
59
     * @return string
60
     */
61 17 View Code Duplication
    public function serialize()
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...
62
    {
63 17
        return serialize([
64 17
            'name'   => $this->getName(),
65 17
            'class'  => $this->getClass(),
66 17
            'config' => $this->getConfig(),
67 17
        ]);
68
    }
69
70
    /**
71
     * Get property name
72
     *
73
     * @return mixed
74
     */
75 200
    public function getName()
76
    {
77 200
        return $this->name;
78
    }
79
80
    /**
81
     * Set property name
82
     *
83
     * @param string $name
84
     * @throws \InvalidArgumentException
85
     * @return $this
86
     */
87 200 View Code Duplication
    public function setName($name)
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...
88
    {
89 200
        if ((!is_string($name)) && ($name !== null)) {
90 2
            throw new \InvalidArgumentException('Property name must be a string');
91
        }
92 198
        $this->name = $name;
93 198
        $this->hash = null;
94 198
        return $this;
95
    }
96
97
    /**
98
     * Get class name for property object
99
     *
100
     * @return string
101
     */
102 196
    public function getClass()
103
    {
104 196
        return $this->class;
105
    }
106
107
    /**
108
     * Set class name for property object
109
     *
110
     * @param string $class
111
     * @throws \InvalidArgumentException
112
     * @return $this
113
     */
114 202 View Code Duplication
    public function setClass($class)
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...
115
    {
116 202
        if ((!is_string($class)) && ($class !== null)) {
117 2
            throw new \InvalidArgumentException('Property class name must be a string');
118
        }
119 200
        $this->class = $class;
120 200
        $this->hash = null;
121 200
        return $this;
122
    }
123
124
    /**
125
     * Get configuration options for property object
126
     *
127
     * @return array
128
     */
129 194
    public function getConfig()
130
    {
131 194
        return $this->config;
132
    }
133
134
    /**
135
     * Set configuration options for property object
136
     *
137
     * @param array $config
138
     * @return $this
139
     */
140 196
    public function setConfig(array $config)
141
    {
142 196
        $this->config = $config;
143 196
        $this->hash = null;
144 196
        return $this;
145
    }
146
147
    /**
148
     * Defined by Serializable interface
149
     *
150
     * @param string $serialized
151
     * @return void
152
     * @throws \InvalidArgumentException
153
     */
154 18
    public function unserialize($serialized)
155
    {
156 18
        $array = unserialize($serialized);
157 18
        if (!is_array($array)) {
158 1
            return;
159
        }
160 17
        if (array_key_exists('name', $array)) {
161 17
            $this->setName($array['name']);
162 17
        }
163 17
        if (array_key_exists('class', $array)) {
164 17
            $this->setClass($array['class']);
165 17
        }
166 17
        if (array_key_exists('config', $array)) {
167 17
            $this->setConfig($array['config']);
168 17
        }
169 17
    }
170
171
    /**
172
     * Get metadata information as array
173
     *
174
     * @return array
175
     */
176 14 View Code Duplication
    public function toArray()
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...
177
    {
178
        return [
179 14
            'name'   => $this->getName(),
180 14
            'class'  => $this->getClass(),
181 14
            'config' => $this->getConfig(),
182 14
            'hash'   => $this->getHash(),
183 14
        ];
184
    }
185
186
    /**
187
     * Get hash for this structure metadata item
188
     *
189
     * @return string
190
     */
191 94
    public function getHash()
192
    {
193 94
        if (!$this->hash) {
194 94
            $this->hash = sha1($this->getName() . $this->getClass() . serialize($this->getConfig()));
195 94
        }
196 94
        return $this->hash;
197
    }
198
}
199