Issues (39)

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/Models/Token.php (1 issue)

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
namespace CodexShaper\OAuth2\Server\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Token extends Model
8
{
9
    /**
10
     * The database table used by the model.
11
     *
12
     * @var string
13
     */
14
    protected $table = 'oauth_access_tokens';
15
16
    /**
17
     * The "type" of the primary key ID.
18
     *
19
     * @var string
20
     */
21
    protected $keyType = 'string';
22
23
    /**
24
     * Indicates if the IDs are auto-incrementing.
25
     *
26
     * @var bool
27
     */
28
    public $incrementing = false;
29
30
    /**
31
     * The guarded attributes on the model.
32
     *
33
     * @var array
34
     */
35
    protected $guarded = [];
36
37
    /**
38
     * The attributes that should be cast to native types.
39
     *
40
     * @var array
41
     */
42
    protected $casts = [
43
        'scopes'  => 'array',
44
        'revoked' => 'bool',
45
    ];
46
47
    /**
48
     * The attributes that should be mutated to dates.
49
     *
50
     * @var array
51
     */
52
    protected $dates = [
53
        'expires_at',
54
    ];
55
56
    /**
57
     * Indicates if the model should be timestamped.
58
     *
59
     * @var bool
60
     */
61
    public $timestamps = false;
62
63
    /**
64
     * Get the client that the token belongs to.
65
     *
66
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
67
     */
68
    public function client()
69
    {
70
        return $this->belongsTo(Passport::clientModel());
71
    }
72
73
    /**
74
     * Get the user that the token belongs to.
75
     *
76
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
77
     */
78
    public function user()
79
    {
80
        $provider = config('auth.guards.api.provider');
81
82
        return $this->belongsTo(config('auth.providers.'.$provider.'.model'));
83
    }
84
85
    /**
86
     * Determine if the token has a given scope.
87
     *
88
     * @param string $scope
89
     *
90
     * @return bool
91
     */
92
    public function can($scope)
93
    {
94
        if (in_array('*', $this->scopes)) {
95
            return true;
96
        }
97
98
        $scopes = Passport::$withInheritedScopes
99
            ? $this->resolveInheritedScopes($scope)
100
            : [$scope];
101
102
        foreach ($scopes as $scope) {
103
            if (array_key_exists($scope, array_flip($this->scopes))) {
104
                return true;
105
            }
106
        }
107
108
        return false;
109
    }
110
111
    /**
112
     * Resolve all possible scopes.
113
     *
114
     * @param string $scope
115
     *
116
     * @return array
117
     */
118
    protected function resolveInheritedScopes($scope)
119
    {
120
        $parts = explode(':', $scope);
121
122
        $scopes = [];
123
124
        for ($i = 0; $i <= count($parts); $i++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
125
            $scopes[] = implode(':', array_slice($parts, 0, $i));
126
        }
127
128
        return $scopes;
129
    }
130
131
    /**
132
     * Determine if the token is missing a given scope.
133
     *
134
     * @param string $scope
135
     *
136
     * @return bool
137
     */
138
    public function cant($scope)
139
    {
140
        return !$this->can($scope);
141
    }
142
143
    /**
144
     * Revoke the token instance.
145
     *
146
     * @return bool
147
     */
148
    public function revoke()
149
    {
150
        return $this->forceFill(['revoked' => true])->save();
151
    }
152
153
    /**
154
     * Determine if the token is a transient JWT token.
155
     *
156
     * @return bool
157
     */
158
    public function transient()
159
    {
160
        return false;
161
    }
162
}
163