Issues (121)

Security Analysis    not enabled

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.

app/Auth/Guard.php (5 issues)

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 App\Auth;
4
5
use App\MemberToken;
6
use App\Member;
7
use Facebook\FacebookAuthorizationException;
8
use Facebook\FacebookSession;
9
use Facebook\FacebookRequest;
10
use Facebook\GraphUser;
11
use Illuminate;
12
use Illuminate\Support\Facades\Config;
13
use Illuminate\Support\Facades\Auth;
14
use Illuminate\Support\Facades\Session;
15
use Illuminate\Http\Request as HttpRequest;
16
17
/**
18
 * Class Guard
19
 * @package App\Auth
20
 */
21
class Guard
22
{
23
    /**
24
     * @param $code
25
     * @return null
26
     * @throws \Facebook\FacebookRequestException
27
     * @throws \Facebook\FacebookSDKException
28
     */
29
    protected function getAccessToken($code)
30
    {
31
        $response = (new FacebookRequest(
32
            FacebookSession::newAppSession(),
33
            'GET',
34
            '/oauth/access_token',
35
            [
36
                'client_id' => FacebookSession::_getTargetAppId(),
37
                'client_secret' => FacebookSession::_getTargetAppSecret(),
38
                'redirect_uri' => Config::get('auth.providers.facebook.redirect_uri'),
39
                'code' => $code
40
            ]
41
        ))->execute()->getResponse();
42
43
        // Graph v2.3 and greater return objects on the /oauth/access_token endpoint
44
        $accessToken = null;
45
        if (is_object($response) && isset($response->access_token)) {
46
            $accessToken = $response->access_token;
47
        } elseif (is_array($response) && array_key_exists('access_token', $response)) {
48
            $accessToken = $response['access_token'];
49
        }
50
51
        return $accessToken;
52
    }
53
54
    /**
55
     * @name facebookAuth
56
     * @param $code
57
     * @return null
58
     * @throws \Facebook\FacebookSDKException
59
     * @throws \Facebook\FacebookRequestException
60
     * @throws FacebookAuthorizationException
61
     */
62
    public function facebookAuth($code)
63
    {
64
        $accessToken = $this->getAccessToken($code);
0 ignored issues
show
Are you sure the assignment to $accessToken is correct as $this->getAccessToken($code) (which targets App\Auth\Guard::getAccessToken()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
65
66
        $session = new FacebookSession($accessToken);
67
68
        if (!$session) {
69
            throw new FacebookAuthorizationException('Invalid code', ['Invalid code'], 401);
70
        }
71
72
        /**
73
         * @var GraphUser $userProfile
74
         */
75
        $userProfile = (new FacebookRequest(
76
            $session,
77
            'GET',
78
            '/me'
79
        ))->execute()->getGraphObject(GraphUser::className());
80
81
        $user = Member::firstOrNew(['facebookId' => $userProfile->getId()]);
82
        $user->name = $userProfile->getName();
83
        $user->save();
84
85
        Auth::login($user);
86
87
        $memberToken = new MemberToken();
88
        $memberToken->memberId = $user->id;
0 ignored issues
show
The property memberId does not exist on object<App\MemberToken>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
89
        $memberToken->accessToken = $accessToken;
0 ignored issues
show
The property accessToken does not exist on object<App\MemberToken>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
90
        $memberToken->sessionId = Session::getId();
0 ignored issues
show
The property sessionId does not exist on object<App\MemberToken>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
91
        $memberToken->save();
92
93
        return $accessToken;
94
    }
95
96
    public function logout()
97
    {
98
        // If we have an event dispatcher instance, we can fire off the logout event
99
        // so any further processing can be done. This allows the developer to be
100
        // listening for anytime a user signs out of this application manually.
101
102
        MemberToken::where(['sessionId' => Session::getId()])->delete();
103
    }
104
105
    /**
106
     * @name getSessionId
107
     * @param HttpRequest $request
108
     * @return mixed
109
     */
110
    public static function getSessionId(HttpRequest $request)
111
    {
112
        $accessToken = trim(
113
            preg_replace('/^(?:\s+)?Bearer\s/', '', $request->header('Authorization'))
114
        );
115
116
        // find session with token
117
        $memberToken = MemberToken::where('accessToken', $accessToken)->first();
118
119
        if ($memberToken && Session::isValidId($memberToken->sessionId)) {
120
            /**
121
             * @var MemberToken $memberToken
122
             */
123
            $memberToken->update([
124
                'updated_at' => $memberToken->freshTimestamp()
125
            ]);
126
            return $memberToken->sessionId;
0 ignored issues
show
The property sessionId does not exist on object<App\MemberToken>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
127
        } else {
128
            return $request->cookies->get(Session::getName());
129
        }
130
    }
131
}
132