Issues (89)

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.

modules/user/controllers/ManagementController.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\modules\user\controllers;
4
5
use app\modules\user\models\forms\UserForm;
6
use app\modules\user\models\User;
7
use Yii;
8
use app\modules\user\models\SearchUser;
9
use yii\filters\AccessControl;
10
use yii\web\Controller;
11
use yii\web\NotFoundHttpException;
12
13
/**
14
 * ManagementController implements the CRU actions for Users model.
15
 */
16
class ManagementController extends Controller
17
{
18
    /**
19
     * @inheritdoc
20
     */
21 7
    public function behaviors()
22
    {
23
        return [
24
            'access' => [
25 7
                'class' => AccessControl::className(),
26
                'rules' => [
27
                    [
28
                        'allow' => true,
29
                        'actions' => ['index', 'view', 'update'],
30
                        'roles' => [User::ROLE_ADMIN],
31
                    ],
32
                ],
33 7
            ],
34
        ];
35
    }
36
37
    /**
38
     * Lists all Users models.
39
     *
40
     * @return mixed
41
     */
42 1 View Code Duplication
    public function actionIndex()
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...
43
    {
44 1
        $searchModel = new SearchUser();
45 1
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
46
47 1
        return $this->render('index', [
48 1
            'searchModel' => $searchModel,
49 1
            'dataProvider' => $dataProvider,
50
        ]);
51
    }
52
53
    /**
54
     * Displays a single Users model.
55
     *
56
     * @param integer $id
57
     * @return mixed
58
     */
59 3
    public function actionView($id)
60
    {
61 3
        return $this->render('view', [
62 3
            'model' => $this->findModel($id),
63
        ]);
64
    }
65
66
    /**
67
     * Updates an existing Users model.
68
     * If update is successful, the browser will be redirected to the 'view' page.
69
     *
70
     * @param integer $id
71
     * @return mixed
72
     */
73 3
    public function actionUpdate($id)
74
    {
75 3
        $user = $this->findModel($id);
76 3
        $userForm = new UserForm();
77 3
        $userForm->setAttributes($user->attributes);
78 3
        $userForm->role = $user->getRoleName();
79
80 3
        if ($userForm->load(Yii::$app->request->post()) && $userForm->validate()) {
81 1
            $user->setAttributes($userForm->attributes);
82 1
            $user->update(false);
83 1
            $user->setRole($userForm->role);
84
85 1
            Yii::$app->getSession()->setFlash('success', Yii::t('user', 'Information saved.'));
0 ignored issues
show
The method getSession does only exist in yii\web\Application, but not in yii\console\Application.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
86 1
            return $this->redirect(['view', 'id' => $user->id]);
87
        }
88
89 3
        return $this->render('update', [
90 3
            'userForm' => $userForm,
91 3
            'id' => $user->id,
92
        ]);
93
    }
94
95
    /**
96
     * Finds the Users model based on its primary key value.
97
     * If the model is not found, a 404 HTTP exception will be thrown.
98
     *
99
     * @param integer $id
100
     * @return User the loaded model
101
     * @throws NotFoundHttpException if the model cannot be found
102
     */
103 5 View Code Duplication
    protected function findModel($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...
104
    {
105 5
        $model = User::findOne($id);
106 5
        if (null === $model) {
107
            throw new NotFoundHttpException('The requested page does not exist.');
108
        }
109 5
        return $model;
110
    }
111
}
112