Issues (73)

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/Flow.php (3 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 app\models;
4
5
use Yii;
6
7
/**
8
 * This is the model class for table "flow".
9
 *
10
 * @property int $id
11
 * @property string $name
12
 * @property string $description
13
 * @property int $parent_id
14
 * @property Content[] $contents
15
 * @property Flow $parent
16
 * @property Flow[] $flows
17
 * @property ScreenHasFlow[] $screenHasFlows
18
 * @property Screen[] $screens
19
 * @property UserHasFlow[] $userHasFlows
20
 * @property User[] $users
21
 */
22
class Flow extends \yii\db\ActiveRecord
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public static function tableName()
28
    {
29
        return 'flow';
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 View Code Duplication
    public function rules()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    {
37
        return [
38
            [['name'], 'required'],
39
            [['parent_id', 'id'], 'integer'],
40
            [['name'], 'string', 'max' => 64],
41
            [['description'], 'string', 'max' => 1024],
42
            [['parent'], 'safe'],
43
            [['parent_id'], 'exist', 'skipOnError' => true, 'targetClass' => self::class, 'targetAttribute' => ['parent_id' => 'id']],
44
        ];
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function attributeLabels()
51
    {
52
        return [
53
            'id' => Yii::t('app', 'ID'),
54
            'name' => Yii::t('app', 'Name'),
55
            'description' => Yii::t('app', 'Description'),
56
            'parent_id' => Yii::t('app', 'Parent'),
57
            'parent' => Yii::t('app', 'Parent flow'),
58
        ];
59
    }
60
61
    /**
62
     * @return \yii\db\ActiveQuery
63
     */
64
    public function getContents()
65
    {
66
        return $this->hasMany(Content::class, ['flow_id' => 'id']);
67
    }
68
69
    /**
70
     * @return \yii\db\ActiveQuery
71
     */
72
    public function getParent()
73
    {
74
        return $this->hasOne(self::class, ['id' => 'parent_id']);
75
    }
76
77
    /**
78
     * Set parent_id with flow.
79
     *
80
     * @param \app\models\Flow $flow parent flow
81
     */
82
    public function setParent($flow)
83
    {
84
        $this->parent_id = $flow->id;
85
    }
86
87
    /**
88
     * @return \yii\db\ActiveQuery
89
     */
90
    public function getChildren()
91
    {
92
        return $this->hasMany(self::class, ['parent_id' => 'id']);
93
    }
94
95
    /**
96
     * @return \yii\db\ActiveQuery
97
     */
98
    public function getScreenHasFlows()
99
    {
100
        return $this->hasMany(ScreenHasFlow::class, ['flow_id' => 'id']);
101
    }
102
103
    /**
104
     * @return \yii\db\ActiveQuery
105
     */
106
    public function getScreens()
107
    {
108
        return $this->hasMany(Screen::class, ['id' => 'screen_id'])->viaTable('screen_has_flow', ['flow_id' => 'id']);
109
    }
110
111
    /**
112
     * @return \yii\db\ActiveQuery
113
     */
114
    public function getUserHasFlows()
115
    {
116
        return $this->hasMany(UserHasFlow::class, ['flow_id' => 'id']);
117
    }
118
119
    /**
120
     * @return \yii\db\ActiveQuery
121
     */
122
    public function getUsers()
123
    {
124
        return $this->hasMany(User::class, ['username' => 'user_username'])->viaTable('user_has_flow', ['flow_id' => 'id']);
125
    }
126
127
    /**
128
     * Build a query for a specific user, allowing to see only authorized flows.
129
     *
130
     * @param \yii\web\User $user
131
     *
132
     * @return \yii\db\ActiveQuery
133
     */
134
    public static function availableQuery($user)
135
    {
136 View Code Duplication
        if ($user->can('setFlowContent')) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
137
            return self::find();
138
        } elseif ($user->can('setOwnFlowContent') && $user->identity instanceof \app\models\User) {
139
            return self::find()->joinWith(['users'])->where(['username' => $user->identity->username]);
140
        }
141
    }
142
143
    /**
144
     * Check if a specific user is allowed to see this flow.
145
     *
146
     * @param \yii\web\User $user
147
     *
148
     * @return bool can see
149
     */
150 View Code Duplication
    public function canView($user)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
151
    {
152
        if ($user->can('setFlowContent')) {
153
            return true;
154
        }
155
        if ($user->can('setOwnFlowContent') && in_array($user->identity, $this->users)) {
156
            return true;
157
        }
158
159
        return false;
160
    }
161
}
162