This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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
|
|||
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 |
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.