Issues (144)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/User.php (2 issues)

1
<?php
2
3
namespace App;
4
5
use Illuminate\Notifications\Notifiable;
6
use Illuminate\Foundation\Auth\User as Authenticatable;
7
use Illuminate\Database\Eloquent\SoftDeletes;
8
use Spatie\Activitylog\Traits\LogsActivity;
9
use Illuminate\Support\Facades\Auth;
10
11
class User extends Authenticatable
12
{
13
    use Notifiable;
14
    use SoftDeletes;
15
    use LogsActivity;
16
17
    /**
18
     * The attributes that should be mutated to dates.
19
     *
20
     * @var array
21
     */
22
    protected $dates = [
23
        'deleted_at'
24
    ];
25
26
    /**
27
     * The attributes that are mass assignable.
28
     *
29
     * @var array
30
     */
31
    protected $fillable = [
32
        'name', 'email', 'password', 'role', 'phone', 'preferred_device_id'
33
    ];
34
    
35
    /**
36
     * The attributes to ignore in the Activity Log
37
     *
38
     * @var array
39
     */
40
    protected static $ignoreChangedAttributes = [
41
        'updated_at', 'remember_token'
42
    ];
43
    
44
    /**
45
     * The attributes to log in the Activity Log
46
     *
47
     * @var array
48
     */
49
    protected static $logAttributes = [
50
        'name', 'email', 'password', 'role', 'phone', 'preferred_device_id'
51
    ];
52
    
53
    /**
54
     * Only log those that have actually changed after the update.
55
     *
56
     * @var array
57
     */
58
    protected static $logOnlyDirty = true;
59
60
    /**
61
     * The attributes that should be hidden for arrays.
62
     *
63
     * @var array
64
     */
65
    protected $hidden = [
66
        'password', 'remember_token',
67
    ];
68
    
69
    /**
70
     * Update the updated_at and created_at timestamps?
71
     *
72
     * @var array
73
     */
74
    public $timestamps = true;
75
76
    /**
77
     * Route notifications for the Nexmo channel.
78
     *
79
     * @return string
80
     */
81
    public function routeNotificationForNexmo()
82
    {
83
        return $this->phone;
84
    }
85
    
86
    /**
87
     * Is user Admin or better?
88
     *
89
     * @return boolean
90
     */
91
    public function isAdmin()
92
    {
93
        return $this->role > 2;
94
    }
95
    
96
    /**
97
     * Is user Manager or better?
98
     *
99
     * @return boolean
100
     */
101
    public function isManager()
102
    {
103
        return $this->role > 1;
104
    }
105
106
    /**
107
     * Is user User or better?
108
     *
109
     * @return boolean
110
     */
111
    public function isUser()
112
    {
113
        return $this->role > 0;
114
    }
115
    
116
    /**
117
     * Is user a guest?
118
     *
119
     * @return boolean
120
     */
121
    public function isGuest()
122
    {
123
        return $this->role == 0;
124
    }
125
    
126
    
127
    /**
128
     * Returns a list of managers.
129
     *
130
     * @return Users
0 ignored issues
show
The type App\Users was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
131
     */
132
    public function managers()
133
    {
134
        return $this->where('role', '>', 1)->get();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->where('role', '>', 1)->get() returns the type Illuminate\Database\Eloquent\Collection which is incompatible with the documented return type App\Users.
Loading history...
135
    }
136
    
137
    /**
138
     * Returns the users role as a string.
139
     *
140
     * @return string
141
     */
142
    public function roleString()
143
    {
144
        $role_en = array(0 => "Registered", 1 => "User", 2 => "Manager", 3 => "Admin");
145
        return $role_en[ $this->role ].' ('.$this->role.')';
146
    }
147
    
148
    /**
149
     * Get the preferred device of the user
150
     */
151
    public function preferredDevice()
152
    {
153
        return $this->hasOne('App\Device', 'id', 'preferred_device_id');
154
    }
155
    
156
    /**
157
     * Accessor: Get the user's last update time in seconds/minutes/hours since update or converted to user
158
     * friendly readable format.
159
     * If the time is less then a day old then display time since it last updated
160
     * If the time is greater then a day old then display the time in the format of Month day, year 12hour:mins am/pm
161
     * and using the user's preferred timezone
162
     *
163
     *
164
     * @return string
165
     */
166 View Code Duplication
    public function getUpdatedAtHumanAttribute()
167
    {
168
        if ($this->updated_at->diffInDays() > 0) {
169
                    return $this->updated_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
170
        } else {
171
                    return $this->updated_at->diffForHumans();
172
        }
173
    }
174
    
175
    /**
176
     * Accessor: Get the user's creation time in seconds/minutes/hours since update or converted to user
177
     * friendly readable format.
178
     * If the time is less then a day old then display time since creation
179
     * If the time is greater then a day old then display the time in the format of Month day, year 12hour:mins am/pm
180
     * and using the user's preferred timezone
181
     *
182
     *
183
     * @return string
184
     */
185 View Code Duplication
    public function getCreatedAtHumanAttribute()
186
    {
187
        if ($this->created_at->diffInDays() > 0) {
188
                    return $this->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
189
        } else {
190
                    return $this->created_at->diffForHumans();
191
        }
192
    }
193
    
194
    /**
195
     * Accessor: Get the user's deletion time in seconds/minutes/hours since deletion or converted to user
196
     * friendly readable format.
197
     * If the time is less then a day old then display time since deletion
198
     * If the time is greater then a day old then display the time in the format of Month day, year 12hour:mins am/pm
199
     * and using the user's preferred timezone
200
     *
201
     *
202
     * @return string
203
     */
204 View Code Duplication
    public function getDeletedAtHumanAttribute()
205
    {
206
        if ($this->deleted_at->diffInDays() > 0) {
207
            return $this->deleted_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
208
        } else {
209
            return $this->deleted_at->diffForHumans();
210
        }
211
    }
212
}
213