Issues (272)

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.

app/controllers/UsersController.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
4
5
/**
6
 * UsersController Class
7
 *
8
 * Implements actions regarding user management
9
 */
10
class UsersController extends Controller
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
11
{
12
13
    /**
14
     * Displays the form for account creation
15
     *
16
     * @return  Illuminate\Http\Response
17
     */
18
    public function create()
19
    {
20
        return View::make(Config::get('confide::signup_form'));
21
    }
22
23
    /**
24
     * Stores new account
25
     *
26
     * @return  Illuminate\Http\Response
27
     */
28
    public function store()
29
    {
30
        $repo = App::make('UserRepository');
31
        $user = $repo->signup(Input::all());
32
33
        if ($user->id) {
34
            if (Config::get('confide::signup_email')) {
35
                Mail::queueOn(
36
                    Config::get('confide::email_queue'),
37
                    Config::get('confide::email_account_confirmation'),
38
                    compact('user'),
39
                    function ($message) use ($user) {
40
                        $message
41
                            ->to($user->email, $user->username)
42
                            ->subject(Lang::get('confide::confide.email.account_confirmation.subject'));
43
                    }
44
                );
45
            }
46
47
            return Redirect::action('UsersController@login')
48
                ->with('notice', Lang::get('confide::confide.alerts.account_created'));
49
        } else {
50
            $error = $user->errors()->all(':message');
51
52
            return Redirect::action('UsersController@create')
53
                ->withInput(Input::except('password'))
54
                ->with('error', $error);
55
        }
56
    }
57
58
    /**
59
     * Displays the login form
60
     *
61
     * @return  Illuminate\Http\Response
62
     */
63
    public function login()
64
    {
65
        if (Confide::user()) {
66
            return Redirect::to('/');
0 ignored issues
show
Bug Best Practice introduced by
The return type of return \Redirect::to('/'); (Illuminate\Http\RedirectResponse) is incompatible with the return type documented by UsersController::login of type Illuminate\Http\Response.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
67
        } else {
68
            return View::make(Config::get('confide::login_form'));
69
        }
70
    }
71
72
    /**
73
     * Attempt to do login
74
     *
75
     * @return  Illuminate\Http\Response
76
     */
77
    public function doLogin()
78
    {
79
        $repo = App::make('UserRepository');
80
        $input = Input::all();
81
82
        if ($repo->login($input)) {
83
            return Redirect::intended('/');
0 ignored issues
show
Bug Best Practice introduced by
The return type of return \Redirect::intended('/'); (Illuminate\Http\RedirectResponse) is incompatible with the return type documented by UsersController::doLogin of type Illuminate\Http\Response.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
84
        } else {
85
            if ($repo->isThrottled($input)) {
86
                $err_msg = Lang::get('confide::confide.alerts.too_many_attempts');
87
            } elseif ($repo->existsButNotConfirmed($input)) {
88
                $err_msg = Lang::get('confide::confide.alerts.not_confirmed');
89
            } else {
90
                $err_msg = Lang::get('confide::confide.alerts.wrong_credentials');
91
            }
92
93
            return Redirect::action('UsersController@login')
94
                ->withInput(Input::except('password'))
95
                ->with('error', $err_msg);
96
        }
97
    }
98
99
    /**
100
     * Attempt to confirm account with code
101
     *
102
     * @param  string $code
103
     *
104
     * @return  Illuminate\Http\Response
105
     */
106
    public function confirm($code)
107
    {
108
        if (Confide::confirm($code)) {
109
            $notice_msg = Lang::get('confide::confide.alerts.confirmation');
110
            return Redirect::action('UsersController@login')
111
                ->with('notice', $notice_msg);
112
        } else {
113
            $error_msg = Lang::get('confide::confide.alerts.wrong_confirmation');
114
            return Redirect::action('UsersController@login')
115
                ->with('error', $error_msg);
116
        }
117
    }
118
119
    /**
120
     * Displays the forgot password form
121
     *
122
     * @return  Illuminate\Http\Response
123
     */
124
    public function forgotPassword()
125
    {
126
        return View::make(Config::get('confide::forgot_password_form'));
127
    }
128
129
    /**
130
     * Attempt to send change password link to the given email
131
     *
132
     * @return  Illuminate\Http\Response
133
     */
134
    public function doForgotPassword()
135
    {
136
        if (Confide::forgotPassword(Input::get('email'))) {
137
            $notice_msg = Lang::get('confide::confide.alerts.password_forgot');
138
            return Redirect::action('UsersController@login')
139
                ->with('notice', $notice_msg);
140
        } else {
141
            $error_msg = Lang::get('confide::confide.alerts.wrong_password_forgot');
142
            return Redirect::action('UsersController@doForgotPassword')
143
                ->withInput()
144
                ->with('error', $error_msg);
145
        }
146
    }
147
148
    /**
149
     * Shows the change password form with the given token
150
     *
151
     * @param  string $token
152
     *
153
     * @return  Illuminate\Http\Response
154
     */
155
    public function resetPassword($token)
156
    {
157
        return View::make(Config::get('confide::reset_password_form'))
158
                ->with('token', $token);
159
    }
160
161
    /**
162
     * Attempt change password of the user
163
     *
164
     * @return  Illuminate\Http\Response
165
     */
166
    public function doResetPassword()
167
    {
168
        $repo = App::make('UserRepository');
169
        $input = array(
170
            'token'                 =>Input::get('token'),
171
            'password'              =>Input::get('password'),
172
            'password_confirmation' =>Input::get('password_confirmation'),
173
        );
174
175
        // By passing an array with the token, password and confirmation
176
        if ($repo->resetPassword($input)) {
177
            $notice_msg = Lang::get('confide::confide.alerts.password_reset');
178
            return Redirect::action('UsersController@login')
179
                ->with('notice', $notice_msg);
180
        } else {
181
            $error_msg = Lang::get('confide::confide.alerts.wrong_password_reset');
182
            return Redirect::action('UsersController@resetPassword', array('token'=>$input['token']))
183
                ->withInput()
184
                ->with('error', $error_msg);
185
        }
186
    }
187
188
    /**
189
     * Log the user out of the application.
190
     *
191
     * @return  Illuminate\Http\Response
192
     */
193
    public function logout()
194
    {
195
        Confide::logout();
196
197
        return Redirect::to('/');
198
    }
199
}
200