Issues (1)

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/Provider/Spotify.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
declare(strict_types=1);
4
5
namespace Kerox\OAuth2\Client\Provider;
6
7
use Kerox\OAuth2\Client\Provider\Exception\SpotifyIdentityProviderException;
8
use League\OAuth2\Client\Provider\AbstractProvider;
9
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
10
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
11
use League\OAuth2\Client\Token\AccessToken;
12
use League\OAuth2\Client\Tool\BearerAuthorizationTrait;
13
use Psr\Http\Message\ResponseInterface;
14
15
class Spotify extends AbstractProvider
16
{
17
    use BearerAuthorizationTrait;
18
19
    public const BASE_SPOTIFY_URL = 'https://accounts.spotify.com/';
20
    public const RESPONSE_TYPE = 'code';
21
22
    // Available scopes.
23
24
    // Images
25
    public const SCOPE_UGC_IMAGE_UPLOAD = 'ugc-image-upload';
26
27
    // Spotify Connect
28
    public const SCOPE_USER_MODIFY_PLAYBACK_STATE = 'user-modify-playback-state';
29
    public const SCOPE_USER_READ_PLAYBACK_STATE = 'user-read-playback-state';
30
    public const SCOPE_USER_READ_CURRENTLY_PLAYING = 'user-read-currently-playing';
31
32
    // Listening History
33
    public const SCOPE_USER_TOP_READ = 'user-top-read';
34
    public const SCOPE_USER_READ_RECENTLY_PLAYED = 'user-read-recently-played';
35
36
    // Library
37
    public const SCOPE_USER_LIBRARY_MODIFY = 'user-library-modify';
38
    public const SCOPE_USER_LIBRARY_READ = 'user-library-read';
39
40
    // Follow
41
    public const SCOPE_USER_FOLLOW_MODIFY = 'user-follow-modify';
42
    public const SCOPE_USER_FOLLOW_READ = 'user-follow-read';
43
44
    // Playlist
45
    public const SCOPE_PLAYLIST_READ_PRIVATE = 'playlist-read-private';
46
    public const SCOPE_PLAYLIST_MODIFY_PUBLIC = 'playlist-modify-public';
47
    public const SCOPE_PLAYLIST_MODIFY_PRIVATE = 'playlist-modify-private';
48
    public const SCOPE_PLAYLIST_READ_COLLABORATIVE = 'playlist-read-collaborative';
49
50
    // User
51
    public const SCOPE_USER_READ_PRIVATE = 'user-read-private';
52
    public const SCOPE_USER_READ_EMAIL = 'user-read-email';
53
54
    // Playback
55
    public const SCOPE_APP_REMOTE_CONTROL = 'app-remote-control';
56
    public const SCOPE_STREAMING = 'streaming';
57
58
    public function __construct(array $options = [], array $collaborators = [])
59
    {
60
        if (!isset($options['responseType']) || $options['responseType'] !== self::RESPONSE_TYPE) {
61 8
            $options['responseType'] = self::RESPONSE_TYPE;
62
        }
63 8
64 1
        parent::__construct($options, $collaborators);
65
    }
66
67 8
    /**
68 8
     * Returns the base URL for authorizing a client.
69
     */
70
    public function getBaseAuthorizationUrl(): string
71
    {
72
        return self::BASE_SPOTIFY_URL . 'authorize';
73 2
    }
74
75 2
    /**
76
     * Returns the base URL for requesting an access token.
77
     */
78
    public function getBaseAccessTokenUrl(array $params): string
79
    {
80
        return self::BASE_SPOTIFY_URL . 'api/token';
81 2
    }
82
83 2
    /**
84
     * Returns the URL for requesting the resource owner's details.
85
     */
86
    public function getResourceOwnerDetailsUrl(AccessToken $token): string
87
    {
88
        return 'https://api.spotify.com/v1/me';
89 1
    }
90
91 1
    /**
92
     * Returns the default scopes used by this provider.
93
     *
94
     * This should only be the scopes that are required to request the details
95
     * of the resource owner, rather than all the available scopes.
96
     */
97
    protected function getDefaultScopes(): array
98
    {
99
        return [];
100 2
    }
101
102 2
    /**
103
     * Checks a provider response for errors.
104
     *
105
     * @param array|string $data Parsed response data
106
     *
107
     * @throws IdentityProviderException
108
     */
109
    protected function checkResponse(ResponseInterface $response, $data): void
110
    {
111
        if ($response->getStatusCode() >= 400) {
112 3
            $error = $data['error_description'] ?? $data['error'] ?? $response->getReasonPhrase();
113
            $statusCode = $response->getStatusCode();
114 3
115 2
            if (\is_array($data['error'])) {
116 2
                $error = $data['error']['message'];
117
                $statusCode = $data['error']['status'];
118 2
            }
119 1
120 1
            throw new SpotifyIdentityProviderException($error, $statusCode, $response);
0 ignored issues
show
$response is of type object<Psr\Http\Message\ResponseInterface>, but the function expects a array|string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
121
        }
122
    }
123 2
124
    /**
125 1
     * Generates a resource owner object from a successful resource owner
126
     * details request.
127
     */
128
    protected function createResourceOwner(array $response, AccessToken $token): ResourceOwnerInterface
129
    {
130
        return new SpotifyResourceOwner($response);
131 1
    }
132
}
133