Issues (12)

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/storage/ClientQuery.php (5 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
 * HIAM module for MRDP database compatibility
4
 *
5
 * @link      https://github.com/hiqdev/hiam-mrdp
6
 * @package   hiam-mrdp
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiam\mrdp\storage;
12
13
use yii\db\Query;
14
15
class ClientQuery extends \yii\db\ActiveQuery
16
{
17
    public function init()
18
    {
19
        parent::init();
20
        $this
21
            ->select([
22
                'c.obj_id       AS id',
23
                'c.login        AS username',
24
                'r.login        AS seller',
25
                'c.seller_id    AS seller_id',
26
                'y.name         AS type',
27
                'z.name         AS state',
28
                'e.roles        AS roles',
29
                'k.first_name   AS first_name',
30
                'k.last_name    AS last_name',
31
                't.value        AS totp_secret',
32
                'to_1(has_deposits(c.obj_id)) AS verified',
33
                'coalesce(i.value,l.value) AS allowed_ips',
34
                'coalesce(c.email,k.email) AS email',
35
                "encode(digest(c.password, 'sha1'), 'hex') AS password_hash",
36
                'o.value        AS email_confirmed'
37
            ])
38
            ->from('zclient             c')
39
            ->innerJoin('zclient        r', 'r.obj_id=c.seller_id')
40
            ->innerJoin('zref           y', 'y.obj_id=c.type_id')
41
            ->innerJoin('zref           z', 'z.obj_id=c.state_id')
42
            ->leftJoin('contact         k', 'k.obj_id=c.obj_id')
43
            ->leftJoin('value           t', "t.obj_id=c.obj_id AND t.prop_id=prop_id('client,access:totp_secret')")
44
            ->leftJoin('value           i', "i.obj_id=c.obj_id AND i.prop_id=prop_id('client,access:allowed_ips')")
45
            ->leftJoin('value           l', "l.obj_id=c.obj_id AND l.prop_id=prop_id('login_ips:panel')")
46
            ->leftJoin('value           o', "o.obj_id=c.obj_id AND o.prop_id=prop_id('contact:email_confirmed')")
47
            ->leftJoin('client2rolez    e', 'e.client_id=c.obj_id')
48
            ->andWhere(['in', 'z.name', ['ok', 'new']]);
49
    }
50
51
    public function andWhere($condition, $params = [])
52
    {
53
        if (!is_array($condition) || isset($condition[0])) {
54
            return parent::andWhere($condition, $params);
55
        }
56
        foreach (['id', 'username', 'password', 'email', 'active'] as $key) {
57
            /// XXX `isset` does not fit here
58
            if (array_key_exists($key, $condition)) {
59
                $this->{"where$key"}($condition[$key]);
60
                unset($condition[$key]);
61
            }
62
        }
63
        if (!empty($condition)) {
64
            parent::andWhere($condition, $params);
65
        }
66
67
        return $this;
68
    }
69
70
    public function whereId($id)
71
    {
72
        return parent::andWhere(['c.obj_id' => $id]);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (andWhere() instead of whereId()). Are you sure this is correct? If so, you might want to change this to $this->andWhere().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
73
    }
74
75
    public function whereEmail($username)
76
    {
77
        return parent::andWhere(['or', 'c.login=:username', 'c.email=:username'], [':username' => $username]);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (andWhere() instead of whereEmail()). Are you sure this is correct? If so, you might want to change this to $this->andWhere().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
78
    }
79
80
    public function whereUsername($username)
81
    {
82
        $userId = (int)$username;
83
        if ($userId > 0 && "$userId" === trim($username)) {
84
            return $this->whereId($userId);
85
        }
86
87
        return parent::andWhere(['or', 'c.login=:username', 'c.email=:username'], [':username' => $username]);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (andWhere() instead of whereUsername()). Are you sure this is correct? If so, you might want to change this to $this->andWhere().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
88
    }
89
90
    public function wherePassword($password)
91
    {
92
        return parent::andWhere(
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (andWhere() instead of wherePassword()). Are you sure this is correct? If so, you might want to change this to $this->andWhere().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
93
            'check_password(:password,c.password) OR check_password(:password,tmp.value)',
94
            [':password' => $password]
95
        )->leftJoin('value tmp', "tmp.obj_id=c.obj_id AND tmp.prop_id=prop_id('client,access:tmp_pwd')");
96
    }
97
98
    public function whereActive($is_active)
99
    {
100
        if (is_null($is_active)) {
101
            return $this;
102
        }
103
104
        return parent::andWhere([$is_active ? 'in' : 'not in', 'z.name', ['ok', 'active']]);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (andWhere() instead of whereActive()). Are you sure this is correct? If so, you might want to change this to $this->andWhere().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
105
    }
106
}
107