Issues (1237)

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.

frontend/controllers/SiteController.php (4 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
namespace frontend\controllers;
3
4
use Yii;
5
use common\models\LoginForm;
6
use frontend\models\PasswordResetRequestForm;
7
use frontend\models\ResetPasswordForm;
8
use frontend\models\SignupForm;
9
use frontend\models\ContactForm;
10
use yii\base\InvalidParamException;
11
use yii\web\BadRequestHttpException;
12
use yii\web\Controller;
13
use yii\filters\VerbFilter;
14
use yii\filters\AccessControl;
15
16
/**
17
 * Site controller
18
 */
19
class SiteController extends Controller
20
{
21
    /**
22
     * @inheritdoc
23
     */
24
    public function behaviors()
25
    {
26
        return [
27
            'access' => [
28
                'class' => AccessControl::className(),
29
                'only' => ['logout', 'signup'],
30
                'rules' => [
31
                    [
32
                        'actions' => ['signup'],
33
                        'allow' => true,
34
                        'roles' => ['?'],
35
                    ],
36
                    [
37
                        'actions' => ['logout'],
38
                        'allow' => true,
39
                        'roles' => ['@'],
40
                    ],
41
                ],
42
            ],
43
            'verbs' => [
44
                'class' => VerbFilter::className(),
45
                'actions' => [
46
                    'logout' => ['post'],
47
                ],
48
            ],
49
        ];
50
    }
51
52
    /**
53
     * @inheritdoc
54
     */
55
    public function actions()
56
    {
57
        return [
58
            'error' => [
59
                'class' => 'yii\web\ErrorAction',
60
            ],
61
            'captcha' => [
62
                'class' => 'yii\captcha\CaptchaAction',
63
                'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
64
            ],
65
        ];
66
    }
67
68
    /**
69
     * Displays homepage.
70
     *
71
     * @return mixed
72
     */
73
    public function actionIndex()
74
    {
75
        return $this->render('index');
76
    }
77
78
    /**
79
     * Logs in a user.
80
     *
81
     * @return mixed
82
     */
83 View Code Duplication
    public function actionLogin()
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...
84
    {
85
        if (!\Yii::$app->user->isGuest) {
86
            return $this->goHome();
87
        }
88
89
        $model = new LoginForm();
90
        if ($model->load(Yii::$app->request->post()) && $model->login()) {
91
            return $this->goBack();
92
        } else {
93
            return $this->render('login', [
94
                'model' => $model,
95
            ]);
96
        }
97
    }
98
99
    /**
100
     * Logs out the current user.
101
     *
102
     * @return mixed
103
     */
104
    public function actionLogout()
105
    {
106
        Yii::$app->user->logout();
107
108
        return $this->goHome();
109
    }
110
111
    /**
112
     * Displays contact page.
113
     *
114
     * @return mixed
115
     */
116 View Code Duplication
    public function actionContact()
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...
117
    {
118
        $model = new ContactForm();
119
        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
120
            if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
121
                Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
122
            } else {
123
                Yii::$app->session->setFlash('error', 'There was an error sending email.');
124
            }
125
126
            return $this->refresh();
127
        } else {
128
            return $this->render('contact', [
129
                'model' => $model,
130
            ]);
131
        }
132
    }
133
134
    /**
135
     * Displays about page.
136
     *
137
     * @return mixed
138
     */
139
    public function actionAbout()
140
    {
141
        return $this->render('about');
142
    }
143
144
    /**
145
     * Signs user up.
146
     *
147
     * @return mixed
148
     */
149
    public function actionSignup()
150
    {
151
        $model = new SignupForm();
152
        if ($model->load(Yii::$app->request->post())) {
153
            if ($user = $model->signup()) {
154
                if (Yii::$app->getUser()->login($user)) {
0 ignored issues
show
The method getUser 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...
155
                    return $this->goHome();
156
                }
157
            }
158
        }
159
160
        return $this->render('signup', [
161
            'model' => $model,
162
        ]);
163
    }
164
165
    /**
166
     * Requests password reset.
167
     *
168
     * @return mixed
169
     */
170 View Code Duplication
    public function actionRequestPasswordReset()
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...
171
    {
172
        $model = new PasswordResetRequestForm();
173
        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
174
            if ($model->sendEmail()) {
175
                Yii::$app->session->setFlash('success', 'Check your email for further instructions.');
176
177
                return $this->goHome();
178
            } else {
179
                Yii::$app->session->setFlash('error', 'Sorry, we are unable to reset password for email provided.');
180
            }
181
        }
182
183
        return $this->render('requestPasswordResetToken', [
184
            'model' => $model,
185
        ]);
186
    }
187
188
    /**
189
     * Resets password.
190
     *
191
     * @param string $token
192
     * @return mixed
193
     * @throws BadRequestHttpException
194
     */
195
    public function actionResetPassword($token)
196
    {
197
        try {
198
            $model = new ResetPasswordForm($token);
199
        } catch (InvalidParamException $e) {
200
            throw new BadRequestHttpException($e->getMessage());
201
        }
202
203
        if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) {
204
            Yii::$app->session->setFlash('success', 'New password was saved.');
205
206
            return $this->goHome();
207
        }
208
209
        return $this->render('resetPassword', [
210
            'model' => $model,
211
        ]);
212
    }
213
}
214