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/models/UserRepository.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
 * Class UserRepository
7
 *
8
 * This service abstracts some interactions that occurs between Confide and
9
 * the Database.
10
 */
11
class UserRepository
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...
12
{
13
    /**
14
     * Signup a new account with the given parameters
15
     *
16
     * @param  array $input Array containing 'email' and 'password'.
17
     *
18
     * @return  User User object that may or may not be saved successfully. Check the id to make sure.
19
     */
20
    public function signup($input)
21
    {
22
        $user = new User;
23
24
        $user->email    = array_get($input, 'email');
25
        $user->password = array_get($input, 'password');
26
27
        // The password confirmation will be removed from model
28
        // before saving. This field will be used in Ardent's
29
        // auto validation.
30
        $user->password_confirmation = array_get($input, 'password_confirmation');
31
32
        // Generate a random confirmation code
33
        $user->confirmation_code     = md5(uniqid(mt_rand(), true));
34
35
        // Save if valid. Password field will be hashed before save
36
        $this->save($user);
37
38
        return $user;
39
    }
40
41
    /**
42
     * Attempts to login with the given credentials.
43
     *
44
     * @param  array $input Array containing the credentials (email and password)
45
     *
46
     * @return  boolean Success?
47
     */
48
    public function login($input)
49
    {
50
        if (! isset($input['password'])) {
51
            $input['password'] = null;
52
        }
53
54
        return Confide::logAttempt($input, Config::get('confide::signup_confirm'));
55
    }
56
57
    /**
58
     * Checks if the credentials has been throttled by too
59
     * much failed login attempts
60
     *
61
     * @param  array $credentials Array containing the credentials (email and password)
0 ignored issues
show
There is no parameter named $credentials. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
62
     *
63
     * @return  boolean Is throttled
64
     */
65
    public function isThrottled($input)
66
    {
67
        return Confide::isThrottled($input);
68
    }
69
70
    /**
71
     * Checks if the given credentials correponds to a user that exists but
72
     * is not confirmed
73
     *
74
     * @param  array $credentials Array containing the credentials (email and password)
0 ignored issues
show
There is no parameter named $credentials. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
75
     *
76
     * @return  boolean Exists and is not confirmed?
77
     */
78
    public function existsButNotConfirmed($input)
79
    {
80
        $user = Confide::getUserByEmailOrUsername($input);
81
82
        if ($user) {
83
            $correctPassword = Hash::check(
84
                isset($input['password']) ? $input['password'] : false,
85
                $user->password
86
            );
87
88
            return (! $user->confirmed && $correctPassword);
89
        }
90
    }
91
92
    /**
93
     * Resets a password of a user. The $input['token'] will tell which user.
94
     *
95
     * @param  array $input Array containing 'token', 'password' and 'password_confirmation' keys.
96
     *
97
     * @return  boolean Success
98
     */
99
    public function resetPassword($input)
100
    {
101
        $result = false;
102
        $user   = Confide::userByResetPasswordToken($input['token']);
103
104
        if ($user) {
105
            $user->password              = $input['password'];
106
            $user->password_confirmation = $input['password_confirmation'];
107
            $result = $this->save($user);
108
        }
109
110
        // If result is positive, destroy token
111
        if ($result) {
112
            Confide::destroyForgotPasswordToken($input['token']);
113
        }
114
115
        return $result;
116
    }
117
118
    /**
119
     * Simply saves the given instance
120
     *
121
     * @param  User $instance
122
     *
123
     * @return  boolean Success
124
     */
125
    public function save(User $instance)
126
    {
127
        return $instance->save();
128
    }
129
}
130