Issues (48)

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.

src/Models/User.php (2 issues)

Labels
Severity

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 Arcanesoft\Auth\Models;
2
3
use Arcanedev\LaravelAuth\Models\User as BaseUser;
4
use Arcanedev\LaravelImpersonator\Contracts\Impersonatable;
5
use Arcanedev\LaravelImpersonator\Traits\CanImpersonate;
6
use Illuminate\Database\Eloquent\Builder;
7
8
/**
9
 * Class     User
10
 *
11
 * @package  Arcanesoft\Auth\Models
12
 * @author   ARCANEDEV <[email protected]>
13
 *
14
 * @property  \Arcanesoft\Auth\Models\PasswordReset  passwordReset
15
 */
16
class User extends BaseUser implements Impersonatable
17
{
18
    /* -----------------------------------------------------------------
19
     |  Traits
20
     | -----------------------------------------------------------------
21
     */
22
23
    use Presenters\UserPresenter,
24
        CanImpersonate;
25
26
    /* -----------------------------------------------------------------
27
     |  Relationships
28
     | -----------------------------------------------------------------
29
     */
30
31
    /**
32
     * Password reset relationship.
33
     *
34
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
35
     */
36
    public function passwordReset()
37
    {
38
        return $this->hasOne(PasswordReset::class, 'email', 'email');
39
    }
40
41
    /* -----------------------------------------------------------------
42
     |  Scopes
43
     | -----------------------------------------------------------------
44
     */
45
46
    /**
47
     * Protect admins.
48
     *
49
     * @param  \Illuminate\Database\Eloquent\Builder  $query
50
     *
51
     * @return \Illuminate\Database\Eloquent\Builder
52
     */
53
    public function scopeProtectAdmins(Builder $query)
54
    {
55
        /** @var  self  $user */
56
        $user = auth()->user();
0 ignored issues
show
The method user does only exist in Illuminate\Contracts\Auth\Guard, but not in Illuminate\Contracts\Auth\Factory.

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...
57
58
        return ($user && $user->is_admin)
59
            ? $query
60
            : $query->where('is_admin', false);
61
    }
62
63
    /* -----------------------------------------------------------------
64
     |  Main Methods
65
     | -----------------------------------------------------------------
66
     */
67
68
    /**
69
     * Get a user from a hashed id or fail if not found.
70
     *
71
     * @param  string  $hashedId
72
     *
73
     * @return self
74
     *
75
     * @throws \Illuminate\Database\Eloquent\ModelNotFoundException
76
     */
77
    public static function firstHashedOrFail($hashedId)
78
    {
79
        return self::withTrashed()->protectAdmins()->withHashedId($hashedId)->firstOrFail();
0 ignored issues
show
The method withTrashed() does not exist on Arcanesoft\Auth\Models\User. Did you maybe mean trashed()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
80
    }
81
82
    /* -----------------------------------------------------------------
83
     |  Check Methods
84
     | -----------------------------------------------------------------
85
     */
86
87
    /**
88
     * Check if user is an administrator.
89
     *
90
     * @return bool
91
     */
92
    public function isAdmin()
93
    {
94
        return parent::isAdmin() || $this->hasRoleSlug(Role::ADMINISTRATOR);
95
    }
96
97
    /**
98
     * Check if user is a moderator.
99
     *
100
     * @return bool
101
     */
102
    public function isModerator()
103
    {
104
        return $this->hasRoleSlug(Role::MODERATOR);
105
    }
106
107
    /**
108
     * Check if user is a member.
109
     *
110
     * @return bool
111
     */
112
    public function isMember()
113
    {
114
        return $this->hasRoleSlug(Role::MEMBER);
115
    }
116
117
    /**
118
     * Check if the user is deletable.
119
     *
120
     * @return bool
121
     */
122
    public function isDeletable()
123
    {
124
        return ! $this->isAdmin();
125
    }
126
127
    /**
128
     * Check if user has a password reset.
129
     *
130
     * @return bool
131
     */
132
    public function hasPasswordReset()
133
    {
134
        return ! is_null($this->passwordReset);
135
    }
136
137
    /**
138
     * Check if the current modal can impersonate other models.
139
     *
140
     * @return  bool
141
     */
142
    public function canImpersonate()
143
    {
144
        return impersonator()->isEnabled() && $this->isAdmin();
145
    }
146
147
    /**
148
     * Check if the current model can be impersonated.
149
     *
150
     * @return  bool
151
     */
152
    public function canBeImpersonated()
153
    {
154
        return impersonator()->isEnabled() && ! $this->isAdmin();
155
    }
156
}
157