Issues (86)

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/Domains/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
2
namespace Domains;
3
4
use Carbon\Carbon;
5
use Illuminate\Auth\Authenticatable;
6
use Illuminate\Auth\Passwords\CanResetPassword;
7
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
8
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
9
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
10
use Illuminate\Foundation\Auth\Access\Authorizable;
11
12
/**
13
 * Class User
14
 * @deprecated
15
 *
16
 * @property int $id
17
 * @property string $gitter_id
18
 * @property string $name
19
 * @property string $avatar
20
 * @property string $url
21
 * @property string $login
22
 * @property string $email
23
 * @property string $password
24
 * @property string $remember_token
25
 * @property Carbon $created_at
26
 * @property Carbon $updated_at
27
 *
28
 * === Accessors ===
29
 *
30
 * @property-read string $karma_text
31
 * @property-read string $thanks_text
32
 *
33
 * === Relations ===
34
 *
35
 * @property-read Achieve[] $achievements
36
 * @property-read Karma[] $karma
37
 * @property-read Karma[] $thanks
38
 *
39
 */
40
class User extends \Eloquent implements
41
    AuthenticatableContract,
42
    AuthorizableContract,
43
    CanResetPasswordContract
44
{
45
    use Authenticatable,
46
        Authorizable,
47
        CanResetPassword;
48
49
    /**
50
     * @var string
51
     */
52
    protected $table = 'users';
53
54
    /**
55
     * @var array
56
     */
57
    protected $hidden = ['password', 'remember_token'];
58
59
    /**
60
     * @var array
61
     */
62
    protected $fillable = ['gitter_id', 'url', 'login', 'name', 'avatar'];
63
64
    /**
65
     *
66
     */
67
    protected static function boot()
68
    {
69
        parent::boot();
70
    }
71
72
    /**
73
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
74
     */
75
    public function achievements()
76
    {
77
        return $this->hasMany(Achieve::class, 'user_id', 'id');
78
    }
79
80
    /**
81
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
82
     */
83
    public function karma()
84
    {
85
        return $this->hasMany(Karma::class, 'user_target_id', 'id');
86
    }
87
88
    /**
89
     * @return string
90
     */
91
    public function getKarmaTextAttribute()
92
    {
93
        $karma = $this->karma->count();
0 ignored issues
show
The method count cannot be called on $this->karma (of type array<integer,object<Domains\Karma>>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
94
95
        return ($karma > 0 ? '+' : '') . $karma;
96
    }
97
98
    /**
99
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
100
     */
101
    public function thanks()
102
    {
103
        return $this->hasMany(Karma::class, 'user_id', 'id');
104
    }
105
106
    /**
107
     * @return string
108
     */
109
    public function getThanksTextAttribute()
110
    {
111
        return $this->thanks->count();
0 ignored issues
show
The method count cannot be called on $this->thanks (of type array<integer,object<Domains\Karma>>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
112
    }
113
114
    /**
115
     * @param $roomId
116
     * @return Carbon
117
     */
118
    public function getLastKarmaTimeForRoom($roomId)
119
    {
120
        $result = Karma::query()
121
            ->where('user_target_id', $this->id)
122
            ->where('room_id', $roomId)
123
            ->orderBy('created_at', 'desc')
124
            ->first();
125
126
        if ($result) {
127
            return $result->created_at;
128
        }
129
130
        return Carbon::createFromTimestamp(0);
131
    }
132
133
    /**
134
     * @param User $user
135
     * @param Message $message
136
     * @return static
137
     */
138
    public function addKarmaTo(User $user, Message $message)
139
    {
140
        return Karma::create([
141
            'room_id'        => $message->room_id,
142
            'message_id'     => $message->gitter_id,
143
            'user_id'        => $this->id,
144
            'user_target_id' => $user->id,
145
            'created_at'     => $message->created_at,
146
        ]);
147
    }
148
149
    /**
150
     * @param User $user
151
     *
152
     * @return bool
153
     */
154
    public function is(User $user)
155
    {
156
        return $this->login === $user->login;
157
    }
158
159
    /**
160
     * @return bool
161
     */
162
    public function isBot()
163
    {
164
        return $this->is(\Auth::user());
165
    }
166
}
167