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/API/MenuApi.php (2 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
namespace Wechat\API;
3
4
use Closure;
5
6
/**
7
 * 微信菜单相关接口.
8
 *
9
 * @author Tian.
10
 */
11
class MenuApi extends BaseApi
12
{
13
14
    /**
15
     * 设置菜单
16
     *
17
     * @param $menus
18
     *
19
     * @return array|bool
20
     */
21 View Code Duplication
    public function set($menus)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
    {
23
        if ($menus instanceof Closure) {
24
            $menus = $menus($this);
25
        }
26
27
        if (!is_array($menus)) {
28
            $this->setError('子菜单必须是数组或者匿名函数返回数组');
29
30
            return false;
31
        }
32
33
        $menus = $this->extractMenus($menus);
34
35
        $data = ['button' => $menus];
36
37
        $res = $this->_post('create', $data);
38
39
        return $res;
40
    }
41
42
    /**
43
     * 获取菜单
44
     *
45
     * @return array
46
     */
47
    public function get()
48
    {
49
        $queryStr = [];
50
51
        $res = $this->_get('get', $queryStr);
52
53
        return $res;
54
    }
55
56
    /**
57
     * 获取菜单【查询接口,能获取到任意方式设置的菜单】
58
     *
59
     * @return array
60
     */
61
    public function current()
62
    {
63
        $queryStr = [];
64
65
        $this->module = 'get_current_selfmenu_info';
66
67
        $res = $this->_get('', $queryStr);
68
69
        return $res;
70
    }
71
72
    /**
73
     * 删除菜单
74
     *
75
     * @return array
76
     */
77
    public function delete()
78
    {
79
        $queryStr = [];
80
81
        $res = $this->_get('delete', $queryStr);
82
83
        return $res;
84
    }
85
86
    /**
87
     * 转menu为数组
88
     *
89
     * @param array $menus
90
     *
91
     * @return array
92
     */
93
    protected function extractMenus(array $menus)
94
    {
95
        foreach ($menus as $key => $menu) {
96
            $menus[$key] = $menu->toArray();
97
98
            if ($menu->sub_button) {
99
                $menus[$key]['sub_button'] = $this->extractMenus($menu->sub_button);
100
            }
101
        }
102
103
        return $menus;
104
    }
105
106
    /**
107
     * 设置个性化菜单
108
     *
109
     * @author Jia <[email protected]>
110
     *
111
     * @date   2017-04-11
112
     *
113
     * @param  array $menus     菜单数组
114
     * @param  array $matchrule 个性化规则
115
     *
116
     * @return array|bool
117
     */
118 View Code Duplication
    public function setIndividuationMenu($menus, $matchrule)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
119
    {
120
        if ($menus instanceof Closure) {
121
            $menus = $menus($this);
122
        }
123
124
        if (!is_array($menus)) {
125
            $this->setError('子菜单必须是数组或者匿名函数返回数组');
126
127
            return false;
128
        }
129
        $menus = $this->extractMenus($menus);
130
131
        $data = [
132
            'button'    => $menus,
133
            'matchrule' => $matchrule,
134
        ];
135
136
        $res = $this->_post('addconditional', $data);
137
138
        return $res;
139
    }
140
141
    /**
142
     * 测试个性化菜单匹配结果
143
     *
144
     * @author Jia <[email protected]>
145
     *
146
     * @date   2017-04-11
147
     *
148
     * @param  string $openid 用户openid
149
     *
150
     * @return array
151
     */
152
    public function tryMatchUser($openid)
153
    {
154
        $queryStr = [
155
            "user_id" => $openid,
156
        ];
157
158
        $res = $this->_post('trymatch', $queryStr);
159
160
        return $res;
161
    }
162
163
    /**
164
     * 删除个性化菜单
165
     *
166
     * @author Jia <[email protected]>
167
     *
168
     * @date   2017-04-12
169
     *
170
     * @param  int $menuId 个性化菜单id
171
     *
172
     * @return array
173
     */
174
    public function deleteIndividuationMenu($menuId)
175
    {
176
        $queryStr = [
177
            "menuid" => $menuId,
178
        ];
179
180
        $res = $this->_post('delconditional', $queryStr);
181
182
        return $res;
183
    }
184
}
185