Issues (9)

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.

ConfirmationRequest.php (4 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
namespace enigmatix\confirmation;
4
5
use yii\base\ErrorException;
6
use yii\behaviors\BlameableBehavior;
7
use yii\helpers\ArrayHelper;
8
use yii\behaviors\TimestampBehavior;
9
use Yii;
10
use yii\helpers\Url;
11
12
13
/**
14
 * This is the model class for table "{{%confirmation_request}}".
15
 *
16
 * @property integer $id
17
 * @property string $model
18
 * @property integer $object_id
19
 * @property string $object
20
 * @property string $release_token
21
 * @property integer $created_at
22
 * @property integer $updated_at
23
 * @property string $values
24
 * @property integer $created_by
25
 * @property integer $updated_by
26
 *
27
 * @property User $createdBy
28
 * @property User $updatedBy
29
 */
30
class ConfirmationRequest extends \yii\db\ActiveRecord
31
{
32
33
    protected $delivery = 'display';
34
35
    protected $secondFactor = 'email';
36
37
    /**
38
     * @inheritdoc
39
     */
40
    public static function tableName()
41
    {
42
        return '{{%confirmation_request}}';
43
    }
44
45
    /**
46
     * @inheritdoc
47
     */
48
    public function rules()
49
    {
50
        return [
51
            [['object_id'], 'integer'],
52
            [['object', 'values'], 'string'],
53
            [['model', 'release_token'], 'string', 'max' => 255],
54
            [['release_token'], 'default', 'value' => function($model, $attribute) { return $this->generateReleaseToken(); }],
55
            [['created_by'], 'exist', 'skipOnError' => true, 'targetClass' => $this->getUserClassName(), 'targetAttribute' => ['created_by' => 'id']],
56
            [['updated_by'], 'exist', 'skipOnError' => true, 'targetClass' => $this->getUserClassName(), 'targetAttribute' => ['updated_by' => 'id']],
57
        ];
58
    }
59
60
    /**
61
     * @inheritdoc
62
     */
63
    public function attributeLabels()
64
    {
65
        return [
66
            'id' => Yii::t('app', 'ID'),
67
            'model' => Yii::t('app', 'Model'),
68
            'object_id' => Yii::t('app', 'Object'),
69
            'object' => Yii::t('app', 'Object'),
70
            'release_token' => Yii::t('app', 'Release Token'),
71
            'created_at' => Yii::t('app', 'Created At'),
72
            'updated_at' => Yii::t('app', 'Updated At'),
73
            'values' => Yii::t('app', 'Values'),
74
            'created_by' => Yii::t('app', 'Created By'),
75
            'updated_by' => Yii::t('app', 'Updated By'),
76
        ];
77
    }
78
79
80
    /**
81
     * @inheritdoc
82
     */
83
    public function relations()
84
    {
85
        return [
86
            'CreatedBy' => 'one',
87
            'UpdatedBy' => 'one',
88
        ];
89
    }
90
91
    public function behaviors() {
92
93
        return ArrayHelper::merge(parent::behaviors(),
94
            [
95
                TimestampBehavior::className(),
96
                BlameableBehavior::className(),
97
            ]);
98
    }
99
100
    public function getViewLink() {
101
        return Url::to(['@web/confirmation-requests', 'release_token' => $this->release_token], true);
102
    }
103
104
    /**
105
     * Generates new password reset token
106
     */
107
    public function generateReleaseToken()
108
    {
109
        return Yii::$app->security->generateRandomString() . '_' . time();
110
    }
111
112
113
    /**
114
     * @return \yii\db\ActiveQuery
115
     */
116
    public function getCreatedBy()
117
    {
118
        return $this->hasOne($this->getUserClassName(), ['id' => 'created_by']);
119
    }
120
121
    /**
122
     * @return \yii\db\ActiveQuery
123
     */
124
    public function getUpdatedBy()
125
    {
126
        return $this->hasOne($this->getUserClassName(), ['id' => 'updated_by']);
127
    }
128
129
    /**
130
     * @return string ActiveRecord user class, as per application implementation
131
     */
132
    protected function getUserClassName() {
133
        return Yii::$app->user->identityClass;
134
    }
135
136
    public function release() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
137
138
        $model          = $this->constructObject();
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 10 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
139
        $changedValues  = $model->getChangedValues();
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 1 space but found 2 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
140
        $current        = clone $model;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 8 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
141
        $current->refresh();
142
143
        foreach ($changedValues as $field => $value) {
144
            $oldValue = $model->oldAttributes[$field];
145
            if ($current->$field !== $oldValue && $current->$field !== $value) {
146
                throw new ErrorException(
147
                    sprintf('Unable to release change, protected field %s has been updated since this request.'
148
                    . ' Expected to find %s or %s, found %s', $field, $value, $oldValue, $current->$field));
149
            }
150
151
        }
152
153
        $model->releaseToken = $this->release_token;
154
        return $model->save();
155
156
    }
157
158
159
    /**
160
     * @return \enigmatix\core\Model
161
     */
162
    public function constructObject() {
163
        return unserialize($this->object);
164
    }
165
166
167
}
168