Issues (1039)

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/Entity/MissionGame.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
namespace PlaygroundGame\Entity;
3
4
use Doctrine\Common\Collections\ArrayCollection;
5
use Doctrine\ORM\Mapping as ORM;
6
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
7
use Doctrine\ORM\Mapping\PrePersist;
8
use Doctrine\ORM\Mapping\PreUpdate;
9
use Zend\InputFilter\InputFilter;
10
use Zend\InputFilter\InputFilterAwareInterface;
11
use Zend\InputFilter\InputFilterInterface;
12
use Zend\InputFilter\Factory as InputFactory;
13
14
/**
15
 * @ORM\Entity @HasLifecycleCallbacks
16
 * @ORM\Table(name="game_mission_game")
17
 */
18
class MissionGame implements InputFilterAwareInterface
19
{
20
    protected $inputFilter;
21
    
22
    /**
23
     * @ORM\Id
24
     * @ORM\Column(type="integer");
25
     * @ORM\GeneratedValue(strategy="AUTO")
26
     */
27
    protected $id;
28
29
    /**
30
    * @ORM\ManyToOne(targetEntity="PlaygroundGame\Entity\Game")
31
    * @ORM\JoinColumn(name="game_id", referencedColumnName="id", onDelete="CASCADE")
32
    **/
33
    protected $game;
34
35
    /**
36
     * @ORM\ManyToOne(targetEntity="Mission", inversedBy="missionGames")
37
     * @ORM\JoinColumn(name="mission_id", referencedColumnName="id", onDelete="CASCADE")
38
     *
39
     **/
40
    protected $mission;
41
    
42
    /**
43
     * @ORM\OneToMany(targetEntity="MissionGameCondition", mappedBy="missionGame", cascade={"persist","remove"})
44
     */
45
    protected $conditions;
46
47
    /**
48
     * position
49
     * @ORM\Column(name="position", type="integer", nullable=false)
50
     */
51
    protected $position;
52
53
    /**
54
     * @ORM\Column(name="created_at", type="datetime", nullable=true)
55
     */
56
    protected $createdAt;
57
58
    /**
59
     * @ORM\Column(name="updated_at", type="datetime", nullable=true)
60
     */
61
    protected $updatedAt;
62
63
    /**
64
     * Constructor
65
     */
66
    public function __construct()
67
    {
68
        $this->conditions = new ArrayCollection();
69
    }
70
71
    public function __clone()
72
    {
73
        $this->conditions = new ArrayCollection();
74
    }
75
76
    /** @PrePersist */
77
    public function createChrono()
78
    {
79
        $this->createdAt = new \DateTime("now");
80
        $this->updatedAt = new \DateTime("now");
81
    }
82
83
    /** @PreUpdate */
84
    public function updateChrono()
85
    {
86
        $this->updatedAt = new \DateTime("now");
87
    }
88
89
    /**
90
     * @param $id
91
     * @return MissionGame
92
     */
93
    public function setId($id)
94
    {
95
        $this->id = (int) $id;
96
97
        return $this;
98
    }
99
100
    /**
101
     * @return integer
102
     */
103
    public function getId()
104
    {
105
        return $this->id;
106
    }
107
108
    /**
109
    * @param $id
110
    * @return MissionGame
111
    */
112
    public function setPosition($position)
113
    {
114
        $this->position = (int) $position;
115
116
        return $this;
117
    }
118
119
    /**
120
     * @return integer
121
     */
122
    public function getPosition()
123
    {
124
        return $this->position;
125
    }
126
127
    /**
128
     * @return the $game
129
     */
130
    public function getGame()
131
    {
132
        return $this->game;
133
    }
134
135
    /**
136
     * @param field_type $game
137
     */
138
    public function setGame($game)
139
    {
140
        $this->game = $game;
141
142
        return $this;
143
    }
144
145
    /**
146
     * @return \PlaygroundGame\Service\Mission $game
147
     */
148
    public function getMission()
149
    {
150
        return $this->mission;
151
    }
152
153
    /**
154
     * @param \PlaygroundGame\Service\Mission $mission
155
     */
156
    public function setMission($mission)
157
    {
158
        $this->mission = $mission;
159
160
        return $this;
161
    }
162
  
163
    /**
164
     * @return the $conditions
165
     */
166
    public function getConditions()
167
    {
168
        return $this->conditions;
169
    }
170
171
    /**
172
     * @param field_type $conditions
173
     */
174
    public function setConditions($conditions)
175
    {
176
        $this->conditions = $conditions;
177
        
178
        return $this;
179
    }
180
    
181
    public function addConditions(ArrayCollection $conditions)
182
    {
183
        foreach ($conditions as $condition) {
184
            $condition->setMissionGame($this);
185
            $this->conditions->add($condition);
186
        }
187
    }
188
    
189
    public function removeConditions(ArrayCollection $conditions)
190
    {
191
        foreach ($conditions as $condition) {
192
            $this->conditions->removeElement($condition);
193
        }
194
    }
195
    
196
    /**
197
     * Add a condition to the mission game.
198
     *
199
     * @param MisionGameCondition $condition
200
     *
201
     * @return void
202
     */
203
    public function addCondition($condition)
204
    {
205
        $this->conditions[] = $condition;
206
    }
207
208
    /**
209
     *
210
     * @return \DateTime $createdAt
211
     */
212
    public function getCreatedAt()
213
    {
214
        return $this->createdAt;
215
    }
216
217
    /**
218
     *
219
     * @param \DateTime $createdAt
220
     */
221
    public function setCreatedAt($createdAt)
222
    {
223
        $this->createdAt = $createdAt;
224
        
225
        return $this;
226
    }
227
228
    /**
229
     *
230
     * @return \DateTime $updatedAt
231
     */
232
    public function getUpdatedAt()
233
    {
234
        return $this->updatedAt;
235
    }
236
237
    /**
238
     *
239
     * @param \DateTime $updatedAt
240
     */
241
    public function setUpdatedAt($updatedAt)
242
    {
243
        $this->updatedAt = $updatedAt;
244
        
245
        return $this;
246
    }
247
248
    /**
249
     * Are the conditions linked to this game fulfilled ?
250
     *
251
     * @return boolean
252
     */
253
    public function fulfillConditions($entry = null)
254
    {
255
        foreach ($this->getConditions() as $condition) {
256
            if ($condition->getAttribute() == MissionGameCondition::NONE) {
257
                continue;
258
            }
259
    
260
            // On passe au suivant si on a gagné
261
            if ($condition->getAttribute() == MissionGameCondition::VICTORY) {
262
                if (!$entry || !$entry->getWinner()) {
263
                    return false;
264
                }
265
            }
266
    
267
            // On passe au suivant si on a perdu
268
            if ($condition->getAttribute() == MissionGameCondition::DEFEAT) {
269
                if (!$entry || $entry->getWinner()) {
270
                    return false;
271
                }
272
            }
273
    
274
            // On passe au suivant si on a plus de n points
275
            if ($condition->getAttribute() == MissionGameCondition::GREATER) {
276
                if (!$entry || !($entry->getPoints() >= $condition->getValue())) {
277
                    return false;
278
                }
279
            }
280
    
281
            // On passe au suivant si on a moins de n points
282
            if ($condition->getAttribute() == MissionGameCondition::LESS) {
283
                if (!$entry || !($entry->getPoints() < $condition->getValue())) {
284
                    return false;
285
                }
286
            }
287
        }
288
289
        return true;
290
    }
291
292
    public function setInputFilter(InputFilterInterface $inputFilter)
293
    {
294
        throw new \Exception("Not used");
295
    }
296
297 View Code Duplication
    public function getInputFilter()
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...
298
    {
299
        if (! $this->inputFilter) {
300
            $inputFilter = new InputFilter();
301
            $factory = new InputFactory();
302
303
            $inputFilter->add($factory->createInput(array(
304
                'name' => 'game',
305
                'required' => false,
306
            )));
307
            $this->inputFilter = $inputFilter;
308
        }
309
    
310
        return $this->inputFilter;
311
    }
312
}
313