Issues (42)

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/Model/Table/UsersTable.php (2 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
 * CakeCMS Community
4
 *
5
 * This file is part of the of the simple cms based on CakePHP 3.
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @package     Community
10
 * @license     MIT
11
 * @copyright   MIT License http://www.opensource.org/licenses/mit-license.php
12
 * @link        https://github.com/CakeCMS/Community".
13
 * @author      Sergey Kalistratov <[email protected]>
14
 */
15
16
namespace Community\Model\Table;
17
18
use Cake\ORM\Query;
19
use Core\ORM\Table;
20
use Core\Event\EventManager;
21
use Cake\Validation\Validator;
22
use Community\Model\Entity\User;
23
use Cake\Datasource\EntityInterface;
24
25
/**
26
 * Class UsersTable
27
 *
28
 * @method      filterParams(array $query = [])
29
 * @method      User get($primaryKey, $options = [])
30
 * @property    GroupsTable $Groups
31
 *
32
 * @package     Community\Model\Table
33
 */
34
class UsersTable extends Table
35
{
36
37
    /**
38
     * Initialize a table instance. Called after the constructor.
39
     *
40
     * @param   array $config Configuration options passed to the constructor.
41
     * @return  void
42
     *
43
     * @throws  \RuntimeException
44
     */
45
    public function initialize(array $config)
46
    {
47
        parent::initialize($config);
48
49
        $this
50
            ->setPrimaryKey('id')
51
            ->setTable(CMS_TABLE_USERS)
52
            ->setDisplayField('name');
53
54
        $this->addBehavior('Timestamp');
55
        $this->addBehavior('Search.Search');
56
57
        $this->addAssociations([
58
            'belongsTo' => [
59
                'Groups' => [
60
                    'foreignKey' => 'group_id',
61
                    'className'  => 'Community.Groups'
62
                ]
63
            ]
64
        ]);
65
    }
66
67
    /**
68
     * Persists an entity based on the fields that are marked as dirty and
69
     * returns the same entity after a successful save or false in case
70
     * of any error.
71
     *
72
     * @param   \Cake\Datasource\EntityInterface $entity the entity to be saved
73
     * @param   array|\ArrayAccess $options The options to use when saving.
74
     * @return  \Cake\Datasource\EntityInterface|false
75
     */
76
    public function save(EntityInterface $entity, $options = [])
77
    {
78
        EventManager::trigger('Model.User.beforeSave', $this, [
79
            'user' => $entity
80
        ]);
81
82
        $success = parent::save($entity, $options);
0 ignored issues
show
It seems like $options defined by parameter $options on line 76 can also be of type object<ArrayAccess>; however, Cake\ORM\Table::save() does only seem to accept array, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and 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...
83
84
        EventManager::trigger('Model.User.afterSave', $this, [
85
            'user'    => $entity,
86
            'success' => $success
87
        ]);
88
89
        return $success;
90
    }
91
92
    /**
93
     * Default validation rules.
94
     *
95
     * @param   Validator $validator The validator that can be modified to add some rules to it.
96
     * @return  Validator
97
     *
98
     * @throws  \Aura\Intl\Exception
99
     */
100
    public function validationDefault(Validator $validator)
101
    {
102
        $validator
103
            ->requirePresence('login', 'create')
104
            ->notEmpty('login', __d('community', 'Login could not be empty.'))
105
            ->add('login', 'unique', [
106
                'provider' => 'table',
107
                'rule'     => 'validateUnique',
108
                'message'  => __d('community', 'User with this login already exists.')
109
            ])
110
            ->add('login', 'length', [
111
                'rule'    => ['minLength', MIN_LENGTH_LOGIN],
112
                'message' => __d('community', 'The minimum login length must be {0} characters', MIN_LENGTH_LOGIN)
113
            ]);
114
115
        $validator
116
            ->requirePresence('slug', 'create')
117
            ->notEmpty('slug', __d('community', 'Alias could not be empty.'))
118
            ->add('slug', 'unique', [
119
                'provider' => 'table',
120
                'rule'     => 'validateUnique',
121
                'message'  => __d('community', 'User with this alias already exists.')
122
            ])
123
            ->add('slug', 'length', [
124
                'rule'    => ['minLength', MIN_LENGTH_LOGIN],
125
                'message' => __d('community', 'The minimum alias length must be {0} characters', MIN_LENGTH_LOGIN)
126
            ]);
127
128
        $validator
129
            ->requirePresence('group_id', 'create')
130
            ->notEmpty('group_id', __d('community', 'Please, choose user group.'))
131
            ->notEmpty('name', __d('community', 'Please, enter you full name.'));
132
133
        $validator
134
            ->notEmpty('email', __d('community', 'Please, enter you email.'))
135
            ->add('email', 'unique', [
136
                'provider' => 'table',
137
                'rule'     => 'validateUnique',
138
                'message'  => __d('community', 'User with this email already exists.')
139
            ])
140
            ->add('email', 'valid', [
141
                'rule'    => 'email',
142
                'message' => __d('community', 'Please enter valid email.')
143
            ]);
144
145
        $validator
146
            ->notEmpty('password', __d('community', 'Please, enter you password.'))
147
            ->add('password', 'minLength', [
148
                'rule'    => ['minLength', MIN_LENGTH_PASS],
149
                'message' => __d('community', 'The minimum password length is {0}', MIN_LENGTH_PASS)
150
            ]);
151
152
        $validator
153
            ->notEmpty('password_confirm', __d('community', 'Please, confirm you password.'))
154
            ->add('password_confirm', 'no-misspelling', [
155
                'rule'    => ['compareWith', 'password'],
156
                'message' => __d('community', 'Passwords are not equal')
157
            ]);
158
159
        return $validator;
160
    }
161
162
    /**
163
     * Find auth user.
164
     *
165
     * @param   Query $query
166
     * @param   array $options
167
     *
168
     * @return  \Cake\ORM\Query
169
     */
170
    public function findAuth(Query $query, array $options)
0 ignored issues
show
The parameter $options is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
171
    {
172
        return $query->where(['Users.status' => 1]);
173
    }
174
}
175