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/objects/UserTypeMutatorTrait.php (1 issue)

Severity

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\objects;
10
11
use flipbox\organizations\records\UserType;
12
13
/**
14
 * @author Flipbox Factory <[email protected]>
15
 * @since 1.0.0
16
 */
17
trait UserTypeMutatorTrait
18
{
19
    /**
20
     * @param int|null $id
21
     */
22
    abstract protected function internalSetTypeId(int $id = null);
23
24
    /**
25
     * @return int|null
26
     */
27
    abstract protected function internalGetTypeId();
28
29
    /**
30
     * @param UserType|null $type
31
     */
32
    abstract protected function internalSetType(UserType $type = null);
33
34
    /**
35
     * @return UserType|null
36
     */
37
    abstract protected function internalGetType();
38
39
    /**
40
     * @param $id
41
     * @return $this
42
     */
43
    public function setTypeId(int $id = null)
44
    {
45
        $this->internalSetTypeId($id);
46
47
        if (null !== $this->internalGetType() && $id != $this->internalGetType()->id) {
48
            $this->internalSetType(null);
49
        }
50
51
        return $this;
52
    }
53
54
    /**
55
     * @return int|null
56
     */
57
    public function getTypeId()
58
    {
59
        if (null === $this->internalGetTypeId() && null != $this->internalGetType()) {
60
            $this->setTypeId($this->internalGetType()->id);
61
        }
62
63
        return $this->internalGetTypeId();
64
    }
65
66
    /**
67
     * @param $type
68
     * @return $this
69
     */
70
    public function setType($type = null)
71
    {
72
        $this->internalSetType(null);
73
        $this->internalSetTypeId(null);
74
75
        if ($type = $this->internalResolveType($type)) {
76
            $this->internalSetType($type);
0 ignored issues
show
$type is of type object<yii\db\ActiveRecordInterface>|array, but the function expects a null|object<flipbox\orga...tions\records\UserType>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
77
            $this->internalSetTypeId($type->id);
78
        }
79
80
        return $this;
81
    }
82
83
    /**
84
     * @return UserType|null
85
     */
86
    public function getType()
87
    {
88
        if ($this->internalGetType() === null) {
89
            $type = $this->resolveType();
90
            $this->setType($type);
91
            return $type;
92
        }
93
94
        $typeId = $this->internalGetTypeId();
95
        if ($typeId !== null && $typeId != $this->internalGetType()->id) {
96
            $this->internalSetType(null);
97
            return $this->getType();
98
        }
99
100
        return $this->internalGetType();
101
    }
102
103
    /**
104
     * @return UserType|null
105
     */
106
    protected function resolveType()
107
    {
108
        if ($type = $this->resolveTypeFromId()) {
109
            return $type;
110
        }
111
112
        return null;
113
    }
114
115
    /**
116
     * @return UserType|null
117
     */
118
    private function resolveTypeFromId()
119
    {
120
        if (null === $this->internalGetTypeId()) {
121
            return null;
122
        }
123
124
        return UserType::findOne($this->internalGetTypeId());
125
    }
126
127
    /**
128
     * @param $type
129
     * @return UserType|null
130
     */
131
    protected function internalResolveType($type = null)
132
    {
133
        if ($type === null) {
134
            return null;
135
        }
136
137
        if ($type instanceof UserType) {
138
            return $type;
139
        }
140
141
        return UserType::findOne($type);
142
    }
143
}
144