Issues (19)

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.

src/SocialProviderManager.php (6 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
2
3
namespace MadWeb\SocialAuth;
4
5
use MadWeb\SocialAuth\Models\SocialProvider;
6
use Illuminate\Contracts\Auth\Authenticatable;
7
use MadWeb\SocialAuth\Events\SocialUserCreated;
8
use MadWeb\SocialAuth\Events\SocialUserAttached;
9
use Laravel\Socialite\Contracts\User as SocialUser;
10
use MadWeb\SocialAuth\Contracts\SocialAuthenticatable;
11
12
class SocialProviderManager
13
{
14
    /**
15
     * @var SocialProvider
16
     */
17
    protected $social;
18
19
    /**
20
     * SocialProviderManager constructor.
21
     * @param SocialProvider $social
22
     */
23 51
    public function __construct(SocialProvider $social)
24
    {
25 51
        $this->social = $social;
26 51
    }
27
28
    /**
29
     * @param string $key
30
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
31
     */
32 24
    public function socialUserQuery(string $key)
33
    {
34 24
        return $this->social->users()->wherePivot(config('social-auth.foreign_keys.socials'), $key);
35
    }
36
37
    /**
38
     * Gets user by unique social identifier.
39
     *
40
     * @param string $key
41
     * @return mixed
42
     */
43 18
    public function getUserByKey(string $key)
44
    {
45 18
        return $this->socialUserQuery($key)->first();
46
    }
47
48
    /**
49
     * @param SocialAuthenticatable $user
50
     * @param SocialUser $socialUser
51
     */
52 12
    public function attach(SocialAuthenticatable $user, SocialUser $socialUser)
53
    {
54 12
        $user->attachSocial(
55 12
            $this->social,
56 12
            $socialUser->getId(),
57 12
            $socialUser->token,
0 ignored issues
show
Accessing token on the interface Laravel\Socialite\Contracts\User suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
58 12
            $socialUser->expiresIn ?? null
0 ignored issues
show
Accessing expiresIn on the interface Laravel\Socialite\Contracts\User suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
59
        );
60
61 12
        event(new SocialUserAttached($user, $this->social, $socialUser));
62 12
    }
63
64
    /**
65
     * Create new system user by social user data.
66
     *
67
     * @param Authenticatable $userModel
68
     * @param SocialProvider $social
69
     * @param SocialUser $socialUser
70
     * @return Authenticatable
71
     */
72 6
    public function createNewUser(
73
        Authenticatable $userModel,
74
        SocialProvider $social,
75
        SocialUser $socialUser
76
    ): Authenticatable {
77 6
        $NewUser = $userModel->create(
0 ignored issues
show
The method create() does not seem to exist on object<Illuminate\Contracts\Auth\Authenticatable>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
78 6
            $userModel->mapSocialData($socialUser)
0 ignored issues
show
The method mapSocialData() does not seem to exist on object<Illuminate\Contracts\Auth\Authenticatable>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
79
        );
80
81 6
        $NewUser->attachSocial(
82 6
            $social,
83 6
            $socialUser->getId(),
84 6
            $socialUser->token,
0 ignored issues
show
Accessing token on the interface Laravel\Socialite\Contracts\User suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
85 6
            $socialUser->expiresIn ?? null
0 ignored issues
show
Accessing expiresIn on the interface Laravel\Socialite\Contracts\User suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
86
        );
87
88 6
        event(new SocialUserCreated($NewUser));
89
90 6
        return $NewUser;
91
    }
92
}
93