Issues (11)

Security Analysis    no request data  

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/Controller/SampleAppController.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
3
namespace Anax\Controller;
4
5
use Anax\Commons\AppInjectableInterface;
6
use Anax\Commons\AppInjectableTrait;
7
8
// use Anax\Route\Exception\ForbiddenException;
9
// use Anax\Route\Exception\NotFoundException;
10
// use Anax\Route\Exception\InternalErrorException;
11
12
/**
13
 * A sample controller to show how a controller class can be implemented.
14
 * The controller will be injected with $app if implementing the interface
15
 * AppInjectableInterface, like this sample class does.
16
 * The controller is mounted on a particular route and can then handle all
17
 * requests for that mount point.
18
 *
19
 * @SuppressWarnings(PHPMD.TooManyPublicMethods)
20
 */
21 View Code Duplication
class SampleAppController implements AppInjectableInterface
0 ignored issues
show
This class 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...
22
{
23
    use AppInjectableTrait;
24
25
26
27
    /**
28
     * @var string $db a sample member variable that gets initialised
29
     */
30
    private $db = "not active";
31
32
33
34
    /**
35
     * The initialize method is optional and will always be called before the
36
     * target method/action. This is a convienient method where you could
37
     * setup internal properties that are commonly used by several methods.
38
     *
39
     * @return void
40
     */
41 10
    public function initialize() : void
42
    {
43
        // Use to initialise member variables.
44 10
        $this->db = "active";
45
46
        // Use $this->app to access the framework services.
47 10
    }
48
49
50
51
    /**
52
     * This is the index method action, it handles:
53
     * ANY METHOD mountpoint
54
     * ANY METHOD mountpoint/
55
     * ANY METHOD mountpoint/index
56
     *
57
     * @return string
58
     */
59 1
    public function indexAction() : string
60
    {
61
        // Deal with the action and return a response.
62 1
        return __METHOD__ . ", \$db is {$this->db}";
63
    }
64
65
66
67
    /**
68
     * This sample method dumps the content of $app.
69
     * GET mountpoint/dump-app
70
     *
71
     * @return string
72
     */
73 1
    public function dumpAppActionGet() : string
74
    {
75
        // Deal with the action and return a response.
76 1
        $services = implode(", ", $this->app->getServices());
77 1
        return __METHOD__ . "<p>\$app contains: $services";
78
    }
79
80
81
82
    /**
83
     * Add the request method to the method name to limit what request methods
84
     * the handler supports.
85
     * GET mountpoint/info
86
     *
87
     * @return string
88
     */
89 1
    public function infoActionGet() : string
90
    {
91
        // Deal with the action and return a response.
92 1
        return __METHOD__ . ", \$db is {$this->db}";
93
    }
94
95
96
97
    /**
98
     * This sample method action it the handler for route:
99
     * GET mountpoint/create
100
     *
101
     * @return string
102
     */
103 1
    public function createActionGet() : string
104
    {
105
        // Deal with the action and return a response.
106 1
        return __METHOD__ . ", \$db is {$this->db}";
107
    }
108
109
110
111
    /**
112
     * This sample method action it the handler for route:
113
     * POST mountpoint/create
114
     *
115
     * @return string
116
     */
117 1
    public function createActionPost() : string
118
    {
119
        // Deal with the action and return a response.
120 1
        return __METHOD__ . ", \$db is {$this->db}";
121
    }
122
123
124
125
    /**
126
     * This sample method action takes one argument:
127
     * GET mountpoint/argument/<value>
128
     *
129
     * @param mixed $value
130
     *
131
     * @return string
132
     */
133 1
    public function argumentActionGet($value) : string
134
    {
135
        // Deal with the action and return a response.
136 1
        return __METHOD__ . ", \$db is {$this->db}, got argument '$value'";
137
    }
138
139
140
141
    /**
142
     * This sample method action takes zero or one argument and you can use - as a separator which will then be removed:
143
     * GET mountpoint/defaultargument/
144
     * GET mountpoint/defaultargument/<value>
145
     * GET mountpoint/default-argument/
146
     * GET mountpoint/default-argument/<value>
147
     *
148
     * @param mixed $value with a default string.
149
     *
150
     * @return string
151
     */
152 1
    public function defaultArgumentActionGet($value = "default") : string
153
    {
154
        // Deal with the action and return a response.
155 1
        return __METHOD__ . ", \$db is {$this->db}, got argument '$value'";
156
    }
157
158
159
160
    /**
161
     * This sample method action takes two typed arguments:
162
     * GET mountpoint/typed-argument/<string>/<int>
163
     *
164
     * NOTE. Its recommended to not use int as type since it will still
165
     * accept numbers such as 2hundred givving a PHP NOTICE. So, its better to
166
     * deal with type check within the action method and throuw exceptions
167
     * when the expected type is not met.
168
     *
169
     * @param mixed $value with a default string.
170
     *
171
     * @return string
172
     */
173 1
    public function typedArgumentActionGet(string $str, int $int) : string
174
    {
175
        // Deal with the action and return a response.
176 1
        return __METHOD__ . ", \$db is {$this->db}, got string argument '$str' and int argument '$int'.";
177
    }
178
179
180
181
    /**
182
     * This sample method action takes a variadic list of arguments:
183
     * GET mountpoint/variadic/
184
     * GET mountpoint/variadic/<value>
185
     * GET mountpoint/variadic/<value>/<value>
186
     * GET mountpoint/variadic/<value>/<value>/<value>
187
     * etc.
188
     *
189
     * @param array $value as a variadic parameter.
190
     *
191
     * @return string
192
     */
193 1
    public function variadicActionGet(...$value) : string
194
    {
195
        // Deal with the action and return a response.
196 1
        return __METHOD__ . ", \$db is {$this->db}, got '" . count($value) . "' arguments: " . implode(", ", $value);
197
    }
198
199
200
201
    /**
202
     * Adding an optional catchAll() method will catch all actions sent to the
203
     * router. You can then reply with an actual response or return void to
204
     * allow for the router to move on to next handler.
205
     * A catchAll() handles the following, if a specific action method is not
206
     * created:
207
     * ANY METHOD mountpoint/**
208
     *
209
     * @param array $args as a variadic parameter.
210
     *
211
     * @return mixed
212
     *
213
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
214
     */
215 1
    public function catchAll(...$args)
216
    {
217
        // Deal with the request and send an actual response, or not.
218
        //return __METHOD__ . ", \$db is {$this->db}, got '" . count($args) . "' arguments: " . implode(", ", $args);
219 1
        return;
220
    }
221
}
222