Issues (233)

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/CacheDriver/RedisDriver.php (4 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 Wechat\CacheDriver;
4
5
use Wechat\CacheDriver\BaseDriver;
6
7
/**
8
 * 文件缓存驱动.
9
 *
10
 */
11
class RedisDriver extends BaseDriver
12
{
13
    private $redis;
14
    private $pre;
15
16
    public function __construct()
17
    {
18
        $pre = 'WeixinApi:';
19
        parent::__construct($pre);
20
21
        if (!class_exists('redis')) {
22
            exit('Redis初始化连接失败');
0 ignored issues
show
Coding Style Compatibility introduced by
The method __construct() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
23
        }
24
25
        ini_set('default_socket_timeout', 50);//socket连接超时时间;
26
        $this->redis = new \redis();
27
        // 如果用框架 此处最好走配置文件
28
        $host      = '127.0.0.1';
29
        $port      = '6379';
30
        $this->pre = $pre;
31
        $link      = $this->redis->connect($host, $port, 40);
32
33
        if (!$link) {
34
            exit('Redis初始化连接失败');
0 ignored issues
show
Coding Style Compatibility introduced by
The method __construct() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
35
        }
36
    }
37
38
    /**
39
     * 根据缓存名获取缓存内容.
40
     *
41
     * @param string $name
42
     *
43
     * @return bool|mixed|string
44
     */
45
    public function _get($name)
46
    {
47
        $name = $this->createFileName($name);
48
        $data = $this->redis->get($name);
49
        if ($data) {
50
            $data = $this->unpackData($data);
51
        }
52
53
        return $data;
54
    }
55
56
    /**
57
     * 根据缓存名 设置缓存值和超时时间.
58
     *
59
     * @param string $name    缓存名
60
     * @param void   $value   缓存值
61
     * @param int    $expires 超时时间
62
     *
63
     * @return boolean;
0 ignored issues
show
The doc-type boolean; could not be parsed: Expected "|" or "end of type", but got ";" at position 7. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
64
     */
65
    public function _set($name, $value, $expires)
66
    {
67
        $name = $this->createFileName($name);
68
        $data = $this->packData($value);
69
        if ($expires === 0) {
70
            return $this->redis->set($name, $data);
71
        }
72
73
        return $this->redis->setex($name, $expires, $data);
74
    }
75
76
    /**
77
     * 数据打包.
78
     *
79
     * @param void $data    缓存值
80
     * @param int  $expires 超时时间
0 ignored issues
show
There is no parameter named $expires. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
81
     *
82
     * @return string
83
     */
84
    private function packData($data)
85
    {
86
        return serialize($data);
87
    }
88
89
    /**
90
     * 数据解包.
91
     *
92
     * @param $data
93
     *
94
     * @return mixed
95
     */
96
    private function unpackData($data)
97
    {
98
        return unserialize($data);
99
    }
100
101
    /**
102
     * 创建缓存文件名.
103
     *
104
     * @param string $name 缓存名
105
     *
106
     * @return string
107
     */
108
    private function createFileName($name)
109
    {
110
        return $this->pre . md5($name);
111
    }
112
}
113