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/Zoho.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 Asad\OAuth2\Client\Provider;
4
5
use League\OAuth2\Client\Provider\AbstractProvider;
6
use League\OAuth2\Client\Grant\AbstractGrant;
7
use Psr\Http\Message\ResponseInterface;
8
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
9
use League\OAuth2\Client\Tool\BearerAuthorizationTrait;
10
use League\OAuth2\Client\Token\AccessToken;
11
use Asad\OAuth2\Client\AccessToken\ZohoAccessToken;
12
13
class Zoho extends AbstractProvider
14
{
15
    use BearerAuthorizationTrait;
16
17
    /**
18
     * You must use your domain-specific Zoho Accounts URL to generate access and refresh tokens.
19
     * The following are the various domains and their corresponding accounts URLs.
20
     */
21
22
    private $dcDomain = [
23
        'US' => 'https://accounts.zoho.com',
24
        'AU' => 'https://accounts.zoho.com.au',
25
        'EU' => 'https://accounts.zoho.eu',
26
        'IN' => 'https://accounts.zoho.in',
27
        'CN' => 'https://accounts.zoho.com.cn',
28
    ];
29
30
    /**
31
     * @var string define which data center you want to use
32
     * @link https://www.zoho.com/crm/developer/docs/api/multi-dc.html
33
     */
34
    protected $dc;
35
36
    /**
37
     * Get authorization url to begin OAuth flow
38
     *
39
     * @return string
40
     */
41
    public function getBaseAuthorizationUrl()
42
    {
43
        $dc = $this->dc && $this->dc == 'CN' ? $this->dc : 'US';
44
        return $this->getDcDomain($dc) . '/oauth/v2/auth';
45
    }
46
47
    /**
48
     * Get access token url to retrieve token
49
     *
50
     * @param array $params
51
     *
52
     * @return string
53
     */
54
    public function getBaseAccessTokenUrl(array $params)
55
    {
56
        return $this->getDcDomain($this->dc) . '/oauth/v2/token';
57
    }
58
59
    /**
60
     * Get provider url to fetch user details
61
     *
62
     * @param AccessToken $token
63
     *
64
     * @return string
65
     */
66
    public function getResourceOwnerDetailsUrl(AccessToken $token)
67
    {
68
        return 'https://accounts.zoho.com/oauth/user/info';
69
    }
70
71
    /**
72
     * @var array List of scopes that will be used for authentication.
73
     * @link https://www.zoho.com/crm/developer/docs/api/oauth-overview.html#scopes
74
     * The provided scope will be used if you don't give any scope
75
     * and this scope will be used to grab user accounts public information
76
     *
77
     * @return array
78
     */
79
    protected function getDefaultScopes()
80
    {
81
        return ['aaaserver.profile.READ'];
82
    }
83
84
    /**
85
     * Returns the string that should be used to separate scopes when building
86
     * the URL for requesting an access token.
87
     *
88
     * @return string Scope separator, defaults to ','
89
     */
90
    protected function getScopeSeparator()
91
    {
92
        return ',';
93
    }
94
95
    /**
96
     * Check a provider response for errors.
97
     *
98
     * @param  ResponseInterface $response
99
     * @param  array|string $data
100
     *
101
     * @throws IdentityProviderException
102
     */
103
    protected function checkResponse(ResponseInterface $response, $data)
104
    {
105
        // @codeCoverageIgnoreStart
106
        if (empty($data['error'])) {
107
            return;
108
        }
109
        // @codeCoverageIgnoreEnd
110
111
        $error = isset($data['error']) ? $data['error'] : null;
112
        throw new IdentityProviderException(
113
            $error,
114
            $response->getStatusCode(),
115
            $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...
116
        );
117
    }
118
119
    /**
120
     * Generate a user object from a successful user details request.
121
     *
122
     * @param array $response
123
     * @param AccessToken $token
124
     *
125
     * @return League\OAuth2\Client\Provider\ResourceOwnerInterface
126
     */
127
    protected function createResourceOwner(array $response, AccessToken $token)
128
    {
129
        return new ZohoUser($response);
130
    }
131
132
    /**
133
     * Creates an access token from a response.
134
     *
135
     * The grant that was used to fetch the response can be used to provide
136
     * additional context.
137
     *
138
     * @param  array $response
139
     * @param  AbstractGrant $grant
140
     * @return AccessTokenInterface
141
     */
142
    protected function createAccessToken(array $response, AbstractGrant $grant)
143
    {
144
        return new ZohoAccessToken($response);
145
    }
146
147
    /**
148
     * You must use your domain-specific Zoho Accounts URL to generate access and refresh tokens
149
     * @return string zoho data center url
150
     */
151
152
    private function getDcDomain($dc)
153
    {
154
        return $dc && isset($this->dcDomain[$dc]) ? $this->dcDomain[$dc] : $this->fallbackDc();
155
    }
156
157
    /**
158
     * The zoho default data center
159
     * @return string zoho default data center url
160
     */
161
    private function fallbackDc()
162
    {
163
        return $this->dcDomain['US'];
164
    }
165
}
166