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

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
3
namespace Shippinno\NextEngine\OAuth2\Client\Provider;
4
5
use League\OAuth2\Client\Provider\AbstractProvider;
6
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
7
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
8
use League\OAuth2\Client\Token\AccessToken;
9
use Psr\Http\Message\ResponseInterface;
10
11
class NextEngineProvider extends AbstractProvider
12
{
13
    /**
14
     * @var string Key used in a token response to identify the resource owner.
15
     */
16
    const ACCESS_TOKEN_RESOURCE_OWNER_ID = 'uid';
17
18
    /**
19
     * Returns the base URL for authorizing a client.
20
     *
21
     * @return string
22
     */
23 1
    public function getBaseAuthorizationUrl()
24
    {
25 1
        return 'https://base.next-engine.org/users/sign_in/';
26
    }
27
28
    /**
29
     * Returns the base URL for requesting an access token.
30
     *
31
     * Eg. https://oauth.service.com/token
32
     *
33
     * @param array $params
34
     * @return string
35
     */
36 2
    public function getBaseAccessTokenUrl(array $params)
37
    {
38 2
        return 'https://api.next-engine.org/api_neauth/';
39
    }
40
41
    /**
42
     * Returns the URL for requesting the resource owner's details.
43
     *
44
     * @param AccessToken $token
45
     * @return string
46
     */
47 1
    public function getResourceOwnerDetailsUrl(AccessToken $token)
48
    {
49 1
        return null;
50
    }
51
52
    /**
53
     * Returns the default scopes used by this provider.
54
     *
55
     * This should only be the scopes that are required to request the details
56
     * of the resource owner, rather than all the available scopes.
57
     *
58
     * @return string[]
59
     */
60
    protected function getDefaultScopes()
61
    {
62
        return [];
63
    }
64
65
    /**
66
     * Checks a provider response for errors.
67
     *
68
     * @throws IdentityProviderException
69
     * @param  ResponseInterface $response
70
     * @param  array|string $data Parsed response data
71
     * @return void
72
     */
73 2
    protected function checkResponse(ResponseInterface $response, $data)
74
    {
75 2
        if (isset($data['result']) && 'error' === $data['result']) {
76 1
            throw new IdentityProviderException(
77 1
                $data['message'] ?: $response->getReasonPhrase(),
78 1
                $response->getStatusCode(),
79 1
                $response->getBody()
80 1
            );
81
        }
82 1
    }
83
84
    /**
85
     * Returns authorization parameters based on provided options.
86
     *
87
     * @param  array $options
88
     * @return array Authorization parameters
89
     */
90 1
    protected function getAuthorizationParameters(array $options)
91
    {
92 1
        if (!isset($options['redirect_uri'])) {
93 1
            $options['redirect_uri'] = $this->redirectUri;
94 1
        }
95
96 1
        $options['client_id'] = $this->clientId;
97 1
        $options['client_secret'] = $this->clientSecret;
98
99 1
        return $options;
100
    }
101
102
    /**
103
     * Requests an access token using a specified grant and option set.
104
     *
105
     * @param  mixed $grant
106
     * @param  array $options
107
     * @return AccessToken
108
     */
109 2
    public function getAccessToken($grant, array $options = [])
110
    {
111 2
        $grant = $this->verifyGrant($grant);
112
113 2
        $request  = $this->getAccessTokenRequest($options);
114 2
        $response = $this->getParsedResponse($request);
115 1
        $prepared = $this->prepareAccessTokenResponse($response);
0 ignored issues
show
It seems like $response defined by $this->getParsedResponse($request) on line 114 can also be of type null or string; however, League\OAuth2\Client\Pro...reAccessTokenResponse() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
116 1
        $token    = $this->createAccessToken($prepared, $grant);
117
118 1
        return $token;
119
    }
120
121
    /**
122
     * Generates a resource owner object from a successful resource owner
123
     * details request.
124
     *
125
     * @param  array $response
126
     * @param  AccessToken $token
127
     * @return ResourceOwnerInterface
128
     */
129
    protected function createResourceOwner(array $response, AccessToken $token)
130
    {
131
        return new NextEngineResourceOwner($token->getValues());
132
    }
133
134
    /**
135
     * Requests and returns the resource owner of given access token.
136
     *
137
     * @param  AccessToken $token
138
     * @return ResourceOwnerInterface
139
     */
140
    public function getResourceOwner(AccessToken $token)
141
    {
142
        return $this->createResourceOwner([], $token);
143
    }
144
}
145