Issues (52)

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/controllers/PostController.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 zacksleo\yii2\cms\controllers;
4
5
use Yii;
6
use zacksleo\yii2\cms\models\Post;
7
use yii\data\ActiveDataProvider;
8
use yii\web\Controller;
9
use yii\web\NotFoundHttpException;
10
use yii\filters\VerbFilter;
11
12
/**
13
 * PostController implements the CRUD actions for Post model.
14
 */
15
class PostController extends Controller
16
{
17
    public function beforeAction($action)
18
    {
19
        return parent::beforeAction($action);
20
    }
21
22
    /**
23
     * @inheritdoc
24
     */
25
    public function behaviors()
26
    {
27
        return [
28
            'verbs' => [
29
                'class' => VerbFilter::className(),
0 ignored issues
show
Deprecated Code introduced by
The method yii\base\BaseObject::className() has been deprecated with message: since 2.0.14. On PHP >=5.5, use `::class` instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
30
                'actions' => [
31
                    'delete' => ['POST'],
32
                ],
33
            ],
34
        ];
35
    }
36
37
    public function actions()
38
    {
39
        return [
40
            'upload' => [
41
                'class' => 'zacksleo\yii2\cms\actions\UEditorAction',
42
                'config' => [
43
                    //"imageUrlPrefix" => "http://www.baidu.com",//图片访问路径前缀
44
                    "imagePathFormat" => "/uploads/{yyyy}{mm}{dd}/{time}{rand:6}",
45
                    //上传保存路径
46
                    "imageRoot" => Yii::getAlias("@frontend/web"),
47
                ],
48
            ]
49
        ];
50
    }
51
52
    /**
53
     * Lists all Post models.
54
     * @return mixed
55
     */
56
    public function actionIndex()
57
    {
58
        $dataProvider = new ActiveDataProvider([
59
            'query' => Post::find(),
60
        ]);
61
62
        return $this->render('index', [
63
            'dataProvider' => $dataProvider,
64
        ]);
65
    }
66
67
    public function actionTag($name)
68
    {
69
        $dataProvider = new ActiveDataProvider([
70
            'query' => Post::find()->anyTagValues($name),
0 ignored issues
show
The method anyTagValues() does not seem to exist on object<yii\db\ActiveQueryInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
71
        ]);
72
73
        return $this->render('index', [
74
            'dataProvider' => $dataProvider,
75
        ]);
76
    }
77
78
    /**
79
     * Displays a single Post model.
80
     * @param integer $id
81
     * @return mixed
82
     */
83
    public function actionView($id)
84
    {
85
        return $this->render('view', [
86
            'model' => $this->findModel($id),
87
        ]);
88
    }
89
90
    /**
91
     * Creates a new Post model.
92
     * If creation is successful, the browser will be redirected to the 'view' page.
93
     * @return mixed
94
     */
95
    public function actionCreate()
96
    {
97
        $model = new Post();
98
99
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
100
            return $this->redirect(['view', 'id' => $model->id]);
101
        } else {
102
            return $this->render('create', [
103
                'model' => $model,
104
            ]);
105
        }
106
    }
107
108
    /**
109
     * Updates an existing Post model.
110
     * If update is successful, the browser will be redirected to the 'view' page.
111
     * @param integer $id
112
     * @return mixed
113
     */
114
    public function actionUpdate($id)
115
    {
116
        $model = $this->findModel($id);
117
118
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
119
            return $this->redirect(['view', 'id' => $model->id]);
120
        } else {
121
            return $this->render('update', [
122
                'model' => $model,
123
            ]);
124
        }
125
    }
126
127
    /**
128
     * Deletes an existing Post model.
129
     * If deletion is successful, the browser will be redirected to the 'index' page.
130
     * @param integer $id
131
     * @return mixed
132
     */
133
    public function actionDelete($id)
134
    {
135
        $this->findModel($id)->delete();
136
137
        return $this->redirect(['index']);
138
    }
139
140
    /**
141
     * Finds the Post model based on its primary key value.
142
     * If the model is not found, a 404 HTTP exception will be thrown.
143
     * @param integer $id
144
     * @return Post the loaded model
145
     * @throws NotFoundHttpException if the model cannot be found
146
     */
147
    protected function findModel($id)
148
    {
149
        if (($model = Post::findOne($id)) !== null) {
0 ignored issues
show
Bug Compatibility introduced by
The expression \zacksleo\yii2\cms\models\Post::findOne($id); of type yii\db\ActiveRecordInterface|array|null adds the type array to the return on line 150 which is incompatible with the return type documented by zacksleo\yii2\cms\contro...stController::findModel of type zacksleo\yii2\cms\models\Post.
Loading history...
150
            return $model;
151
        } else {
152
            throw new NotFoundHttpException('The requested page does not exist.');
153
        }
154
    }
155
}
156