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/Entity/User.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\Entity;
17
18
use Cake\Routing\Router;
19
use Cake\I18n\FrozenTime;
20
use Core\ORM\Entity\Entity;
21
use Cake\Auth\DefaultPasswordHasher;
22
23
/**
24
 * Class User
25
 *
26
 * @package     Community\Model\Entity
27
 *
28
 * @property    int        $id
29
 * @property    int        $group_id
30
 * @property    Group      $group
31
 * @property    string     $login
32
 * @property    string     $name
33
 * @property    string     $slug
34
 * @property    string     $email
35
 * @property    string     $password
36
 * @property    string     $token
37
 * @property    bool       $status
38
 * @property    FrozenTime $last_login
39
 * @property    FrozenTime $last_action
40
 * @property    FrozenTime $modified
41
 * @property    FrozenTime $created
42
 * @property    string     activation_url  Virtual field.
43
 */
44
class User extends Entity
45
{
46
47
    /**
48
     * List of computed or virtual fields that **should** be included in JSON or array
49
     * representations of this Entity. If a field is present in both _hidden and _virtual
50
     * the field will **not** be in the array/json versions of the entity.
51
     *
52
     * @var array
53
     */
54
    protected $_virtual = [
55
        'activation_url',
56
        'setup_password_url'
57
    ];
58
59
    /**
60
     * Get current user edit profile url.
61
     *
62
     * @param   bool $backend   Backend or frontend point.
63
     * @return  string
64
     */
65
    public function getEditUrl($backend = false)
66
    {
67
        $url = [
68
            'action'     => 'edit',
69
            'controller' => 'Users',
70
            'plugin'     => 'Community'
71
        ];
72
73
        if ($backend) {
74
            $url['prefix'] = 'admin';
75
            $url[] = $this->id;
76
        }
77
78
        return Router::url($url);
79
    }
80
81
    /**
82
     * Set virtual field activation_url.
83
     *
84
     * @return  string
85
     */
86 View Code Duplication
    protected function _getActivationUrl()
0 ignored issues
show
This method 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...
87
    {
88
        return Router::url([
89
            'controller' => 'Users',
90
            'action'     => 'activate',
91
            'plugin'     => 'Community',
92
            $this->id,
93
            $this->token
94
        ], true);
95
    }
96
97
    /**
98
     * set virtual field setup_password_url
99
     *
100
     * @return string
101
     */
102 View Code Duplication
    protected function _getSetupPasswordUrl()
0 ignored issues
show
This method 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...
103
    {
104
        return Router::url([
105
            'controller' => 'Users',
106
            'plugin'     => 'Community',
107
            'action'     => 'setupPassword',
108
            $this->id,
109
            $this->token
110
        ], true);
111
    }
112
113
    /**
114
     * Setup password.
115
     *
116
     * @param   string $password    User password for create hashed.
117
     * @return  null|string
118
     */
119
    protected function _setPassword($password)
120
    {
121
        if ($password !== null) {
122
            return (new DefaultPasswordHasher())->hash($password);
123
        }
124
125
        return null;
126
    }
127
}
128