Issues (685)

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/Admin/UsersController.php (17 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
namespace App\Controller\Admin;
3
4
use App\Controller\AppController;
5
6
class UsersController extends AppController
7
{
8
9
    /**
10
     * Search users form.
11
     *
12
     * @return void
13
     */
14
    public function index()
15
    {
16
    }
17
18
    /**
19
     * Search users.
20
     *
21
     * @return void
22
     */
23
    public function search()
24
    {
25
        //Keyword to search. (For pagination)
26 View Code Duplication
        if (!empty($this->request->getData('search'))) {
0 ignored issues
show
This code seems to be duplicated across 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...
27
            $keyword = $this->request->getData('search');
28
            $this->request->session()->write('Search.Admin.Users.Keyword', $keyword);
29
        } else {
30
            if ($this->request->session()->read('Search.Admin.Users.Keyword')) {
31
                $keyword = $this->request->session()->read('Search.Admin.Users.Keyword');
32
            } else {
33
                $keyword = '';
34
            }
35
        }
36
37
        //Search type. (For pagination)
38 View Code Duplication
        if (!empty($this->request->getData('type'))) {
0 ignored issues
show
This code seems to be duplicated across 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...
39
            $type = $this->request->getData('type');
40
            $this->request->session()->write('Search.Admin.Users.Type', $type);
41
        } else {
42
            if ($this->request->session()->read('Search.Admin.Users.Type')) {
43
                $type = $this->request->session()->read('Search.Admin.Users.Type');
44
            } else {
45
                $type = '';
46
            }
47
        }
48
49
        switch ($type) {
50 View Code Duplication
            case "username":
0 ignored issues
show
This code seems to be duplicated across 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...
51
                $this->paginate = [
52
                    'limit' => 15,
53
                    'conditions' => [
54
                        'Users.username LIKE' => "%$keyword%"
55
                    ],
56
                    'order' => [
57
                        'Users.username' => 'asc'
58
                    ]
59
                ];
60
                break;
61
62 View Code Duplication
            case "ip":
0 ignored issues
show
This code seems to be duplicated across 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...
63
                $this->paginate = [
64
                    'limit' => 15,
65
                    'conditions' => [
66
                        'Users.last_login_ip LIKE' => "%$keyword%"
67
                    ],
68
                    'order' => [
69
                        'Users.last_login_ip' => 'asc'
70
                    ]
71
                ];
72
                break;
73
74 View Code Duplication
            case "mail":
0 ignored issues
show
This code seems to be duplicated across 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...
75
                $this->paginate = [
76
                    'limit' => 15,
77
                    'conditions' => [
78
                        'Users.email LIKE' => "%$keyword%"
79
                    ],
80
                    'order' => [
81
                        'Users.email' => 'asc'
82
                    ]
83
                ];
84
                break;
85
86
            case "group":
87
                $this->paginate = [
88
                    'limit' => 15,
89
                    'conditions' => [
90
                        'Groups.name LIKE' => "%$keyword%"
91
                    ],
92
                    'contain' => ['Groups']
93
                ];
94
                break;
95
96 View Code Duplication
            default:
0 ignored issues
show
This code seems to be duplicated across 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...
97
                $this->paginate = [
98
                    'limit' => 15,
99
                    'conditions' => [
100
                        'Users.username LIKE' => "%$keyword%"
101
                    ],
102
                    'order' => [
103
                        'Users.username' => 'asc'
104
                    ]
105
                ];
106
        }
107
108
        $users = $this->paginate($this->Users->find());
0 ignored issues
show
The property Users does not exist on object<App\Controller\Admin\UsersController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
109
        $this->set(compact('users', 'keyword', 'type'));
110
    }
111
112
    /**
113
     * Edit an user.
114
     *
115
     * @return \Cake\Network\Response|void
116
     */
117
    public function edit()
118
    {
119
        $user = $this->Users
0 ignored issues
show
The property Users does not exist on object<App\Controller\Admin\UsersController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
120
            ->find()
121
            ->where([
122
                'Users.id' => $this->request->id
123
            ])
124
            ->first();
125
126
        //Check if the user is found.
127
        if (empty($user)) {
128
            $this->Flash->error(__d('admin', 'This user doesn\'t exist or has been deleted.'));
129
130
            return $this->redirect(['action' => 'index']);
131
        }
132
133
        if ($this->request->is('put')) {
134
            $this->Users->patchEntity(
0 ignored issues
show
The property Users does not exist on object<App\Controller\Admin\UsersController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
135
                $user,
136
                $this->request->getParsedBody(),
137
                [
138
                    'validate' => 'update',
139
                    'accessibleFields' => ['group_id' => true]
140
                ]
141
            );
142
143
            if ($this->Users->save($user)) {
0 ignored issues
show
The property Users does not exist on object<App\Controller\Admin\UsersController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
144
                $this->Flash->success(__d('admin', 'This user has been updated successfully !'));
145
146
                return $this->redirect(['action' => 'index']);
147
            }
148
        }
149
150
        $this->loadModel('Groups');
151
152
        $groups = $this->Groups->find('list');
0 ignored issues
show
The property Groups does not exist on object<App\Controller\Admin\UsersController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
153
154
        $this->set(compact('user', 'groups'));
155
    }
156
157
    /**
158
     * Delete an user and all his articles, comments and likes.
159
     *
160
     * @return \Cake\Network\Response
161
     */
162
    public function delete()
163
    {
164
        $user = $this->Users
0 ignored issues
show
The property Users does not exist on object<App\Controller\Admin\UsersController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
165
            ->find()
166
            ->where([
167
                'Users.id' => $this->request->id
168
            ])
169
            ->first();
170
171
        //Check if the user is found.
172
        if (empty($user) || $user->is_deleted == true) {
173
            $this->Flash->error(__d('admin', 'This user doesn\'t exist or has been deleted.'));
174
175
            return $this->redirect(['action' => 'index']);
176
        }
177
178
        $user->is_deleted = true;
179
180
        if ($this->Users->save($user)) {
0 ignored issues
show
The property Users does not exist on object<App\Controller\Admin\UsersController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
181
            $this->Flash->success(__d('admin', 'This user has been deleted successfully !'));
182
183
            return $this->redirect(['action' => 'index']);
184
        }
185
186
        $this->Flash->error(__d('admin', 'Unable to delete this user.'));
187
188
        return $this->redirect(['action' => 'index']);
189
    }
190
191
    /**
192
     * Delete an avatar.
193
     *
194
     * @return \Cake\Network\Response
195
     */
196
    public function deleteAvatar()
197
    {
198
        $user = $this->Users
0 ignored issues
show
The property Users does not exist on object<App\Controller\Admin\UsersController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
199
            ->find()
200
            ->where([
201
                'Users.id' => $this->request->id
202
            ])
203
            ->first();
204
205
        //Check if the user is found.
206
        if (empty($user)) {
207
            $this->Flash->error(__d('admin', 'This user doesn\'t exist or has been deleted.'));
208
209
            return $this->redirect(['action' => 'index']);
210
        }
211
212
        $user->avatar = '../img/avatar.png';
213
214
        if ($this->Users->save($user)) {
0 ignored issues
show
The property Users does not exist on object<App\Controller\Admin\UsersController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
215
            $this->Flash->success(__d('admin', 'His avatar has been deleted successfully !'));
216
217
            return $this->redirect($this->referer());
0 ignored issues
show
It seems like $this->referer() targeting Cake\Controller\Controller::referer() can also be of type object<Cake\Http\ServerRequest>; however, Cake\Controller\Controller::redirect() does only seem to accept string|array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
218
        }
219
220
        $this->Flash->error(__d('admin', 'Unable to delete his avatar.'));
221
222
        return $this->redirect($this->referer());
0 ignored issues
show
It seems like $this->referer() targeting Cake\Controller\Controller::referer() can also be of type object<Cake\Http\ServerRequest>; however, Cake\Controller\Controller::redirect() does only seem to accept string|array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
223
    }
224
}
225