Issues (1704)

Branch: master

Security Analysis    not enabled

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.

BusinessEntityBundle/Entity/BusinessProperty.php (8 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 Victoire\Bundle\BusinessEntityBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * @ORM\Entity(repositoryClass="Victoire\Bundle\BusinessEntityBundle\Entity\BusinessPropertyRepository")
9
 * @ORM\Table("vic_business_property")
10
 */
11
class BusinessProperty
12
{
13
    /**
14
     * @var int
15
     *
16
     * @ORM\Column(name="id", type="integer")
17
     * @ORM\Id
18
     * @ORM\GeneratedValue(strategy="AUTO")
19
     */
20
    protected $id;
21
22
    /**
23
     * @var string
24
     *
25
     * @ORM\Column(name="types", type="text", nullable=true)
26
     */
27
    protected $types = null;
28
29
    /**
30
     * @var string
31
     *
32
     * @ORM\Column(name="name", type="string", length=255, nullable=true)
33
     */
34
    protected $name = null;
35
36
    /**
37
     * @ORM\ManyToOne(targetEntity="Victoire\Bundle\BusinessEntityBundle\Entity\BusinessEntity", inversedBy="businessProperties")
38
     */
39
    protected $businessEntity;
40
41
    /**
42
     * @var array
43
     *
44
     * @ORM\Column(name="choices", type="text", nullable=true)
45
     */
46
    protected $choices;
47
48
    /**
49
     * @var string
50
     *
51
     * @ORM\Column(name="listMethod", type="text", nullable=true)
52
     */
53
    protected $listMethod;
54
55
    /**
56
     * @var string
57
     *
58
     * @ORM\Column(name="filterMethod", type="text", nullable=true)
59
     */
60
    protected $filterMethod;
61
62
    /**
63
     * Set the type.
64
     *
65
     * @param string $types
66
     */
67 View Code Duplication
    public function setTypes($types)
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...
68
    {
69
        $data = @unserialize($types);
70
        if ($types === 'b:0;' || $data !== false) {
71
            $this->types = $types;
72
        } else {
73
            $this->types = serialize($types);
74
        }
75
    }
76
77
    /**
78
     * @return string the type of business property
79
     */
80
    public function getTypes()
81
    {
82
        if (!$this->types) {
83
            return [];
0 ignored issues
show
Bug Best Practice introduced by
The return type of return array(); (array) is incompatible with the return type documented by Victoire\Bundle\Business...inessProperty::getTypes of type string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
84
        }
85
86
        return unserialize($this->types);
87
    }
88
89
    /**
90
     * Display object as string.
91
     *
92
     * @return string
93
     */
94
    public function __toString()
95
    {
96
        return $this->name;
97
    }
98
99
    /**
100
     * @return BusinessEntity
101
     */
102
    public function getBusinessEntity()
103
    {
104
        return $this->businessEntity;
105
    }
106
107
    /**
108
     * @param BusinessEntity $businessEntity
109
     */
110
    public function setBusinessEntity(BusinessEntity $businessEntity)
111
    {
112
        $this->businessEntity = $businessEntity;
113
        $businessEntity->addBusinessProperty($this);
114
    }
115
116
    /**
117
     * @return int
118
     */
119
    public function getId()
120
    {
121
        return $this->id;
122
    }
123
124
    /**
125
     * @return string
126
     */
127
    public function getName()
128
    {
129
        return $this->name;
130
    }
131
132
    /**
133
     * @param string $name
134
     */
135
    public function setName($name)
136
    {
137
        $this->name = $name;
138
    }
139
140
    /**
141
     * Set the choices.
142
     *
143
     * @param string $choices
144
     */
145 View Code Duplication
    public function setChoices($choices)
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...
146
    {
147
        $data = @unserialize($choices);
148
        if ($choices === 'b:0;' || $data !== false) {
149
            $this->choices = $choices;
0 ignored issues
show
Documentation Bug introduced by
It seems like $choices of type string is incompatible with the declared type array of property $choices.

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...
150
        } else {
151
            $this->choices = serialize($choices);
0 ignored issues
show
Documentation Bug introduced by
It seems like serialize($choices) of type string is incompatible with the declared type array of property $choices.

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...
152
        }
153
    }
154
155
    /**
156
     * @return string the choice of business property
157
     */
158
    public function getChoices()
159
    {
160
        if (!$this->choices) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->choices of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
161
            return [];
0 ignored issues
show
Bug Best Practice introduced by
The return type of return array(); (array) is incompatible with the return type documented by Victoire\Bundle\Business...essProperty::getChoices of type string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
162
        }
163
164
        return unserialize($this->choices);
165
    }
166
167
    /**
168
     * @return string
169
     */
170
    public function getListMethod()
171
    {
172
        return $this->listMethod;
173
    }
174
175
    /**
176
     * @param string $listMethod
177
     */
178
    public function setListMethod($listMethod)
179
    {
180
        $this->listMethod = $listMethod;
181
    }
182
183
    /**
184
     * @return string
185
     */
186
    public function getFilterMethod()
187
    {
188
        return $this->filterMethod;
189
    }
190
191
    /**
192
     * @param string $filterMethod
193
     */
194
    public function setFilterMethod($filterMethod)
195
    {
196
        $this->filterMethod = $filterMethod;
197
    }
198
199
    /**
200
     * @param string $type
201
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
202
    public function hasType($type)
203
    {
204
        return in_array($type, $this->getTypes());
205
    }
206
}
207