Issues (19)

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.

Mapping/ClassMetadata.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
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Cubiche\Core\Validator\Mapping;
13
14
use Cubiche\Core\Validator\Assert;
15
use Metadata\ClassMetadata as BaseClassMetadata;
16
17
/**
18
 * ClassMetadata class.
19
 *
20
 * @author Ivannis Suárez Jerez <[email protected]>
21
 */
22
class ClassMetadata extends BaseClassMetadata
23
{
24
    /**
25
     * @var string
26
     */
27
    public $defaultGroup;
28
29
    /**
30
     * @return string
31
     */
32
    public function getClassName()
33
    {
34
        return $this->name;
35
    }
36
37
    /**
38
     * @param string $property
39
     *
40
     * @return PropertyMetadata|null
41
     */
42
    protected function getPropertyMetadata($property)
43
    {
44
        return isset($this->propertyMetadata[$property]) ? $this->propertyMetadata[$property] : null;
45
    }
46
47
    /**
48
     * @param string $property
49
     * @param Assert $constraint
50
     * @param string $group
51
     */
52 View Code Duplication
    public function addPropertyConstraint($property, Assert $constraint, $group = null)
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...
53
    {
54
        $propertyMetadata = $this->getPropertyMetadata($property);
55
        if ($propertyMetadata === null) {
56
            $propertyMetadata = new PropertyMetadata($this->getClassName(), $property);
57
            $propertyMetadata->defaultGroup = $this->defaultGroup;
58
        }
59
60
        $propertyMetadata->addConstraint($constraint, $group);
61
62
        $this->addPropertyMetadata($propertyMetadata);
63
    }
64
65
    /**
66
     * @param string $property
67
     * @param array  $constraints
68
     * @param string $group
69
     */
70
    public function addPropertyConstraints($property, array $constraints, $group = null)
71
    {
72
        foreach ($constraints as $constraint) {
73
            $this->addPropertyConstraint($property, $constraint, $group);
74
        }
75
    }
76
77
    /**
78
     * @return PropertyMetadata[]
79
     */
80
    public function getPropertiesMetadata()
81
    {
82
        return $this->propertyMetadata;
83
    }
84
85
    /**
86
     * @param string $method
87
     *
88
     * @return MethodMetadata|null
89
     */
90
    protected function getMethodMetadata($method)
91
    {
92
        return isset($this->methodMetadata[$method]) ? $this->methodMetadata[$method] : null;
93
    }
94
95
    /**
96
     * @param string $method
97
     * @param Assert $constraint
98
     * @param string $group
99
     */
100 View Code Duplication
    public function addMethodConstraint($method, Assert $constraint, $group = null)
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...
101
    {
102
        $methodMetadata = $this->getMethodMetadata($method);
103
        if ($methodMetadata === null) {
104
            $methodMetadata = new MethodMetadata($this->getClassName(), $method);
105
            $methodMetadata->defaultGroup = $this->defaultGroup;
106
        }
107
108
        $methodMetadata->addConstraint($constraint, $group);
109
110
        $this->addMethodMetadata($methodMetadata);
111
    }
112
113
    /**
114
     * @param string $method
115
     * @param array  $constraints
116
     * @param string $group
117
     */
118
    public function addMethodConstraints($method, array $constraints, $group = null)
119
    {
120
        foreach ($constraints as $constraint) {
121
            $this->addMethodConstraint($method, $constraint, $group);
122
        }
123
    }
124
125
    /**
126
     * @return MethodMetadata[]
127
     */
128
    public function getMethodsMetadata()
129
    {
130
        return $this->methodMetadata;
131
    }
132
133
    /**
134
     * Merges the constraints of the given metadata into this object.
135
     *
136
     * @param ClassMetadata $source
137
     */
138
    public function mergeConstraints(ClassMetadata $source)
139
    {
140
        foreach ($source->getPropertiesMetadata() as $property => $propertyMetadata) {
141
            foreach ($propertyMetadata->getConstraints() as $group => $constraints) {
142
                $this->addPropertyConstraints($property, $constraints, $group);
143
            }
144
        }
145
146
        foreach ($source->getMethodsMetadata() as $method => $methodMetadata) {
147
            foreach ($methodMetadata->getConstraints() as $group => $constraints) {
148
                $this->addMethodConstraints($method, $constraints, $group);
149
            }
150
        }
151
    }
152
153
    /**
154
     * {@inheritdoc}
155
     */
156
    public function serialize()
157
    {
158
        return serialize(array(
159
            $this->name,
160
            $this->methodMetadata,
161
            $this->propertyMetadata,
162
            $this->fileResources,
163
            $this->createdAt,
164
            $this->defaultGroup,
165
        ));
166
    }
167
168
    /**
169
     * {@inheritdoc}
170
     */
171
    public function unserialize($str)
172
    {
173
        list(
174
            $this->name,
175
            $this->methodMetadata,
176
            $this->propertyMetadata,
177
            $this->fileResources,
178
            $this->createdAt,
179
            $this->defaultGroup) = unserialize($str);
180
181
        $this->reflection = new \ReflectionClass($this->name);
182
    }
183
}
184