Issues (174)

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.

models/invitation/Invitation.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
 *  _   __ __ _____ _____ ___  ____  _____
5
 * | | / // // ___//_  _//   ||  __||_   _|
6
 * | |/ // /(__  )  / / / /| || |     | |
7
 * |___//_//____/  /_/ /_/ |_||_|     |_|
8
 * @link https://vistart.me/
9
 * @copyright Copyright (c) 2016 - 2017 vistart
10
 * @license https://vistart.me/license/
11
 */
12
13
namespace rhosocial\user\models\invitation;
14
15
use rhosocial\base\models\models\BaseBlameableModel;
16
use rhosocial\base\models\queries\BaseBlameableQuery;
17
use rhosocial\user\User;
18
19
/**
20
 * Class Invitation
21
 * This class is used to record each invitation of the current user. If you want to use the invitation code, please
22
 * refer to the [[InvitationCode]] class.
23
 * You can not use this class directly, but you need to declare and use specific invitation scenes, see [[Registration]].
24
 *
25
 * @property integer $content Invitation Type. The custom value range should be greater than or equal to 0x80.
26
 * Once this value is determined, no modification is recommended.
27
 * @property User|string $invitee Invited person.
28
 * @property string $invitee_guid The GUID of invited person.
29
 * Once this value is determined, no modification is recommended.
30
 *
31
 * @package rhosocial\user\models\invitation
32
 * @version 1.0
33
 * @author vistart <[email protected]>
34
 */
35
abstract class Invitation extends BaseBlameableModel
36
{
37
    public $hostClass = User::class;
38
    public $idAttribute = false;
39
    public $updatedAtAttribute = false;
40
    /**
41
     * @var array The content field in the data table should be an integer.
42
     */
43
    public $contentAttributeRule = ['integer'];
44
    /**
45
     * @var bool Whether to allow to send invitation to the same invitee repeatedly.
46
     */
47
    public $allowRepeated = true;
48
49
    /**
50
     * @return array
51
     */
52
    public function getInviteeRules()
53
    {
54
        $rules = [
55
            ['invitee_guid', 'required'],
56
            ['invitee_guid', 'string'],
57
        ];
58
        if (!$this->allowRepeated) {
59
            $rules[] = [
60
                [$this->createdByAttribute, $this->contentAttribute, 'invitee_guid'], 'unique', 'targetAttribute' => [
61
                    $this->createdByAttribute, $this->contentAttribute, 'invitee_guid',
62
                ]
63
            ];
64
        }
65
        return $rules;
66
    }
67
68
    /**
69
     * @return array
70
     */
71
    public function rules()
72
    {
73
        return array_merge(parent::rules(), $this->getInviteeRules());
74
    }
75
76
    /**
77
     * @param User|string $invitee
78
     * @return string
79
     */
80
    public function setInvitee($invitee)
81
    {
82
        return $this->invitee_guid = (string)$invitee;
83
    }
84
85
    /**
86
     * @return User
87
     */
88
    public function getInvitee()
89
    {
90
        $userClass = $this->hostClass;
91
        return $userClass::findOne($this->invitee_guid);
92
    }
93
94
    /**
95
     * @param User|string|array $invitee
96
     * @return BaseBlameableQuery
97
     */
98
    public static function findByInvitee($invitee)
99
    {
100
        if (!is_array($invitee)) {
101
            $i[0] = $invitee;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$i was never initialized. Although not strictly required by PHP, it is generally a good practice to add $i = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
102
            $invitee = $i;
103
        }
104
        foreach ($invitee as $key => $i) {
105
            $invitee[$key] = (string)$i;
106
        }
107
        return static::find()->andWhere(['invitee_guid' => $invitee]);
108
    }
109
110
    /**
111
     * @return string
112
     */
113
    public static function tableName()
114
    {
115
        return '{{%user_invitation}}';
116
    }
117
}
118