Issues (336)

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/User.php (11 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
 * GitScrum v0.1.
4
 *
5
 * @author  Renato Marinho <renato.marinho>
6
 * @license http://opensource.org/licenses/GPL-3.0 GPLv3
7
 */
8
9
namespace GitScrum\Models;
10
11
use Illuminate\Database\Eloquent\Model;
12
use Illuminate\Foundation\Auth\User as Authenticatable;
13
use GitScrum\Scopes\GlobalScope;
14
15
class User extends Authenticatable
16
{
17
    use GlobalScope;
18
    /**
19
     * The database table used by the model.
20
     *
21
     * @var string
22
     */
23
    protected $table = 'users';
24
25
    /**
26
     * Attributes that should be mass-assignable.
27
     *
28
     * @var array
29
     */
30
    protected $fillable = ['provider_id', 'provider', 'username', 'name', 'avatar', 'html_url', 'email',
31
        'bio', 'location', 'blog', 'since', 'token', 'main_repository', 'position_held', ];
32
33
    /**
34
     * The attributes excluded from the model's JSON form.
35
     *
36
     * @var array
37
     */
38
    protected $hidden = ['password', 'remember_token'];
39
40
    /**
41
     * The attributes that should be casted to native types.
42
     *
43
     * @var array
44
     */
45
    protected $casts = [];
46
47
    public function setNameAttribute($value)
48
    {
49
        $this->attributes['name'] = $value;
50
51
        if (empty($value)) {
52
            $this->attributes['name'] = $this->attributes['username'];
53
        }
54
    }
55
56
    public function configStatuses()
57
    {
58
        return $this->belongsToMany(\GitScrum\Models\ConfigStatus::class, 'statuses', 'user_id', 'id');
59
    }
60
61
    public function issues()
62
    {
63
        return $this->belongsToMany(\GitScrum\Models\Issue::class, 'issues_has_users', 'user_id', 'issue_id');
64
    }
65
66
    public function organizations()
67
    {
68
        return $this->belongsToMany(\GitScrum\Models\Organization::class, 'users_has_organizations')
69
            ->withTimestamps();
70
    }
71
72
    public function attachments()
73
    {
74
        return $this->hasMany(\GitScrum\Models\Attachment::class, 'user_id', 'id');
75
    }
76
77
    public function branches()
78
    {
79
        return $this->hasMany(\GitScrum\Models\Branch::class, 'user_id', 'id');
80
    }
81
82
    public function comments()
83
    {
84
        return $this->hasMany(\GitScrum\Models\Comment::class, 'user_id', 'id');
85
    }
86
87
    public function commits()
88
    {
89
        return $this->hasMany(\GitScrum\Models\Commit::class, 'user_id', 'id');
90
    }
91
92
    public function statuses()
93
    {
94
        return $this->hasMany(\GitScrum\Models\Status::class, 'user_id', 'id');
95
    }
96
97
    public function notes()
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
98
    {
99
        return $this->morphMany(\GitScrum\Models\Note::class, 'noteable')
100
            ->orderby('position', 'ASC');
101
    }
102
103
    public function labels($feature)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
104
    {
105
        return $this->{$feature}->map(function ($obj) {
106
            return $obj->labels;
107
        })->flatten(1)->unique('id');
108
    }
109
110
    public function productBacklogs($product_backlog_id = null)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
111
    {
112
        return $this->organizations->map(function ($organization) use ($product_backlog_id) {
0 ignored issues
show
The property organizations does not exist on object<GitScrum\Models\User>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
113
            $obj = $organization->productBacklog()
114
                ->with('sprints')
115
                ->with('userStories')
116
                ->with('favorite')
117
                ->with('organization')
118
                ->with('issues')
119
                ->get();
120
121
            if (!is_null($product_backlog_id)) {
122
                $obj = $obj->where('id', $product_backlog_id);
123
            }
124
125
            return $obj;
126
        })->flatten(1);
127
    }
128
129
    public function sprints($sprint_id = null)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
130
    {
131
        $sprints = $this->issues->where('sprint_id', '!=', null)->map(function ($issue) use ($sprint_id) {
0 ignored issues
show
The property issues does not exist on object<GitScrum\Models\User>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
132
            if (!is_null($sprint_id)) {
133
                $obj = $issue->sprint()->where('id', $sprint_id)->get();
134
            } else {
135
                $obj = $issue->sprint()->get();
136
            }
137
138
            return $obj;
139
        })->flatten(1)->unique('id');
140
141
        return $sprints;
142
    }
143
144
    public function userStories($user_story_id = null)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
The parameter $user_story_id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
145
    {
146
        return $this->productBacklogs()->map(function ($productBacklog) {
147
            return $productBacklog->userStories()->get();
148
        })->flatten(1);
149
    }
150
151
    public function team()
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
152
    {
153
        return $this->organizations->map(function ($obj) {
0 ignored issues
show
The property organizations does not exist on object<GitScrum\Models\User>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
154
            return $obj->users;
155
        })->flatten(1)->unique('id');
156
    }
157
158
    public function activities($user_id = null, $limit = 6)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
159
    {
160
        return $this->team()->map(function ($obj) use ($user_id) {
161
            $statuses = $obj->statuses;
162
            if (!is_null($user_id)) {
163
                $statuses = $statuses->where('user_id', $user_id);
164
            }
165
166
            return $statuses;
167
        })->flatten(1)->sortByDesc('id')->take($limit);
168
    }
169
170
    public function getProviderAttribute()
171
    {
172
        return ucfirst($this->attributes['provider']);
173
    }
174
}
175