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/Mission.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
namespace PlaygroundGame\Entity;
3
4
use PlaygroundGame\Entity\Game;
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\Mapping as ORM;
7
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
8
use Zend\InputFilter\InputFilter;
9
use Zend\InputFilter\Factory as InputFactory;
10
use Zend\InputFilter\InputFilterAwareInterface;
11
12
/**
13
 * @ORM\Entity @HasLifecycleCallbacks
14
 * @ORM\Table(name="game_mission")
15
 */
16
class Mission extends Game implements InputFilterAwareInterface
17
{
18
    const CLASSTYPE = 'mission';
19
    
20
    /**
21
     * @ORM\OneToMany(targetEntity="MissionGame", mappedBy="mission", cascade={"persist","remove"}, orphanRemoval=true)
22
     */
23
    protected $missionGames;
24
25
    public function __construct()
26
    {
27
        parent::__construct();
28
        $this->setClassType(self::CLASSTYPE);
29
        $this->missionGames = new ArrayCollection();
30
    }
31
32
    /**
33
    * @return the $missionGames
34
    */
35
    public function getMissionGames()
36
    {
37
        return $this->missionGames;
38
    }
39
40
    /**
41
     * @param \PlaygroundGame\Entity\ArrayCollection $missionGames
42
     */
43
    public function setMissionGames($missionGames)
44
    {
45
        $this->missionGames = $missionGames;
46
        
47
        return $this;
48
    }
49
    
50
    public function addMissionGames(ArrayCollection $missionGames)
51
    {
52
        foreach ($missionGames as $missionGame) {
53
            $missionGame->setMission($this);
54
            $this->missionGames->add($missionGame);
55
        }
56
    }
57
    
58
    public function removeMissionGames(ArrayCollection $missionGames)
59
    {
60
        foreach ($missionGames as $missionGame) {
61
            $missionGame->setMission(null);
62
            $this->missionGames->removeElement($missionGame);
63
        }
64
    }
65
    
66
    /**
67
     * Add a game to the mission.
68
     *
69
     * @param MissionGame $missionGame
70
     *
71
     * @return void
72
     */
73
    public function addMissionGame($missionGame)
74
    {
75
        $this->missionGames[] = $missionGame;
76
    }
77
78
    /**
79
     * Get the playables game if any
80
     *
81
     * @return array
82
     */
83
    public function getPlayableGames($entry = null)
84
    {
85
        $sortedPlayableGames = array();
86
        foreach ($this->missionGames as $missionGame) {
87
            $g = $missionGame->getGame();
88
            
89
            if ($g->isStarted() && $g->getActive()) {
90
                if (!$missionGame->getConditions() || $missionGame->fulfillConditions($entry)) {
91
                    $sortedPlayableGames[$missionGame->getPosition()] = $missionGame;
92
                }
93
            }
94
        }
95
96
        return $sortedPlayableGames;
97
    }
98
99
    /**
100
     * Get the previous playable game if any
101
     *
102
     * @return \PlaygroundGame\Entity\Game
103
     */
104
    public function getPreviousGame($entry = null)
105
    {
106
        $currentGame = $this->getNextPlayableGame($entry);
107
        $previousMissionGame = null;
108
109
        foreach ($this->missionGames as $missionGame) {
110
            if ($missionGame->getGame()->getId() === $currentGame->getId()) {
111
                return $previousMissionGame;
112
            }
113
114
            $previousMissionGame = $missionGame->getGame();
115
        }
116
117
        return null;
118
    }
119
120
    /**
121
     * Get the next playable game if any
122
     *
123
     * @return \PlaygroundGame\Entity\Game
124
     */
125
    public function getNextPlayableGame($entry = null)
126
    {
127
        $sortedPlayableGames = $this->getPlayableGames($entry);
128
129
        return (count($sortedPlayableGames) >= 1)?current($sortedPlayableGames)->getGame():null;
130
    }
131
132
    /**
133
     * is this game playable ?
134
     *
135
     * @return boolean
136
     */
137
    public function isPlayable($subGame, $entry = null)
138
    {
139
        if (!$subGame) {
140
            return false;
141
        }
142
        
143
        $sortedPlayableGames = $this->getPlayableGames($entry);
144
        foreach ($sortedPlayableGames as $pgame) {
145
            if ($subGame->getIdentifier() === $pgame->getGame()->getIdentifier()) {
146
                return true;
147
            }
148
        }
149
150
        return false;
151
    }
152
153
    /**
154
     * Convert the object to an array.
155
     *
156
     * @return array
157
     */
158
    public function getArrayCopy()
159
    {
160
        return get_object_vars($this);
161
    }
162
163
    /**
164
     * Populate from an array.
165
     *
166
     * @param array $data
167
     */
168
    public function populate($data = array())
169
    {
170
    }
171
172 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...
173
    {
174
        if (! $this->inputFilter) {
175
            $inputFilter = new InputFilter();
0 ignored issues
show
$inputFilter is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
176
            $factory = new InputFactory();
177
178
            $inputFilter = parent::getInputFilter();
179
            
180
            // This definition is mandatory for the hydration to work in a form !!!!
181
            $inputFilter->add($factory->createInput(array(
182
                'name' => 'missionGames',
183
                'required' => false,
184
            )));
185
            
186
187
            $this->inputFilter = $inputFilter;
188
        }
189
    
190
        return $this->inputFilter;
191
    }
192
}
193