Issues (68)

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.

app/src/Schema/UserSchema.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
namespace App\Schema;
3
4
use \Carbon\Carbon;
5
6
/**
7
 * @api {get} /user Список пользователей
8
 * @apiName GetUsers
9
 * @apiGroup User
10
 *
11
 * @apiDescription Метод для получения списка пользователей.
12
 *
13
 * @apiPermission user
14
 *
15
 * @apiHeader {String} Authorization Bearer TOKEN
16
 *
17
 * @apiSuccessExample {json} Успешно (200)
18
 *     HTTP/1.1 200 OK
19
 *     {
20
 *       "data": [
21
 *         {
22
 *           "type": "user",
23
 *           "id": "1",
24
 *           "attributes": {
25
 *             "full_name": "Тестовый пользователь",
26
 *             "email": "[email protected]",
27
 *             "role_id": 1,
28
 *             "created_at": "2016-10-17T07:38:21+0000",
29
 *             "updated_at": "2016-10-17T07:38:21+0000",
30
 *             "created_by": 0,
31
 *             "updated_by": null,
32
 *             "status": 1,
33
 *           },
34
 *           "relationships": {
35
 *             "role": {
36
 *               "data": {
37
 *                 "type": "role",
38
 *                 "id": "1"
39
 *               }
40
 *             }
41
 *           },
42
 *           "links": {
43
 *             "self": "http://bootstrapi.dev/api/user/1"
44
 *           }
45
 *         }
46
 *       ]
47
 *     }
48
 *
49
 * @apiUse StandardErrors
50
 * @apiUse UnauthorizedError
51
 */
52
53
/**
54
 * @api {get} /user/:id?include=role&fields[role]=name Получить пользователя
55
 * @apiName GetUser
56
 * @apiGroup User
57
 *
58
 * @apiDescription Метод для получения пользователя.
59
 *
60
 * @apiPermission user
61
 *
62
 * @apiParam {Number} id Id пользователя
63
 *
64
 * @apiHeader {String} Authorization Bearer TOKEN
65
 *
66
 * @apiSuccessExample {json} Успешно (200)
67
 *     HTTP/1.1 200 OK
68
 *     {
69
 *       "data": {
70
 *         "type": "user",
71
 *         "id": "1",
72
 *         "attributes": {
73
 *           "full_name": "Тестовый пользователь",
74
 *           "email": "[email protected]",
75
 *           "role_id": 1,
76
 *           "created_at": "2016-10-17T07:38:21+0000",
77
 *           "updated_at": "2016-10-17T07:38:21+0000",
78
 *           "created_by": 0,
79
 *           "updated_by": null,
80
 *           "status": 1,
81
 *         },
82
 *         "relationships": {
83
 *           "role": {
84
 *             "data": {
85
 *               "type": "role",
86
 *               "id": "1"
87
 *             }
88
 *           }
89
 *         },
90
 *         "links": {
91
 *           "self": "http://bootstrapi.dev/api/user/1"
92
 *         }
93
 *       }
94
 *     }
95
 *
96
 * @apiUse StandardErrors
97
 * @apiUse UnauthorizedError
98
 * @apiUse NotFoundError
99
 */
100
101
/**
102
 * @api {delete} /user/:id Удаление пользователя
103
 * @apiName DeleteUser
104
 * @apiGroup User
105
 *
106
 * @apiDescription Метод для удаления пользователя.
107
 *
108
 * @apiPermission admin
109
 *
110
 * @apiParam {Number} id Id пользователя
111
 *
112
 * @apiHeader {String} Authorization Bearer TOKEN
113
 *
114
 * @apiSuccessExample {json} Успешно (204)
115
 *     HTTP/1.1 204 OK
116
 *
117
 * @apiUse UnauthorizedError
118
 * @apiUse StandardErrors
119
 * @apiUse NotFoundError
120
 */
121
122
/**
123
 * @api {post} /user Создание пользователя
124
 * @apiName CreateUser
125
 * @apiGroup User
126
 *
127
 * @apiDescription Метод для создания нового пользователя.
128
 *
129
 * @apiPermission admin
130
 *
131
 * @apiParam {String} full_name Полное имя пользователя
132
 * @apiParam {String} email Email пользователя (уникальный)
133
 * @apiParam {String} password Пароль
134
 * @apiParam {Number} role_id Id роли пользователя
135
 *
136
 * @apiParamExample {json} Пример запроса:
137
 *    {
138
 *      "data":{
139
 *        "attributes":{
140
 *          "full_name":"Тестовый пользователь",
141
 *          "email": "[email protected]",
142
 *          "password": "qwerty",
143
 *          "role_id": 1,
144
 *          "status": 1
145
 *        }
146
 *      }
147
 *    }
148
 *
149
 * @apiHeader {String} Authorization Bearer TOKEN
150
 *
151
 * @apiSuccessExample {json} Успешно (200)
152
 *     HTTP/1.1 200 OK
153
 *     {
154
 *       "data": {
155
 *         "type": "user",
156
 *         "id": "2",
157
 *         "attributes": {
158
 *           "full_name": "Тестовый пользователь",
159
 *           "email": "[email protected]",
160
 *           "role_id": 1,
161
 *           "created_at": "2016-10-17T07:38:21+0000",
162
 *           "updated_at": "2016-10-17T07:38:21+0000",
163
 *           "created_by": 1,
164
 *           "updated_by": null,
165
 *           "status": 1,
166
 *         },
167
 *         "relationships": {
168
 *            "role": {
169
 *             "data": {
170
 *               "type": "role",
171
 *               "id": "1"
172
 *             }
173
 *           }
174
 *         },
175
 *         "links": {
176
 *           "self": "http://bootstrapi.dev/api/user/2"
177
 *         }
178
 *       }
179
 *     }
180
 *
181
 * @apiUse StandardErrors
182
 * @apiUse UnauthorizedError
183
 */
