Issues (108)

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/Chat/Chat.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
3
namespace EntWeChat\Chat;
4
5
use EntWeChat\Core\AbstractAPI;
6
7
/**
8
 * Class Chat.
9
 */
10
class Chat extends AbstractAPI
11
{
12
    const API_GET = 'https://qyapi.weixin.qq.com/cgi-bin/chat/get';
13
    const API_CREATE = 'https://qyapi.weixin.qq.com/cgi-bin/chat/create';
14
    const API_UPDATE = 'https://qyapi.weixin.qq.com/cgi-bin/chat/update';
15
    const API_QUIT = 'https://qyapi.weixin.qq.com/cgi-bin/chat/quit';
16
    const API_CLEAR_NOTIFY = 'https://qyapi.weixin.qq.com/cgi-bin/chat/clearnotify';
17
    const API_SEND = 'https://qyapi.weixin.qq.com/cgi-bin/chat/send';
18
    const API_SET_MUTE = 'https://qyapi.weixin.qq.com/cgi-bin/chat/setmute';
19
20
    const CHAT_TYPE_SINGLE = 'single';  // 单聊
21
    const CHAT_TYPE_GROUP = 'group';   // 群聊
22
23
    const MSG_TYPE_TEXT = 'text';   // 文本
24
    const MSG_TYPE_VOICE = 'voice';  // 语音
25
    const MSG_TYPE_IMAGE = 'image';  // 图片
26
    const MSG_TYPE_FILE = 'file';   // 文件
27
    const MSG_TYPE_LINK = 'link';   // 文件
28
29
    /**
30
     * Fetch a chat by chat id.
31
     *
32
     * @param string $chatId
33
     *
34
     * @return \EntWeChat\Support\Collection
35
     */
36
    public function get($chatId)
37
    {
38
        $params = [
39
            'chatid' => $chatId,
40
        ];
41
42
        return $this->parseJSON('get', [self::API_GET, $params]);
43
    }
44
45
    /**
46
     * Create chat.
47
     *
48
     * @param string $chatId
49
     * @param string $name
50
     * @param string $owner
51
     * @param array  $userList
52
     *
53
     * @return \EntWeChat\Support\Collection
54
     */
55
    public function create($chatId, $name, $owner, array $userList)
56
    {
57
        $params = [
58
            'chatid'   => $chatId,
59
            'name'     => $name,
60
            'owner'    => $owner,
61
            'userlist' => $userList,
62
        ];
63
64
        return $this->parseJSON('json', [self::API_CREATE, $params]);
65
    }
66
67
    /**
68
     * Update chat.
69
     *
70
     * @param string $chatId
71
     * @param string $opUser
72
     * @param array  $chatInfo
73
     *
74
     * @return \EntWeChat\Support\Collection
75
     */
76 View Code Duplication
    public function update($chatId, $opUser, array $chatInfo = [])
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...
77
    {
78
        $params = array_merge($chatInfo, [
79
            'chatid'  => $chatId,
80
            'op_user' => $opUser,
81
        ]);
82
83
        return $this->parseJSON('json', [self::API_UPDATE, $params]);
84
    }
85
86
    /**
87
     * Quit chat.
88
     *
89
     * @param string $chatId
90
     * @param string $opUser
91
     *
92
     * @return \EntWeChat\Support\Collection
93
     */
94 View Code Duplication
    public function quit($chatId, $opUser)
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...
95
    {
96
        $params = [
97
            'chatid'  => $chatId,
98
            'op_user' => $opUser,
99
        ];
100
101
        return $this->parseJSON('json', [self::API_QUIT, $params]);
102
    }
103
104
    /**
105
     * Clear chat.
106
     *
107
     * @param string $chatId
108
     * @param array  $chat
109
     *
110
     * @return \EntWeChat\Support\Collection
111
     */
112
    public function clear($chatId, array $chat)
113
    {
114
        $params = [
115
            'chatid' => $chatId,
116
            'chat'   => $chat,
117
        ];
118
119
        return $this->parseJSON('json', [self::API_CLEAR_NOTIFY, $params]);
120
    }
121
122
    /**
123
     * Send chat.
124
     *
125
     * @param string $type
126
     * @param string $id
127
     * @param string $sender
128
     * @param string $msgType
129
     * @param mixed  $message
130
     *
131
     * @return \EntWeChat\Support\Collection
132
     */
133
    public function send($type, $id, $sender, $msgType, $message)
134
    {
135
        $content = (new Transformer($msgType, $message))->transform();
136
137
        $params = array_merge([
138
            'receiver' => [
139
                'type' => $type,
140
                'id'   => $id,
141
            ],
142
            'sender' => $sender,
143
        ], $content);
144
145
        return $this->parseJSON('json', [self::API_SEND, $params]);
146
    }
147
148
    /**
149
     * Set chat.
150
     *
151
     * @return \EntWeChat\Support\Collection
152
     */
153
    public function mute(array $userMuteList)
154
    {
155
        $params = [
156
            'user_mute_list' => $userMuteList,
157
        ];
158
159
        return $this->parseJSON('json', [self::API_SET_MUTE, $params]);
160
    }
161
}
162