GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (2170)

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.

application/components/AuthClientHelper.php (7 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\components;
4
5
use app;
6
use app\modules\user\models\UserService;
7
use yii\base\ErrorException;
8
9
/**
10
 * AuthClientHelper is a helper class for serving login through social networks and retrieving needed information by api
11
 * @package app\components
12
 */
13
class AuthClientHelper
14
{
15
    public static $ServiceIdMapping = [
16
        'app\modules\user\authclients\GitHub' => 'id',
17
        'yii\authclient\clients\YandexOpenId' => 'id',
18
        'yii\authclient\clients\Twitter' => 'id',
19
        'app\modules\user\authclients\Facebook' => 'id',
20
        'app\modules\user\authclients\VKontakte' => 'uid',
21
        'yii\authclient\clients\YandexOAuth' => 'id',
22
        'yii\authclient\clients\GoogleOAuth' => 'id',
23
        'app\modules\user\authclients\PayPal' => 'user_id'
24
    ];
25
26
    /**
27
     * Finds service record for current logged client and returns corresponding user.
28
     * @param \yii\authclient\BaseClient $client AuthClient instance with social authenticated details(ie. user attributes)
29
     * @throws ErrorException
30
     * @return app\modules\user\models\User|null
31
     */
32
    public static function findUserByService(\yii\authclient\BaseClient $client)
33
    {
34
        $serviceType = $client->className();
0 ignored issues
show
Deprecated Code introduced by
The method yii\base\BaseObject::className() has been deprecated with message: since 2.0.14. On PHP >=5.5, use `::class` instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
35
        if (isset(static::$ServiceIdMapping[$client->className()])) {
0 ignored issues
show
Deprecated Code introduced by
The method yii\base\BaseObject::className() has been deprecated with message: since 2.0.14. On PHP >=5.5, use `::class` instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
36
            $id_attribute = static::$ServiceIdMapping[$client->className()];
0 ignored issues
show
Deprecated Code introduced by
The method yii\base\BaseObject::className() has been deprecated with message: since 2.0.14. On PHP >=5.5, use `::class` instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
37
            $attributes = $client->getUserAttributes();
38
            $serviceId = null;
0 ignored issues
show
$serviceId is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
39
            if (isset($attributes[$id_attribute])) {
40
                $serviceId = $attributes[$id_attribute];
41
            } else {
42
                throw new ErrorException("No user identified supplied by social service.");
43
            }
44
            /** @var \app\modules\user\models\UserService $service */
45
            $service = UserService::find()
46
                ->where([
47
                    'service_type' => $serviceType,
48
                    'service_id' => $serviceId,
49
                ])
50
                ->with('user')
51
                ->one();
52
53
            if ($service === null) {
54
                return null;
55
            }
56
57
            return $service->user;
58
        } else {
59
            throw new ErrorException("Unidentified social service used.");
60
        }
61
62
    }
63
64
    /**
65
     * Retrieves additional profile information which can be needed for first-login(registration)
66
     * and which was not provided by first api call.
67
     * Returns merged user attributes
68
     * @param \yii\authclient\BaseClient $client
69
     * @return \yii\authclient\BaseClient Client with merged attributes
70
     */
71
    public static function retrieveAdditionalData(\yii\authclient\BaseClient $client)
72
    {
73
        $attributes = $client->getUserAttributes();
74
75
        switch ($client->className()) {
0 ignored issues
show
Deprecated Code introduced by
The method yii\base\BaseObject::className() has been deprecated with message: since 2.0.14. On PHP >=5.5, use `::class` instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
76
            case 'app\modules\user\authclients\GitHub':
77
                try {
78
                    /** @var \app\modules\user\authclients\GitHub $client */
79
                    $emails = $client->api('user/emails');
80
81
                    foreach ($emails as $email) {
82
                        if ($email['primary'] === true) {
83
                            $attributes['email'] = $email['email'];
84
                            break;
85
                        }
86
                    }
87
88
                } catch (\yii\authclient\InvalidResponseException $e) {
89
                    // no email :-(
90
                }
91
                break;
92
            default:
93
                break;
94
        }
95
        $client->setUserAttributes($attributes);
96
        return $client;
97
    }
98
99
100
    /**
101
     * Converts service attributes to app\modules\user\models\User model attributes
102
     * @param \yii\authclient\BaseClient $client
103
     * @return array Array of attributes by model type which we can apply by $model->setAttributes()
104
     */
105
    public static function mapUserAttributesWithService(\yii\authclient\BaseClient $client)
106
    {
107
        $mappings = [
108
            'service' => [
109
                // id of user in service
110
                'service_id' => static::$ServiceIdMapping,
111
            ],
112
            'user' => [
113
                'username' => [
114
                    'app\modules\user\authclients\GitHub' => 'login',
115
                    'yii\authclient\clients\Twitter' => 'screen_name',
116
                    'app\modules\user\authclients\VKontakte' => 'nickname',
117
                    'yii\authclient\clients\YandexOAuth' => 'login',
118
                ],
119
                'email' => [
120
                    'app\modules\user\authclients\GitHub' => 'email',
121
                    'yii\authclient\clients\YandexOpenId' => 'email',
122
                    'app\modules\user\authclients\Facebook' => 'email',
123
                    'yii\authclient\clients\YandexOAuth' => 'default_email',
124
                ],
125
                'first_name' => [
126
                    'app\modules\user\authclients\Facebook' => 'first_name',
127
                    'app\modules\user\authclients\VKontakte' => 'first_name',
128
                    'yii\authclient\clients\YandexOAuth' => 'first_name',
129
                ],
130
                'last_name' => [
131
                    'app\modules\user\authclients\Facebook' => 'last_name',
132
                    'app\modules\user\authclients\VKontakte' => 'last_name',
133
                    'yii\authclient\clients\YandexOAuth' => 'last_name',
134
                ],
135
                'avatar_url' => [
136
                    'app\modules\user\authclients\GitHub' => 'avatar_url',
137
                    'yii\authclient\clients\Twitter' => 'profile_image_url',
138
                    'app\modules\user\authclients\VKontakte' => 'photo',
139
                ],
140
                'company' => [
141
                    'app\modules\user\authclients\GitHub' => 'company',
142
                ],
143
                'url' => [
144
                    'app\modules\user\authclients\GitHub' => 'html_url',
145
                ],
146
                'location' => [
147
                    'app\modules\user\authclients\GitHub' => 'location',
148
                ],
149
            ],
150
        ];
151
152
        $class_name = $client->className();
0 ignored issues
show
Deprecated Code introduced by
The method yii\base\BaseObject::className() has been deprecated with message: since 2.0.14. On PHP >=5.5, use `::class` instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
153
        $attributes = $client->getUserAttributes();
154
        $result = [];
155
        foreach ($mappings as $model_type => $mappings_by_attribute) {
156
            $result [$model_type] = [];
157
158
            foreach ($mappings_by_attribute as $attribute => $maps) {
159
                if (isset($maps[$class_name])) {
160
                    $key_in_attributes = $maps[$class_name];
161
                    $value = null;
0 ignored issues
show
$value is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
162
                    if (is_array($key_in_attributes)) {
163
                        $value = [];
164
                        foreach ($key_in_attributes as $key) {
165
                            if (isset($attributes[$key])) {
166
                                $value[] = $attributes[$key];
167
                            }
168
                        }
169
                        if (count($value) > 0) {
170
                            $value = implode(' ', $value);
171
                        } else {
172
                            $value = null;
173
                        }
174
                    } else {
175
                        $value = isset($attributes[$key_in_attributes]) ? $attributes[$key_in_attributes] : null;
176
                    }
177
178
                    if ($value !== null) {
179
                        $result[$model_type][$attribute] = $value;
180
                    }
181
                }
182
            }
183
        }
184
185
        return $result;
186
    }
187
188
}