Issues (12)

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/DefaultController.php (1 issue)

Severity

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\post\controllers;
4
5
use Yii;
6
use zacksleo\yii2\post\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 DefaultController extends Controller
16
{
17
    //todo 前缀名要修改
18
    public function actions()
19
    {
20
        return [
21
            'upload' => [
22
                'class' => 'kucha\ueditor\UEditorAction',
23
                'config' => [
24
                    "imageUrlPrefix" => Yii::$app->request->hostInfo,//图片访问路径前缀
25
                    "imagePathFormat" => "/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", //上传保存路径
26
                    "imageRoot" => Yii::getAlias("@webroot"),
27
                ],
28
            ]
29
        ];
30
    }
31
32
    /**
33
     * Lists all Post models.
34
     * @return mixed
35
     */
36
    public function actionIndex()
37
    {
38
        $dataProvider = new ActiveDataProvider([
39
            'query' => Post::find(),
40
            'sort' => [
41
                'defaultOrder' => [
42
                    'created_at' => SORT_DESC
43
                ]
44
            ]
45
        ]);
46
47
        return $this->render('index', [
48
            'dataProvider' => $dataProvider,
49
        ]);
50
    }
51
52
    /**
53
     * Displays a single Post model.
54
     * @param integer $id
55
     * @return mixed
56
     */
57
    public function actionView($id)
58
    {
59
        return $this->render('view', [
60
            'model' => $this->findModel($id),
61
        ]);
62
    }
63
64
    /**
65
     * Creates a new Post model.
66
     * If creation is successful, the browser will be redirected to the 'view' page.
67
     * @return mixed
68
     */
69
    public function actionCreate()
70
    {
71
        $model = new Post();
72
        $model->setScenario('insert');
73
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
74
            return $this->redirect(['view', 'id' => $model->id]);
75
        } else {
76
            return $this->render('create', [
77
                'model' => $model,
78
            ]);
79
        }
80
    }
81
82
    /**
83
     * Updates an existing Post model.
84
     * If update is successful, the browser will be redirected to the 'view' page.
85
     * @param integer $id
86
     * @return mixed
87
     */
88
    public function actionUpdate($id)
89
    {
90
        $model = $this->findModel($id);
91
        $model->setScenario('update');
92
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
93
            return $this->redirect(['view', 'id' => $model->id]);
94
        } else {
95
            return $this->render('update', [
96
                'model' => $model,
97
            ]);
98
        }
99
    }
100
101
    /**
102
     * Deletes an existing Post model.
103
     * If deletion is successful, the browser will be redirected to the 'index' page.
104
     * @param integer $id
105
     * @return mixed
106
     */
107
    public function actionDelete($id)
108
    {
109
        $this->findModel($id)->delete();
110
111
        return $this->redirect(['index']);
112
    }
113
114
    /**
115
     * Finds the Post model based on its primary key value.
116
     * If the model is not found, a 404 HTTP exception will be thrown.
117
     * @param integer $id
118
     * @return Post the loaded model
119
     * @throws NotFoundHttpException if the model cannot be found
120
     */
121
    protected function findModel($id)
122
    {
123
        if (($model = Post::findOne($id)) !== null) {
124
            return $model;
125
        } else {
126
            throw new NotFoundHttpException('The requested page does not exist.');
127
        }
128
    }
129
130
131
    /**
132
     * @brief 修改文章状态1显示:0不显示
133
     * @param $id
134
     * @param $status
135
     * @return
136
     */
137
    public function actionStatus($id, $status)
138
    {
139
        $model = $this->findModel($id);
140
        $model->status = $status;
0 ignored issues
show
The property status does not exist on object<zacksleo\yii2\post\models\Post>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
141
        $model->save();
142
        if ($model !== false) {
143
            $message = ['status' => 1, 'message' => "修改成功"];
144
        } else {
145
            $message = ['status' => 0, 'message' => "修改失败"];
146
        }
147
        \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
148
        return $message;
149
    }
150
}
151