Issues (2)

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/OAuth/Two/FacebookProvider.php (2 issues)

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 namespace Arcanedev\Socialite\OAuth\Two;
2
3
use GuzzleHttp\ClientInterface;
4
use Illuminate\Support\Arr;
5
6
/**
7
 * Class     FacebookProvider
8
 *
9
 * @package  Arcanedev\Socialite\OAuth\Two
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class FacebookProvider extends AbstractProvider
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Properties
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    /**
19
     * The base Facebook Graph URL.
20
     *
21
     * @var string
22
     */
23
    protected $graphUrl = 'https://graph.facebook.com';
24
25
    /**
26
     * The Graph API version for the request.
27
     *
28
     * @var string
29
     */
30
    protected $version = 'v2.8';
31
32
    /**
33
     * The user fields being requested.
34
     *
35
     * @var array
36
     */
37
    protected $fields = ['name', 'email', 'gender', 'verified', 'link'];
38
39
    /**
40
     * The scopes being requested.
41
     *
42
     * @var array
43
     */
44
    protected $scopes = ['email'];
45
46
    /**
47
     * Display the dialog in a popup view.
48
     *
49
     * @var bool
50
     */
51
    protected $popup = false;
52
53
    /**
54
     * Re-request a declined permission.
55
     *
56
     * @var bool
57
     */
58
    protected $reRequest = false;
59
60
    /* ------------------------------------------------------------------------------------------------
61
     |  Main Functions
62
     | ------------------------------------------------------------------------------------------------
63
     */
64
    /**
65
     * {@inheritdoc}
66
     */
67
    protected function getAuthUrl($state)
68
    {
69
        return $this->buildAuthUrlFromBase("https://www.facebook.com/{$this->version}/dialog/oauth", $state);
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     */
75 6
    protected function getTokenUrl()
76
    {
77 6
        return "{$this->graphUrl}/oauth/access_token";
78
    }
79
80
    /**
81
     * {@inheritdoc}
82
     */
83 6
    public function getAccessTokenResponse($code)
84
    {
85 6
        $postKey  = (version_compare(ClientInterface::VERSION, '6') === 1) ? 'form_params' : 'body';
86 6
        $response = $this->getHttpClient()->post($this->getTokenUrl(), [
87 6
            $postKey => $this->getTokenFields($code),
88 3
        ]);
89
90 6
        $data = [];
91 6
        parse_str($response->getBody(), $data);
92
93 6
        return Arr::add($data, 'expires_in', Arr::pull($data, 'expires'));
0 ignored issues
show
It seems like $data can also be of type null; however, Illuminate\Support\Arr::pull() 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...
It seems like $data can also be of type null; however, Illuminate\Support\Arr::add() 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...
94
    }
95
96
    /**
97
     * {@inheritdoc}
98
     */
99
    protected function getUserByToken($token)
100
    {
101
        $meUrl = "{$this->graphUrl}/{$this->version}/me?access_token={$token}&fields=".implode(',', $this->fields);
102
103
        if ( ! empty($this->clientSecret)) {
104
            $meUrl .= '&appsecret_proof='.hash_hmac('sha256', $token, $this->clientSecret);
105
        }
106
107
        $response = $this->getHttpClient()->get($meUrl, [
108
            'headers' => [
109
                'Accept' => 'application/json',
110
            ],
111
        ]);
112
113
        return json_decode($response->getBody(), true);
114
    }
115
116
    /**
117
     * {@inheritdoc}
118
     */
119 6
    protected function mapUserToObject(array $user)
120
    {
121 6
        $avatarUrl = "{$this->graphUrl}/{$this->version}/".$user['id'].'/picture';
122
123 6
        return (new User)->setRaw($user)->map([
124 6
            'id'              => $user['id'],
125 3
            'nickname'        => null,
126 6
            'name'            => Arr::get($user, 'name'),
127 6
            'email'           => Arr::get($user, 'email'),
128 6
            'avatar'          => "{$avatarUrl}?type=normal",
129 6
            'avatar_original' => "{$avatarUrl}?width=1920",
130 6
            'profileUrl'      => Arr::get($user, 'link'),
131 3
        ]);
132
    }
133
134
    /**
135
     * {@inheritdoc}
136
     */
137
    protected function getCodeFields($state = null)
138
    {
139
        $fields = parent::getCodeFields($state);
140
141
        if ($this->popup) {
142
            $fields['display'] = 'popup';
143
        }
144
145
        if ($this->reRequest) {
146
            $fields['auth_type'] = 'rerequest';
147
        }
148
149
        return $fields;
150
    }
151
152
    /**
153
     * Set the user fields to request from Facebook.
154
     *
155
     * @param  array  $fields
156
     *
157
     * @return self
158
     */
159
    public function fields(array $fields)
160
    {
161
        $this->fields = $fields;
162
163
        return $this;
164
    }
165
166
    /**
167
     * Set the dialog to be displayed as a popup.
168
     *
169
     * @return self
170
     */
171
    public function asPopup()
172
    {
173
        $this->popup = true;
174
175
        return $this;
176
    }
177
178
    /**
179
     * Re-request permissions which were previously declined.
180
     *
181
     * @return self
182
     */
183
    public function reRequest()
184
    {
185
        $this->reRequest = true;
186
        return $this;
187
    }
188
}
189