Issues (114)

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/Entity.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 Analogue\ORM;
4
5
use Analogue\ORM\System\Proxies\EntityProxy;
6
7
class Entity extends ValueObject
8
{
9
    /**
10
     * Entities Hidden Attributes, that will be discarded when converting
11
     * the entity to Array/Json
12
     * (can include any embedded object's attribute)
13
     *
14
     * @var array
15
     */
16
    protected $hidden = [];
17
18
    /**
19
     * Return the entity's attribute
20
     * @param  string $key
21
     * @return mixed
22
     */
23
    public function __get($key)
24
    {
25
        if ($this->hasGetMutator($key)) {
26
            $method = 'get' . $this->getMutatorMethod($key);
27
28
            $attribute = null;
29
30
            if (isset($this->attributes[$key])) {
31
                $attribute = $this->attributes[$key];
32
            }
33
34
            return $this->$method($attribute);
35
        }
36
        if (!array_key_exists($key, $this->attributes)) {
37
            return null;
38
        }
39
        if ($this->attributes[$key] instanceof EntityProxy) {
40
            $this->attributes[$key] = $this->attributes[$key]->load();
41
        }
42
        return $this->attributes[$key];
43
    }
44
45
    /**
46
     * Dynamically set attributes on the entity.
47
     *
48
     * @param  string $key
49
     * @param  mixed  $value
50
     * @return void
51
     */
52
    public function __set($key, $value)
53
    {
54
        if ($this->hasSetMutator($key)) {
55
            $method = 'set' . $this->getMutatorMethod($key);
56
57
            $this->$method($value);
58
        } else {
59
            $this->attributes[$key] = $value;
60
        }
61
    }
62
63
    /**
64
     * Is a getter method defined ?
65
     *
66
     * @param  string $key
67
     * @return boolean
68
     */
69
    protected function hasGetMutator($key)
70
    {
71
        return method_exists($this, 'get' . $this->getMutatorMethod($key)) ? true : false;
72
    }
73
74
    /**
75
     * Is a setter method defined ?
76
     *
77
     * @param  string $key
78
     * @return boolean
79
     */
80
    protected function hasSetMutator($key)
81
    {
82
        return method_exists($this, 'set' . $this->getMutatorMethod($key)) ? true : false;
83
    }
84
85
    /**
86
     * @param $key
87
     * @return string
88
     */
89
    protected function getMutatorMethod($key)
90
    {
91
        $key = ucwords(str_replace(['-', '_'], ' ', $key));
92
        return str_replace(' ', '', $key) . "Attribute";
93
    }
94
95
    /**
96
     * Convert every attributes to value / arrays
97
     *
98
     * @return array
99
     */
100
    public function toArray()
101
    {
102
        // First, call the trait method before filtering
103
        // with Entity specific methods
104
        $attributes = $this->attributesToArray($this->attributes);
105
106 View Code Duplication
        foreach ($this->attributes as $key => $attribute) {
0 ignored issues
show
This code seems to be duplicated across 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...
107
            if (in_array($key, $this->hidden)) {
108
                unset($attributes[$key]);
109
                continue;
110
            }
111
            if ($this->hasGetMutator($key)) {
112
                $method = 'get' . $this->getMutatorMethod($key);
113
                $attributes[$key] = $this->$method($attribute);
114
            }
115
        }
116
        return $attributes;
117
    }
118
119
    /**
120
     * Fill an entity with key-value pairs
121
     * 
122
     * @param  array  $attributes 
123
     * @return void
124
     */
125
    public function fill(array $attributes)
126
    {
127 View Code Duplication
        foreach ($attributes as $key => $attribute) {
0 ignored issues
show
This code seems to be duplicated across 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...
128
            
129
            if ($this->hasSetMutator($key)) {
130
                $method = 'set' . $this->getMutatorMethod($key);
131
                $this->attributes[$key] = $this->$method($attribute);
132
            }
133
            else {
134
                $this->attributes[$key] = $attribute;
135
            }
136
        }
137
    }
138
}
139