Issues (19)

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/Credential.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
/*
4
 * This file is part of the slince/smartqq package.
5
 *
6
 * (c) Slince <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Slince\SmartQQ;
13
14
use GuzzleHttp\Cookie\CookieJar;
15
use GuzzleHttp\Cookie\SetCookie;
16
17
class Credential
18
{
19
    /**
20
     * 鉴权参数ptwebqq,存储在cookie中.
21
     *
22
     * @var string
23
     */
24
    protected $ptWebQQ;
25
26
    /**
27
     * 鉴权参数vfwebqq.
28
     *
29
     * @var string
30
     */
31
    protected $vfWebQQ;
32
33
    /**
34
     * 鉴权参数pSessionId.
35
     *
36
     * @var string
37
     */
38
    protected $pSessionId;
39
40
    /**
41
     * 客户端id.
42
     *
43
     * @var int
44
     */
45
    protected $clientId;
46
47
    /**
48
     * 当前登录的用户编号(o+QQ号).
49
     *
50
     * @var string
51
     */
52
    protected $uin;
53
54
    /**
55
     * cookie信息,由于client发起请求需要使用cookie信息故cookie也需要一同处理.
56
     *
57
     * @var CookieJar
58
     */
59
    protected $cookies;
60
61
    public function __construct($ptWebQQ, $vfWebQQ, $pSessionId, $uin, $clientId, CookieJar $cookies)
62
    {
63
        $this->ptWebQQ = $ptWebQQ;
64
        $this->vfWebQQ = $vfWebQQ;
65
        $this->pSessionId = $pSessionId;
66
        $this->uin = $uin;
67
        $this->clientId = $clientId;
68
        $this->cookies = $cookies;
69
    }
70
71
    /**
72
     * @return string
73
     */
74
    public function getPtWebQQ()
75
    {
76
        return $this->ptWebQQ;
77
    }
78
79
    /**
80
     * @param string $ptWebQQ
81
     */
82
    public function setPtWebQQ($ptWebQQ)
83
    {
84
        $this->ptWebQQ = $ptWebQQ;
85
    }
86
87
    /**
88
     * @return string
89
     */
90
    public function getVfWebQQ()
91
    {
92
        return $this->vfWebQQ;
93
    }
94
95
    /**
96
     * @param string $vfWebQQ
97
     */
98
    public function setVfWebQQ($vfWebQQ)
99
    {
100
        $this->vfWebQQ = $vfWebQQ;
101
    }
102
103
    /**
104
     * @return string
105
     */
106
    public function getPSessionId()
107
    {
108
        return $this->pSessionId;
109
    }
110
111
    /**
112
     * @return CookieJar
113
     */
114
    public function getCookies()
115
    {
116
        return $this->cookies;
117
    }
118
119
    /**
120
     * @param CookieJar $cookies
121
     */
122
    public function setCookies($cookies)
123
    {
124
        $this->cookies = $cookies;
125
    }
126
127
    /**
128
     * @param string $pSessionId
129
     */
130
    public function setPSessionId($pSessionId)
131
    {
132
        $this->pSessionId = $pSessionId;
133
    }
134
135
    /**
136
     * @return int
137
     */
138
    public function getClientId()
139
    {
140
        return $this->clientId;
141
    }
142
143
    /**
144
     * @param int $clientId
145
     */
146
    public function setClientId($clientId)
147
    {
148
        $this->clientId = $clientId;
149
    }
150
151
    /**
152
     * @return string
153
     */
154
    public function getUin()
155
    {
156
        return $this->uin;
157
    }
158
159
    /**
160
     * @param string $uin
161
     */
162
    public function setUin($uin)
163
    {
164
        $this->uin = $uin;
165
    }
166
167
    /**
168
     * @return array
169
     */
170
    public function toArray()
171
    {
172
        return [
173
            'ptWebQQ' => $this->ptWebQQ,
174
            'vfWebQQ' => $this->vfWebQQ,
175
            'pSessionId' => $this->pSessionId,
176
            'uin' => $this->uin,
177
            'clientId' => $this->clientId,
178
            'cookies' => $this->cookies->toArray(),
179
        ];
180
    }
181
182
    /**
183
     * Create from a array data.
184
     *
185
     * @param array $data
186
     *
187
     * @return static
188
     */
189
    public static function fromArray(array $data)
190
    {
191
        $cookieJar = null;
192
        if (isset($data['cookies'])) {
193
            $cookieJar = new CookieJar();
194
            foreach ($data['cookies'] as $cookie) {
195
                $cookieJar->setCookie(new SetCookie($cookie));
196
            }
197
        }
198
199
        return new static($data['ptWebQQ'], $data['vfWebQQ'],
200
            $data['pSessionId'], $data['uin'], $data['clientId'],
201
            $cookieJar
0 ignored issues
show
It seems like $cookieJar defined by null on line 191 can be null; however, Slince\SmartQQ\Credential::__construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
202
        );
203
    }
204
}
205