Issues (55)

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/queries/UserAssociationQuery.php (1 issue)

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
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/organization/license
6
 * @link       https://www.flipboxfactory.com/software/organization/
7
 */
8
9
namespace flipbox\organizations\queries;
10
11
use craft\db\QueryAbortedException;
12
use craft\helpers\Db;
13
use flipbox\craft\ember\queries\CacheableActiveQuery;
14
use flipbox\craft\ember\queries\UserAttributeTrait;
15
use flipbox\organizations\records\UserAssociation;
16
use flipbox\organizations\records\UserTypeAssociation;
17
18
/**
19
 * @author Flipbox Factory <[email protected]>
20
 * @since 1.0.0
21
 *
22
 * @method UserAssociation one($db = null)
23
 * @method UserAssociation[] all($db = null)
24
 * @method UserAssociation[] getCachedResult($db = null)
25
 */
26
class UserAssociationQuery extends CacheableActiveQuery
27
{
28
    use UserAttributeTrait,
29
        OrganizationAttributeTrait,
30
        UserTypeAttributeTrait;
31
32
    /**
33
     * @var string|string[]|null
34
     */
35
    public $state;
36
37
    /**
38
     * @param string|string[]|null $value
39
     * @return static The query object
40
     */
41
    public function setState($value)
42
    {
43
        $this->state = $value;
44
        return $this;
45
    }
46
47
    /**
48
     * @param string|string[]|null $value
49
     * @return static The query object
50
     */
51
    public function state($value)
52
    {
53
        return $this->setState($value);
54
    }
55
56
    /**
57
     * @inheritdoc
58
     */
59
    public function init()
60
    {
61
        $this->from([
62
            UserAssociation::tableName() . ' ' . UserAssociation::tableAlias()
63
        ]);
64
65
        parent::init();
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    protected function joinUserTypeTable(): string
72
    {
73
        $name = UserTypeAssociation::tableName();
74
        $alias = UserTypeAssociation::tableAlias();
75
76
        $table = "{$name} {$alias}";
77
78
        if (!is_array($this->join) || !$this->isJoined($table)) {
0 ignored issues
show
Documentation Bug introduced by
The method isJoined does not exist on object<flipbox\organizat...s\UserAssociationQuery>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
79
            $this->leftJoin(
80
                $table,
81
                '[[' . $alias . '.userId]] = [['. UserAssociation::tableAlias() .'.id]]'
82
            );
83
        }
84
85
        return $alias;
86
    }
87
88
    /**
89
     * @inheritdoc
90
     * @throws QueryAbortedException
91
     */
92
    public function prepare($builder)
93
    {
94
        $attributes = ['state'];
95
96
        foreach ($attributes as $attribute) {
97
            if (null !== ($value = $this->{$attribute})) {
98
                $this->andWhere(Db::parseParam($attribute, $value));
99
            }
100
        }
101
102
        $this->applyUserParam();
103
        $this->applyOrganizationParam();
104
        $this->applyUserTypeParam();
105
106
        return parent::prepare($builder);
107
    }
108
109
    /**
110
     * @return void
111
     * @throws QueryAbortedException
112
     */
113
    protected function applyUserParam()
114
    {
115
        // Is the query already doomed?
116
        if ($this->user !== null && empty($this->user)) {
117
            throw new QueryAbortedException();
118
        }
119
120
        if (empty($this->user)) {
121
            return;
122
        }
123
124
        $this->andWhere(
125
            Db::parseParam('userId', $this->parseUserValue($this->user))
126
        );
127
    }
128
129
    /**
130
     * @return void
131
     * @throws QueryAbortedException
132
     */
133
    protected function applyOrganizationParam()
134
    {
135
        // Is the query already doomed?
136
        if ($this->organization !== null && empty($this->organization)) {
137
            throw new QueryAbortedException();
138
        }
139
140
        if (empty($this->organization)) {
141
            return;
142
        }
143
144
        $this->andWhere(
145
            Db::parseParam('organizationId', $this->parseOrganizationValue($this->organization))
146
        );
147
    }
148
149
    /**
150
     * @return void
151
     * @throws QueryAbortedException
152
     */
153
    protected function applyUserTypeParam()
154
    {
155
        // Is the query already doomed?
156
        if ($this->userType !== null && empty($this->userType)) {
157
            throw new QueryAbortedException();
158
        }
159
160
        if (empty($this->userType)) {
161
            return;
162
        }
163
164
        $alias = $this->joinUserTypeTable();
165
166
        $this->andWhere(
167
            Db::parseParam($alias . '.typeId', $this->parseUserTypeValue($this->userType))
168
        );
169
    }
170
}
171