Issues (37)

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/Route/SlimRouteApp.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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 13 and the first side effect is on line 8.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * @author   Temitope Olotin <[email protected]>
4
 * @license  <https://opensource.org/license/MIT> MIT
5
 */
6
namespace Laztopaz\EmojiRestfulAPI;
7
8
require 'vendor/autoload.php';
9
10
use Psr\Http\Message\ResponseInterface as Response;
11
use Psr\Http\Message\ServerRequestInterface as Request;
12
13
class SlimRouteApp
14
{
15
    protected $auth;
16
    protected $emoji;
17
    protected $slimApp;
18
19
    public function __construct(Oauth $auth, EmojiController $emoji)
20
    {
21
        $this->auth = $auth;
22
        $this->emoji = $emoji;
23
        $this->slimApp = new \Slim\App([
24
            'settings' => [
25
            'debug'               => true,
26
            'displayErrorDetails' => true,
27
            ], ]);
28
29
        $this->runEmojiRoute();
30
    }
31
32
    public function setUpSlimApp()
33
    {
34
        return $this->slimApp;
35
    }
36
37
    public function runEmojiRoute()
38
    {
39
        $auth = $this->auth;
40
        $emoji = $this->emoji;
41
42
       /*
43
        * This verb returns error 404
44
        *
45
        * @param $request
46
        *
47
        * @param $response
48
        *
49
        * @return json $response
50
        *
51
        */
52
        $this->slimApp->get('/', function (Request $request, Response $response) {
53
            return $response->withJson(['message' => 'Welcome to Sweet Emoji'], 200);
54
55
        });
56
57
        /*
58
        * This verb returns error 404
59
        *
60
        * @param $request
61
        *
62
        * @param $response
63
        *
64
        * @return json $response
65
        *
66
        */
67
        $this->slimApp->post('/', function (Request $request, Response $response) {
68
            return $response->withStatus(404);
69
70
        });
71
72
        /*
73
        * This endpoint registers a new user
74
        *
75
        * @param $request
76
        *
77
        * @param $response
78
        *
79
        * @return json $response
80
        *
81
        */
82
        $this->slimApp->post('/auth/register', function (Request $request, Response $response) use ($auth) {
83
            return $auth->registerUser($request, $response);
84
85
        });
86
87
        /*
88
        * This endpoint authenticate the user
89
        *
90
        * @param $request
91
        *
92
        * @param $response
93
        *
94
        * @return json $response
95
        *
96
        */
97
        $this->slimApp->post('/auth/login', function (Request $request, Response $response) use ($auth) {
98
            return $auth->loginUser($request, $response);
99
100
        });
101
102
        /*
103
        * This endpoint authenticate the user
104
        *
105
        * @param $request
106
        *
107
        * @param $response
108
        *
109
        * @param $args
110
        *
111
        * @return json $response
112
        *
113
        */
114
115
        $this->slimApp->get('/auth/logout', function (Request $request, Response $response, $args) use ($auth) {
116
            return $auth->logoutUser($request, $response, $args);
117
118
        })->add(new Middleware());
119
120
        /*
121
        * This verb returns all emoji
122
        *
123
        * @param $request
124
        *
125
        * @param $response
126
        *
127
        * @return json $response
128
        *
129
        */
130
        $this->slimApp->get('/emojis', function (Request $request, Response $response) use ($emoji) {
131
            return $emoji->listAllEmoji($response);
132
133
        });
134
135
        /*
136
        * This verb returns a single emoji
137
        *
138
        * @param $response
139
        *
140
        * @param $args
141
        *
142
        * @return json $response
143
        *
144
        */
145
        $this->slimApp->get('/emojis/{id}', function (Request $request, Response $response, $args) use ($emoji) {
146
            return $emoji->getSingleEmoji($response, $args);
147
148
        });
149
150
        /*
151
        * This verb creates a new  emoji
152
        *
153
        * @param $request
154
        *
155
        * @param $response
156
        *
157
        * @return json $response
158
        *
159
        */
160
        $this->slimApp->post('/emojis', function (Request $request, Response $response) use ($emoji) {
161
            return $emoji->createEmoji($request, $response);
162
163
        })->add(new Middleware());
164
165
        /*
166
        * This verb updatess an emoji using put verb
167
        *
168
        * @param $request
169
        *
170
        * @param $response
171
        *
172
        * @param $args
173
        *
174
        * @param $emoji
175
        *
176
        * @return json $response
177
        *
178
        */
179
        $this->slimApp->put('/emojis/{id}', function (Request $request, Response $response, $args) use ($emoji) {
180
            return $emoji->updateEmojiByPutVerb($request, $response, $args);
181
182
        })->add(new Middleware());
183
184
        /*
185
        * This verb updatess an emoji using put verb
186
        *
187
        * @param $request
188
        *
189
        * @param $response
190
        *
191
        * @param $data
192
        *
193
        * @return json $response
194
        *
195
        */
196
        $this->slimApp->patch('/emojis/{id}', function (Request $request, Response $response, $args) use ($emoji) {
197
            return $emoji->updateEmojiByPatchVerb($request, $response, $args);
198
199
        })->add(new Middleware());
200
201
        /*
202
        * This verb updatess an emoji using put verb
203
        *
204
        * @param $request
205
        *
206
        * @param $response
207
        *
208
        * @param $args
209
        *
210
        * @return json $response
211
        *
212
        */
213
        $this->slimApp->delete('/emojis/{id}', function (Request $request, Response $response, $args) use ($emoji) {
214
            return $emoji->deleteEmoji($request, $response, $args);
215
216
        })->add(new Middleware());
217
    }
218
}
219