Issues (183)

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.

system/framework.php (3 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
use \FMUP\Request;
4
5
/**
6
 * Classe d'initialisation du framework
7
 * @deprecated use \FMUP\Framework instead
8
 */
9
class Framework
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
10
{
11
    use \FMUP\Sapi\OptionalTrait;
12
13
    /**
14
     * @var Request
15
     */
16
    private $request;
17
    /**
18
     * @var Request\Factory
19
     */
20
    private $requestFactory;
21
22
    /**
23
     * @return Request
24
     */
25
    public function getRequest()
26
    {
27
        if (!$this->request) {
28
            $this->request = $this->getRequestFactory()->get();
29
        }
30
        return $this->request;
31
    }
32
33
    /**
34
     * Returns defined request factory
35
     * @return Request\Factory
36
     */
37
    public function getRequestFactory()
38
    {
39
        return $this->requestFactory = $this->requestFactory ?: new Request\Factory();
40
    }
41
42
    /**
43
     * Define request factory
44
     * @param Request\Factory|null $factory
45
     * @return $this
46
     */
47
    public function setRequestFactory(Request\Factory $factory = null)
48
    {
49
        $this->requestFactory = $factory;
50
        return $this;
51
    }
52
53
    /**
54
     * @param Request $request
55
     * @return $this
56
     */
57
    public function setRequest(Request $request)
58
    {
59
        $this->request = $request;
60
        return $this;
61
    }
62
63
    public function initialize()
64
    {
65
        if (!defined('APPLICATION')) {
66
            throw new \FMUP\Exception("La variable APPLICATION doit être définie.");
67
        }
68
69
        $this->registerErrorHandler();
70
        $this->registerShutdownFunction();
71
        $this->dispatch();
72
73
    }
74
75
    /**
76
     * Allow overwriting of an eventual pre treatment
77
     */
78
    protected function preDispatch()
79
    {
80
    }
81
82
    /**
83
     * @return $this
84
     */
85
    protected function dispatch()
86
    {
87
        list($controllerName, $action) = $this->getRoute();
88
        $this->instantiate($controllerName, $action);
89
        return $this;
90
    }
91
92
    /**
93
     * Allow overwriting of an eventual post treatment
94
     */
95
    protected function postDispatch()
96
    {
97
    }
98
99
    protected function instantiate($sys_controller, $sys_function)
100
    {
101
        // Création d'une instance du controlleur
102
        $controllerName = \FMUP\StringHandling::toCamelCase($sys_controller);
103
104
        /** @var $controllerInstance \FMUP\Controller */
105
        $controllerInstance = new $controllerName();
106
        $controllerInstance->preFilter($sys_function);
0 ignored issues
show
The call to the method FMUP\Controller::preFilter() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
107
108
        if (method_exists($controllerInstance, $sys_function)) {
109
            call_user_func(array($controllerInstance, $sys_function));
110
        } else {
111
            throw new \FMUP\Exception\Status\NotFound("Fonction introuvable : $sys_function");
112
        }
113
        $controllerInstance->postFilter();
0 ignored issues
show
The call to the method FMUP\Controller::postFilter() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
114
        return $controllerInstance;
115
    }
116
117
    /**
118
     * Sends exception in case of error
119
     * @param int $code
120
     * @param string $msg
121
     * @throws \FMUP\Exception
122
     * @deprecated
123
     */
124
    public function errorHandler($code, $msg, $errFile = null, $errLine = 0, array $errContext = array())
125
    {
126
    }
127
128
    /**
129
     * Cette fonction sera lancée à la fin du script quel que soit la cause (fin normale ou erreur)
130
     * Elle nous permet de récupérer les erreurs fatales qui sont ignorées par la fonction précédente
131
     * @deprecated maybe you want to override this
132
     */
133
    public function shutDown()
134
    {
135
    }
136
137
    /**
138
     * Cette fonction récupère le controleur appelé dans l'URL
139
     * Elle va aussi gérer si l'utilisateur doit se connecter ou si le site est en maintenance
140
     * (et changer le controleur en conséquence)
141
     * @return array : Un tableau contenant le dossier, le controleur et la fonction à appeler
142
     */
143
    public function getRoute()
144
    {
145
        preg_match("/^(.*\/)?([0-9a-zA-Z\-_]*)\/([0-9a-zA-Z\-_]*)$/", $this->getRequest()->getRequestUri(), $matches);
146
        if (count($matches) < 3) {
147
            $this->getRouteError(null, null);
148
        }
149
150
        $sys_directory = $matches[1];
151
        $sys_controller = "ctrl_" . $matches[2];
152
        $sys_function = \FMUP\StringHandling::toCamelCase($matches[3]);
153
154
        if (!class_exists(\FMUP\StringHandling::toCamelCase($sys_controller)) ||
155
            !is_callable(array(\FMUP\StringHandling::toCamelCase($sys_controller), $sys_function))
156
        ) {
157
            $this->getRouteError($sys_directory, $sys_controller);
158
        }
159
        return array(\FMUP\StringHandling::toCamelCase($sys_controller), $sys_function);
160
    }
161
162
    /**
163
     * @param string $directory
164
     * @param string $controller
165
     * @throws \FMUP\Exception\Status\NotFound
166
     */
167
    protected function getRouteError($directory, $controller)
168
    {
169
        throw new \FMUP\Exception\Status\NotFound(
170
            "Controlleur introuvable : $directory$controller " .
171
            " (application/" . APPLICATION . "/controller/$directory$controller.php)"
172
        );
173
    }
174
175
    /**
176
     * @return $this
177
     */
178
    protected function registerErrorHandler()
179
    {
180
        set_error_handler(array($this, 'errorHandler'));
181
        return $this;
182
    }
183
184
    /**
185
     * @return $this
186
     */
187
    protected function registerShutdownFunction()
188
    {
189
        register_shutdown_function(array($this, 'shutDown'));
190
        return $this;
191
    }
192
}
193