Issues (81)

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/models/forms/ChangePasswordForm.php (3 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 zacksleo\yii2\backend\models\forms;
3
4
use yii;
5
use yii\base\InvalidParamException;
6
use yii\base\Model;
7
use zacksleo\yii2\backend\models\Admin;
8
9
/**
10
 * Password reset form
11
 */
12
class ChangePasswordForm extends Model
13
{
14
    public $old_password;
15
    public $new_password;
16
    public $new_password_repeat;
17
18
    /**
19
     * @var \zacksleo\yii2\backend\models\Admin
20
     */
21
    private $_user;
22
23
    /**
24
     * Creates a form model
25
     *
26
     * @param  array $config name-value pairs that will be used to initialize the object properties
27
     * @throws \yii\base\InvalidParamException if token is empty or not valid
28
     */
29 2
    public function __construct($config = [])
30
    {
31 2
        $this->_user = Admin::findOne(Yii::$app->user->id);
0 ignored issues
show
Documentation Bug introduced by
It seems like \zacksleo\yii2\backend\m...e(\yii::$app->user->id) can also be of type object<yii\db\ActiveRecordInterface> or array. However, the property $_user is declared as type object<zacksleo\yii2\backend\models\Admin>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
32 2
        if (!$this->_user) {
33
            throw new InvalidParamException('用户不存在');
0 ignored issues
show
Deprecated Code introduced by
The class yii\base\InvalidParamException has been deprecated with message: since 2.0.14. Use [[InvalidArgumentException]] instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
34
        }
35 2
        parent::__construct($config);
36 2
    }
37
38 1
    public function attributeLabels()
39
    {
40
        return [
41 1
            'old_password' => '旧密码',
42
            'new_password' => '新密码',
43
            'new_password_repeat' => '重新输入新密码',
44
        ];
45
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50 1
    public function rules()
51
    {
52
        return [
53 1
            [['old_password', 'new_password', 'new_password_repeat'], 'required'],
54
            [['new_password', 'new_password_repeat'], 'string', 'min' => 6],
55
            ['new_password_repeat', 'compare', 'compareAttribute' => 'new_password'],
56
57
            ['new_password', 'match', 'pattern' => '/\d/', 'message' => '密码至少包含一位数字'],
58
            ['new_password', 'match', 'pattern' => '/[a-zA-Z]/', 'message' => '密码至少包含一个字母'],
59
60
            ['old_password', 'verifyOldPassword', 'message' => '旧密码不正确'],
61
        ];
62
    }
63
64
    /**
65
     * 验证原来密码
66
     * @inheritdoc
67
     */
68 1
    public function verifyOldPassword($attribute, $params)
0 ignored issues
show
The parameter $params 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...
69
    {
70 1
        if (!$this->_user->validatePassword($this->old_password)) {
71 1
            $this->addError($attribute, '旧密码不正确');
72
        }
73 1
    }
74
75
    /**
76
     * Resets password.
77
     *
78
     * @return boolean if password was reset.
79
     */
80 1
    public function resetPassword()
81
    {
82 1
        return $this->_user->resetPassword($this->new_password);
83
    }
84
}
85