Issues (13)

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

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
/**
4
 * @link http://phe.me
5
 * @copyright Copyright (c) 2014 Pheme
6
 * @license MIT http://opensource.org/licenses/MIT
7
 */
8
9
namespace pheme\settings\controllers;
10
11
use Yii;
12
use pheme\settings\models\Setting;
13
use pheme\settings\models\SettingSearch;
14
use pheme\grid\actions\ToggleAction;
15
use yii\filters\AccessControl;
16
use yii\web\Controller;
17
use yii\web\NotFoundHttpException;
18
use yii\filters\VerbFilter;
19
20
/**
21
 * SettingsController implements the CRUD actions for Setting model.
22
 *
23
 * @author Aris Karageorgos <[email protected]>
24
 */
25
class DefaultController extends Controller
26
{
27
    /**
28
     * Defines the controller behaviors
29
     * @return array
30
     */
31
    public function behaviors()
32
    {
33
        return [
34
            'verbs' => [
35
                'class' => VerbFilter::className(),
36
                'actions' => [
37
                    'delete' => ['post'],
38
                ],
39
            ],
40
            'access' => [
41
                'class' => AccessControl::className(),
42
                'rules' => [
43
                    [
44
                        'allow' => true,
45
                        'roles' => $this->module->accessRoles,
46
                    ],
47
                ],
48
            ],
49
        ];
50
    }
51
52
    public function actions()
53
    {
54
        return [
55
            'toggle' => [
56
                'class' => ToggleAction::className(),
57
                'modelClass' => 'pheme\settings\models\Setting',
58
                //'setFlash' => true,
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
59
            ]
60
        ];
61
    }
62
63
    /**
64
     * Lists all Settings.
65
     * @return mixed
66
     */
67
    public function actionIndex()
68
    {
69
        $searchModel = new SettingSearch();
70
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
71
72
        return $this->render(
73
            'index',
74
            [
75
                'searchModel' => $searchModel,
76
                'dataProvider' => $dataProvider,
77
            ]
78
        );
79
    }
80
81
    /**
82
     * Displays the details of a single Setting.
83
     * @param integer $id
84
     * @return mixed
85
     */
86
    public function actionView($id)
87
    {
88
        return $this->render(
89
            'view',
90
            [
91
                'model' => $this->findModel($id),
92
            ]
93
        );
94
    }
95
96
    /**
97
     * Creates a new Setting.
98
     * If creation is successful, the browser will be redirected to the 'view' page.
99
     * @return mixed
100
     */
101
    public function actionCreate()
102
    {
103
        $model = new Setting(['active' => 1]);
104
105
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
106
            return $this->redirect(['view', 'id' => $model->id]);
107
        } else {
108
            return $this->render(
109
                'create',
110
                [
111
                    'model' => $model,
112
                ]
113
            );
114
        }
115
    }
116
117
    /**
118
     * Updates an existing Setting.
119
     * If update is successful, the browser will be redirected to the 'view' page.
120
     * @param integer $id
121
     * @return mixed
122
     */
123
    public function actionUpdate($id)
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
            return $this->render(
131
                'update',
132
                [
133
                    'model' => $model,
134
                ]
135
            );
136
        }
137
    }
138
139
    /**
140
     * Deletes an existing Setting.
141
     * If deletion is successful, the browser will be redirected to the 'index' page.
142
     * @param integer $id
143
     * @return mixed
144
     */
145
    public function actionDelete($id)
146
    {
147
        if (Yii::$app->request->isPost) {
148
            $this->findModel($id)->delete();
149
        }
150
        return $this->redirect(['index']);
151
    }
152
153
    /**
154
     * Finds a Setting model based on its primary key value.
155
     * If the model is not found, a 404 HTTP exception will be thrown.
156
     * @param integer $id
157
     * @return Setting the loaded model
158
     * @throws NotFoundHttpException if the model cannot be found
159
     */
160
    protected function findModel($id)
161
    {
162
        if (($model = Setting::findOne($id)) !== null) {
163
            return $model;
164
        } else {
165
            throw new NotFoundHttpException('The requested page does not exist.');
166
        }
167
    }
168
}
169