Issues (56)

Security Analysis    no request data  

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.

src/User/UserRepository.php (5 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 namespace Anomaly\UsersModule\User;
2
3
use Anomaly\Streams\Platform\Entry\EntryRepository;
4
use Anomaly\UsersModule\User\Contract\UserInterface;
5
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
6
7
/**
8
 * Class UserRepository
9
 *
10
 * @link          http://pyrocms.com/
11
 * @author        PyroCMS, Inc. <[email protected]>
12
 * @author        Ryan Thompson <[email protected]>
13
 */
14
class UserRepository extends EntryRepository implements UserRepositoryInterface
15
{
16
17
    /**
18
     * The user model.
19
     *
20
     * @var UserModel
21
     */
22
    protected $model;
23
24
    /**
25
     * Create a new UserRepository instance.
26
     *
27
     * @param UserModel $model
28
     */
29
    function __construct(UserModel $model)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
30
    {
31
        $this->model = $model;
32
    }
33
34
    /**
35
     * Find a user by their credentials.
36
     *
37
     * @param  array              $credentials
38
     * @return null|UserInterface
39
     */
40
    public function findByCredentials(array $credentials)
41
    {
42
        if (isset($credentials['email'])) {
43
            $user = $this->findByEmail($credentials['email']);
44
        } elseif (isset($credentials['username'])) {
45
            $user = $this->findByUsername($credentials['username']);
46
        } else {
47
            return null;
48
        }
49
50
        if ($user && app('hash')->check($credentials['password'], $user->password)) {
0 ignored issues
show
Accessing password on the interface Anomaly\UsersModule\User\Contract\UserInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
51
            return $user;
52
        }
53
54
        return null;
55
    }
56
57
    /**
58
     * Find a user by their email.
59
     *
60
     * @param $email
61
     * @return null|UserInterface
62
     */
63
    public function findByEmail($email)
64
    {
65
        return $this->model->where('email', $email)->first();
66
    }
67
68
    /**
69
     * Find a user by their username.
70
     *
71
     * @param $username
72
     * @return null|UserInterface
73
     */
74
    public function findByUsername($username)
75
    {
76
        return $this->model->where('username', $username)->first();
77
    }
78
79
    /**
80
     * Find a user by their reset code.
81
     *
82
     * @param $code
83
     * @return null|UserInterface
84
     */
85
    public function findByResetCode($code)
86
    {
87
        return $this->model->where('reset_code', $code)->first();
88
    }
89
90
    /**
91
     * Find a user by their activation code.
92
     *
93
     * @param $code
94
     * @return null|UserInterface
95
     */
96
    public function findByActivationCode($code)
97
    {
98
        return $this->model->where('activation_code', $code)->first();
99
    }
100
101
    /**
102
     * Touch a user's last activity and IP.
103
     *
104
     * @param  UserInterface $user
105
     * @return bool
106
     */
107
    public function touchLastActivity(UserInterface $user)
108
    {
109
        $user->last_activity_at = time();
0 ignored issues
show
Accessing last_activity_at on the interface Anomaly\UsersModule\User\Contract\UserInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
110
        $user->ip_address       = $_SERVER['REMOTE_ADDR'];
0 ignored issues
show
Accessing ip_address on the interface Anomaly\UsersModule\User\Contract\UserInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
111
112
        //return $this->save($user);
113
    }
114
115
    /**
116
     * Touch a user's last login.
117
     *
118
     * @param  UserInterface $user
119
     * @return bool
120
     */
121
    public function touchLastLogin(UserInterface $user)
122
    {
123
        $user->last_login_at = time();
0 ignored issues
show
Accessing last_login_at on the interface Anomaly\UsersModule\User\Contract\UserInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
124
125
        return $this->save($user);
126
    }
127
}
128