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.

controllers/FlowController.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\controllers;
4
5
use Yii;
6
use app\models\Flow;
7
use app\models\Content;
8
use app\models\ContentType;
9
use yii\data\ActiveDataProvider;
10
use yii\web\NotFoundHttpException;
11
use yii\helpers\ArrayHelper;
12
use yii\filters\VerbFilter;
13
use yii\filters\AccessControl;
14
15
/**
16
 * FlowController implements the CRUD actions for Flow model.
17
 */
18
class FlowController extends BaseController
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function behaviors()
24
    {
25
        return [
26
            'verbs' => [
27
                'class' => VerbFilter::class,
28
                'actions' => [
29
                    'delete' => ['POST'],
30
                ],
31
            ],
32
            'access' => [
33
                'class' => AccessControl::class,
34
                'only' => ['index', 'view', 'create', 'update', 'delete'],
35
                'rules' => [
36
                    ['allow' => true, 'actions' => ['index', 'view'], 'roles' => ['@']],
37
                    ['allow' => true, 'actions' => ['create', 'update', 'delete'], 'roles' => ['setFlows']],
38
                ],
39
            ],
40
        ];
41
    }
42
43
    /**
44
     * Lists all Flow models.
45
     *
46
     * @return string
47
     */
48
    public function actionIndex()
49
    {
50
        $query = Flow::availableQuery(Yii::$app->user);
51
        if ($query === null) {
52
            throw new \yii\web\ForbiddenHttpException(Yii::t('app', 'You do not have enough rights to view this flow.'));
53
        }
54
55
        $dataProvider = new ActiveDataProvider([
56
            'query' => $query,
57
        ]);
58
59
        return $this->render('index', [
60
            'dataProvider' => $dataProvider,
61
        ]);
62
    }
63
64
    /**
65
     * Displays a single Flow model.
66
     *
67
     * @param int $id
68
     *
69
     * @return string
70
     */
71
    public function actionView($id)
72
    {
73
        $model = $this->findModel($id);
74
        if (!$model->canView(Yii::$app->user)) {
75
            throw new \yii\web\ForbiddenHttpException(Yii::t('app', 'You do not have enough rights to view this flow.'));
76
        }
77
78
        $dataProvider = new ActiveDataProvider([
79
            'query' => Content::find()->joinWith(['type', 'flow'])->where([Flow::tableName() . '.id' => $id]),
80
        ]);
81
82
        $dataProvider->sort->attributes['type.name'] = [
83
            'asc' => [ContentType::tableName() . '.id' => SORT_ASC],
84
            'desc' => [ContentType::tableName() . '.id' => SORT_DESC],
85
        ];
86
87
        return $this->render('view', [
88
            'model' => $this->findModel($id),
89
            'dataProvider' => $dataProvider,
90
        ]);
91
    }
92
93
    /**
94
     * Creates a new Flow model.
95
     * If creation is successful, the browser will be redirected to the 'view' page.
96
     *
97
     * @return \yii\web\Response|string redirect or render
98
     */
99 View Code Duplication
    public function actionCreate()
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...
100
    {
101
        $model = new Flow();
102
103
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
104
            return $this->redirect(['view', 'id' => $model->id]);
105
        } else {
106
            $flows = ArrayHelper::map(Flow::find()->all(), 'id', 'name');
107
108
            return $this->render('create', [
109
                'model' => $model,
110
                'flows' => ['' => Yii::t('app', '(none)')] + $flows,
111
            ]);
112
        }
113
    }
114
115
    /**
116
     * Updates an existing Flow model.
117
     * If update is successful, the browser will be redirected to the 'view' page.
118
     *
119
     * @param int $id
120
     *
121
     * @return \yii\web\Response|string redirect or render
122
     */
123 View Code Duplication
    public function actionUpdate($id)
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...
124
    {
125
        $model = $this->findModel($id);
126
127
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
128
            return $this->redirect(['view', 'id' => $model->id]);
129
        } else {
130
            $flows = ArrayHelper::map(Flow::find()->all(), 'id', 'name');
131
132
            return $this->render('update', [
133
                'model' => $model,
134
                'flows' => ['' => Yii::t('app', '(none)')] + $flows,
135
            ]);
136
        }
137
    }
138
139
    /**
140
     * Deletes an existing Flow model.
141
     * If deletion is successful, the browser will be redirected to the 'index' page.
142
     *
143
     * @param int $id
144
     *
145
     * @return \yii\web\Response
146
     */
147
    public function actionDelete($id)
148
    {
149
        $this->findModel($id)->delete();
150
151
        return $this->redirect(['index']);
152
    }
153
154
    /**
155
     * Finds the Flow model based on its primary key value.
156
     * If the model is not found, a 404 HTTP exception will be thrown.
157
     *
158
     * @param int $id
159
     *
160
     * @return Flow the loaded model
161
     *
162
     * @throws NotFoundHttpException if the model cannot be found
163
     */
164 View Code Duplication
    protected function findModel($id)
165
    {
166
        if (($model = Flow::findOne($id)) !== null) {
0 ignored issues
show
Bug Compatibility introduced by
The expression \app\models\Flow::findOne($id); of type yii\db\ActiveRecordInterface|array|null adds the type array to the return on line 167 which is incompatible with the return type documented by app\controllers\FlowController::findModel of type app\models\Flow.
Loading history...
167
            return $model;
168
        } else {
169
            throw new NotFoundHttpException(Yii::t('app', 'The requested flow does not exist.'));
170
        }
171
    }
172
}
173