Issues (28)

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.

src/AppBundle/Entity/Trigger.php (1 issue)

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 AppBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * @ORM\Entity
9
 * @ORM\Table(name="triggers")
10
 */
11
class Trigger
12
{
13
14
    public $allowedOperators = [
15
        '>', '<', '>=', '<=', '==', '!='
16
    ];
17
18
    /**
19
     * @ORM\Column(type="integer")
20
     * @ORM\Id
21
     * @ORM\GeneratedValue(strategy="AUTO")
22
     */
23
    private $id;
24
25
    /**
26
     * @ORM\Column(type="string", length=100)
27
     */
28
    private $name;
29
30
    /**
31
     * @return boolean
32
     */
33
    public function getIsEnabled()
34
    {
35
        return $this->isEnabled;
36
    }
37
38
    /**
39
     * @param boolean $isEnabled
40
     * @return Trigger
41
     */
42 1
    public function setIsEnabled($isEnabled)
43
    {
44 1
        $this->isEnabled = $isEnabled;
45 1
        return $this;
46
    }
47
48
    /**
49
     * @ORM\Column(type="boolean")
50
     */
51
    private $isEnabled = true;
52
53
    /**
54
     * @ORM\Column(type="string", length = 2)
55
     */
56
    private $sign;
57
58
    /**
59
     * @ORM\Column(type="string", length = 100)
60
     */
61
    private $value;
62
63
64 1
    public function getExpression()
65
    {
66 1
        return $this->sign.''.$this->value;
67
    }
68
69
    /**
70
     * @ORM\Column(type="boolean")
71
     */
72
    private $state = false;
73
74
    /**
75
     * @var Variable
76
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Variable", inversedBy="triggers")
77
     */
78
    public $variable;
79
80
    /**
81
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Action", inversedBy="activateTriggers")
82
     */
83
    public $onActivate;
84
85
    /**
86
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Action", inversedBy="deactivateTriggers")
87
     */
88
    public $onDeactivate;
89
90
    /** @ORM\Column(type="text") */
91
    public $activateParams;
92
    /** @ORM\Column(type="text") */
93
    public $deactivateParams;
94
95
    /**
96
     * @param $state boolean
97
     * @return Trigger
98
     */
99 1
    public function setState($state)
100
    {
101 1
        $this->state = !!$state;
102 1
        return $this;
103
    }
104
105 1
    public function getState()
106
    {
107 1
        return $this->state;
108
    }
109
110
    /**
111
     * @return mixed
112
     */
113 1
    public function getSign()
114
    {
115 1
        return $this->sign;
116
    }
117
118
    /**
119
     * @param mixed $sign
120
     */
121 1
    public function setSign($sign)
122
    {
123 1
        $this->sign = $sign;
124 1
    }
125
126
    /**
127
     * @return mixed
128
     */
129 1
    public function getValue()
130
    {
131 1
        return $this->value;
132
    }
133
134
    /**
135
     * @param mixed $value
136
     */
137 1
    public function setValue($value)
138
    {
139 1
        $this->value = $value;
140 1
    }
141
142
143
    /**
144
     * @return mixed
145
     */
146
    public function getId()
147
    {
148
        return $this->id;
149
    }
150
151
    /**
152
     * @param mixed $id
153
     * @return Trigger
154
     */
155
    public function setId($id)
156
    {
157
        $this->id = $id;
158
        return $this;
159
    }
160
161
    /**
162
     * @return mixed
163
     */
164
    public function getName()
165
    {
166
        return $this->name;
167
    }
168
169
    /**
170
     * @param string $name
171
     * @return Trigger
172
     */
173 1
    public function setName($name)
174
    {
175 1
        $this->name = $name;
176 1
        return $this;
177
    }
178
179 1
    public function checkState()
180
    {
181 1
        $value = $this->getVariable()->getValue();
182
183 1
        if (!is_numeric($this->getValue())) {
184
            return false;
185
        }
186 1
        if (!in_array($this->getSign(), $this->allowedOperators)) {
187
            return false;
188
        }
189
190 1
        return (bool) eval('return '.$value.' '.$this->getExpression().';');
0 ignored issues
show
It is generally not recommended to use eval unless absolutely required.

On one hand, eval might be exploited by malicious users if they somehow manage to inject dynamic content. On the other hand, with the emergence of faster PHP runtimes like the HHVM, eval prevents some optimization that they perform.

Loading history...
191
    }
192
193
    /**
194
     * @return Variable
195
     */
196 1
    public function getVariable()
197
    {
198 1
        return $this->variable;
199
    }
200
201
    /**
202
     * @param mixed $variable
203
     * @return Trigger
204
     */
205 1
    public function setVariable($variable)
206
    {
207 1
        $this->variable = $variable;
208 1
        return $this;
209
    }
210
211
    public function __toString()
212
    {
213
        return $this->getName().($this->getState() ? ' (on)' : ' (off)');
214
    }
215
}
216