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/Service/Mission.php (6 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 PlaygroundGame\Service;
4
5
use Zend\ServiceManager\ServiceManager;
6
use PlaygroundGame\Service\Game;
7
use PlaygroundGame\Entity\MissionGameCondition as MissionGameConditionEntity;
8
9
class Mission extends Game
10
{
11
12
    /**
13
     * @var MissionMapperInterface
14
     */
15
    protected $missionMapper;
16
    
17
    /**
18
     * @var MissionGameMapperInterface
19
     */
20
    protected $missionGameMapper;
21
22
    protected $options;
23
    
24
    /**
25
     * Find games associated to a mission and add the last entry of the user if it exists
26
     * @param unknown $mission
27
     * @return multitype:NULL
0 ignored issues
show
The doc-type multitype:NULL could not be parsed: Unknown type name "multitype:NULL" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
28
     */
29
    public function getMissionGames($mission, $user)
30
    {
31
        $games = array();
32
        $missionGames = $this->findGamesByMission($mission);
33
        foreach ($missionGames as $missionGame) {
34
            $entry = $this->checkExistingEntry($missionGame->getGame(), $user);
35
            $games[$missionGame->getGame()->getIdentifier()]['game'] = $missionGame;
36
            $games[$missionGame->getGame()->getIdentifier()]['entry'] = $entry;
37
        }
38
    
39
        return $games;
40
    }
41
    
42
    /**
43
     * findMissionGameByMission : find associated games to a mission
44
     * @param Mission $mission
45
     *
46
     * @return Collection de MissionGame $missionGames
47
     */
48
    public function findGamesByMission($mission)
49
    {
50
        return $this->getMissionGameMapper()->findBy(array('mission'=>$mission));
51
    }
52
    
53 View Code Duplication
    public function checkMissionCondition($game, $winner, $prediction, $entry)
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...
54
    {
55
        $missionGame = $this->findMissionGameByGame($game);
0 ignored issues
show
The method findMissionGameByGame() does not seem to exist on object<PlaygroundGame\Service\Mission>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
56
        if (empty($missionGame)) {
57
            return false;
58
        }
59
    
60
        if ($missionGame->getMission()->getActive() === false) {
61
            return false;
62
        }
63
    
64
        $nextMissionGame = $this->getMissionGameMapper()->getNextGame(
65
            $missionGame->getMission(),
66
            $missionGame->getPosition()
67
        );
68
    
69
        if (empty($nextMissionGame)) {
70
            return false;
71
        }
72
    
73
        $missionGameConditions = $this->findMissionGameConditionByMissionGame($nextMissionGame);
0 ignored issues
show
The method findMissionGameConditionByMissionGame() does not seem to exist on object<PlaygroundGame\Service\Mission>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
74
    
75
        if (empty($missionGameConditions)) {
76
            return false;
77
        }
78
    
79
        foreach ($missionGameConditions as $missionGameCondition) {
80
            if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::NONE) {
81
                continue;
82
            }
83
    
84
            // On passe au suivant si on a gagné
85
            if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::VICTORY) {
86
                if (!($winner || $prediction)) {
87
                    return false;
88
                }
89
            }
90
    
91
            // On passe au suivant si on a perdu
92
            if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::DEFEAT) {
93
                if ($winner || $prediction) {
94
                    return false;
95
                }
96
            }
97
    
98
            // On passe au suivant si on a perdu
99
            if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::GREATER) {
100
                if (!$entry) {
101
                    return false;
102
                }
103
                if (!($entry->getPoints() > $missionGameCondition->getValue())) {
104
                    return false;
105
                }
106
            }
107
    
108
            // On passe au suivant si on a perdu
109
            if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::LESS) {
110
                if (!$entry) {
111
                    return false;
112
                }
113
                if (!($entry->getPoints() < $missionGameCondition->getValue())) {
114
                    return false;
115
                }
116
            }
117
        }
118
    
119
        return $nextMissionGame->getGame();
120
    }
121
122
    public function getGameEntity()
123
    {
124
        return new \PlaygroundGame\Entity\Mission;
125
    }
126
127
    /**
128
     * getMissionMapper
129
     *
130
     * @return MissionMapperInterface
131
     */
132
    public function getMissionMapper()
133
    {
134
        if (null === $this->missionMapper) {
135
            $this->missionMapper = $this->serviceLocator->get('playgroundgame_mission_mapper');
136
        }
137
138
        return $this->missionMapper;
139
    }
140
141
    /**
142
     * setMissionMapper
143
     *
144
     * @param  MissionMapperInterface $missionMapper
145
     * @return Mission
146
     */
147
    public function setMissionMapper($missionMapper)
148
    {
149
        $this->missionMapper = $missionMapper;
150
151
        return $this;
152
    }
153
    
154
    /**
155
     * getMissionGameMapper
156
     *
157
     * @return MissionGameMapperInterface
158
     */
159 View Code Duplication
    public function getMissionGameMapper()
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...
160
    {
161
        if (null === $this->missionGameMapper) {
162
            $this->missionGameMapper = $this->serviceLocator->get('playgroundgame_mission_game_mapper');
163
        }
164
    
165
        return $this->missionGameMapper;
166
    }
167
    
168
    /**
169
     * setMissionMapper
170
     *
171
     * @param  MissionMapperInterface $missionGameMapper
172
     * @return Mission
173
     */
174
    public function setMissionGameMapper($missionGameMapper)
175
    {
176
        $this->missionGameMapper = $missionGameMapper;
0 ignored issues
show
Documentation Bug introduced by
It seems like $missionGameMapper of type object<PlaygroundGame\Se...MissionMapperInterface> is incompatible with the declared type object<PlaygroundGame\Se...ionGameMapperInterface> of property $missionGameMapper.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
177
    
178
        return $this;
179
    }
180
}
181