184
185
/**
186
 * @api {patch} /user/:id Изменение пользователя
187
 * @apiName UpdateUser
188
 * @apiGroup User
189
 *
190
 * @apiDescription Метод для изменения пользователя.
191
 *
192
 *
193
 * @apiPermission admin
194
 *
195
 * @apiParam {String} full_name Полное имя пользователя
196
 * @apiParam {String} email Email пользователя (уникальный)
197
 * @apiParam {String} password Пароль
198
 * @apiParam {Number} role_id Id роли пользователя
199
 *
200
 * @apiParamExample {json} Пример запроса:
201
 *    {
202
 *      "data":{
203
 *        "attributes":{
204
 *          "full_name":"Тестовый пользователь",
205
 *          "email": "[email protected]",
206
 *          "password": "qwerty",
207
 *          "role_id": 1
208
 *        }
209
 *      }
210
 *    }
211
 *
212
 * @apiSuccessExample {json} Успешно (200)
213
 *     HTTP/1.1 200 OK
214
 *     {
215
 *       "data": {
216
 *         "type": "user",
217
 *         "id": 2,
218
 *         "attributes": {
219
 *           "full_name": "Тестовый пользователь",
220
 *           "email": "[email protected]",
221
 *           "role_id": 1,
222
 *           "created_at": "2016-10-17T07:38:21+0000",
223
 *           "updated_at": "2016-10-17T07:38:21+0000",
224
 *           "created_by": null,
225
 *           "updated_by": null,
226
 *           "status": 1,
227
 *         },
228
 *         "relationships": {
229
 *           "role": {
230
 *             "data": {
231
 *               "type": "role",
232
 *               "id": "1"
233
 *             }
234
 *           }
235
 *         },
236
 *         "links": {
237
 *           "self": "http://bootstrapi.dev/api/user/2"
238
 *         }
239
 *       }
240
 *     }
241
 *
242
 * @apiHeader {String} Authorization Bearer TOKEN
243
 *
244
 * @apiUse StandardErrors
245
 * @apiUse UnauthorizedError
246
 * @apiUse NotFoundError
247
 */
248
249
/**
250
 * @api {post} /user/request-password-reset Запрос на сброс пароля
251
 * @apiName RequestPasswordReset
252
 * @apiGroup User
253
 *
254
 * @apiDescription Метод высылающий на email пользователя письмо со ссылкой для изменения пароля.
255
 *
256
 * В ссылке отправляется токен для сброса пароля. Его нужно отправить в методе /user/password-reset
257
 *
258
 * @apiParam {String} email Email пользователя
259
 *
260
 * @apiParamExample {json} Пример запроса:
261
 *    {
262
 *      "data":{
263
 *        "attributes":{
264
 *          "email": "[email protected]"
265
 *        }
266
 *      }
267
 *    }
268
 *
269
 * @apiSuccessExample {json} Успешно (204)
270
 *     HTTP/1.1 204 OK
271
 *
272
 * @apiUse StandardErrors
273
 */
274
275
/**
276
 * @api {post} /user/password-reset Сброс пароля
277
 * @apiName PasswordReset
278
 * @apiGroup User
279
 *
280
 * @apiDescription Метод для изменения пароля.
281
 *
282
 * Вместе с паролем нужно отправить токен, который был отправлен пользователю на почту.
283
 *
284
 * @apiParam {String} email Email пользователя
285
 *
286
 * @apiParamExample {json} Пример запроса:
287
 *    {
288
 *      "data":{
289
 *        "attributes":{
290
 *          "token": "f35v3g7h3frw24yi58cawo2e2kqhy3i5_1466085622",
291
 *          "password": "qwerty"
292
 *        }
293
 *      }
294
 *    }
295
 *
296
 * @apiSuccessExample {json} Успешно (204)
297
 *     HTTP/1.1 204 OK
298
 *
299
 * @apiUse StandardErrors
300
 */
301
302 View Code Duplication
final class UserSchema extends BaseSchema
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...
303
{
304
    protected $resourceType = 'user';
305
306
    public function getId($user)
307
    {
308
        return $user->id;
309
    }
310
311
    public function getAttributes($user)
312
    {
313
        return [
314
            'full_name'  => $user->full_name,
315
            'email'      => $user->email,
316
            'role_id'    => (int)$user->role_id,
317
            'created_at' => Carbon::parse($user->created_at)->setTimezone('UTC')->format(Carbon::ISO8601),
318
            'updated_at' => Carbon::parse($user->updated_at)->setTimezone('UTC')->format(Carbon::ISO8601),
319
            'created_by' => $user->created_by,
320
            'updated_by' => $user->updated_by,
321
            'status'     => $user->status,
322
        ];
323
    }
324
325
    public function getRelationships($user, $isPrimary, array $includeList)
326
    {
327
        return [
328
            'role' => [
329
                self::DATA => $user->role,
330
            ],
331
        ];
332
    }
333
}
334