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/User/User.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 EntWeChat\User;
4
5
use EntWeChat\Core\AbstractAPI;
6
7
/**
8
 * Class User.
9
 */
10
class User extends AbstractAPI
11
{
12
    const API_CREATE = 'https://qyapi.weixin.qq.com/cgi-bin/user/create';
13
    const API_UPDATE = 'https://qyapi.weixin.qq.com/cgi-bin/user/update';
14
    const API_DELETE = 'https://qyapi.weixin.qq.com/cgi-bin/user/delete';
15
    const API_BATCH_DELETE = 'https://qyapi.weixin.qq.com/cgi-bin/user/batchdelete';
16
    const API_GET = 'https://qyapi.weixin.qq.com/cgi-bin/user/get';
17
    const API_BATCH_GET = 'https://qyapi.weixin.qq.com/cgi-bin/user/simplelist';
18
    const API_LIST = 'https://qyapi.weixin.qq.com/cgi-bin/user/list';
19
    const API_TO_OPENID = 'https://qyapi.weixin.qq.com/cgi-bin/user/convert_to_openid';
20
    const API_TO_USERID = 'https://qyapi.weixin.qq.com/cgi-bin/user/convert_to_userid';
21
22
    /**
23
     * Fetch a user by user id.
24
     *
25
     * @param string $userId
26
     *
27
     * @return array
28
     */
29 View Code Duplication
    public function get($userId)
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...
30
    {
31
        $params = [
32
            'userid' => $userId,
33
        ];
34
35
        return $this->parseJSON('get', [self::API_GET, $params]);
36
    }
37
38
    /**
39
     * Batch get users.
40
     *
41
     * @param int      $departmentId
42
     * @param int|null $fetchChild
43
     * @param int|null $status
44
     *
45
     * @return \EntWeChat\Support\Collection
46
     */
47 View Code Duplication
    public function batchGet($departmentId, $fetchChild = null, $status = null)
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...
48
    {
49
        $params = [
50
            'department_id' => $departmentId,
51
            'fetch_child'   => $fetchChild,
52
            'status'        => $status,
53
        ];
54
55
        return $this->parseJSON('get', [self::API_BATCH_GET, $params]);
56
    }
57
58
    /**
59
     * List users.
60
     *
61
     * @param int      $departmentId
62
     * @param int|null $fetchChild
63
     * @param int|null $status
64
     *
65
     * @return \EntWeChat\Support\Collection
66
     */
67 View Code Duplication
    public function lists($departmentId, $fetchChild = null, $status = null)
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...
68
    {
69
        $params = [
70
            'department_id' => $departmentId,
71
            'fetch_child'   => $fetchChild,
72
            'status'        => $status,
73
        ];
74
75
        return $this->parseJSON('get', [self::API_LIST, $params]);
76
    }
77
78
    /**
79
     * Create a user.
80
     *
81
     * @param array $userInfo
82
     *
83
     * @return \EntWeChat\Support\Collection
84
     */
85
    public function create(array $userInfo = [])
86
    {
87
        $params = $userInfo;
88
89
        return $this->parseJSON('json', [self::API_CREATE, $params]);
90
    }
91
92
    /**
93
     * Update a user.
94
     *
95
     * @param string $userId
96
     * @param array  $userInfo
97
     *
98
     * @return \EntWeChat\Support\Collection
99
     */
100
    public function update($userId, array $userInfo = [])
101
    {
102
        $params = array_merge($userInfo, ['userid' => $userId]);
103
104
        return $this->parseJSON('json', [self::API_UPDATE, $params]);
105
    }
106
107
    /**
108
     * Delete a user.
109
     *
110
     * @param string $userId
111
     *
112
     * @return \EntWeChat\Support\Collection
113
     */
114
    public function delete($userId)
115
    {
116
        $params = ['userid' => $userId];
117
118
        return $this->parseJSON('json', [self::API_DELETE, $params]);
119
    }
120
121
    /**
122
     * Batch delete users.
123
     *
124
     * @param array $userIds
125
     *
126
     * @return \EntWeChat\Support\Collection
127
     */
128
    public function batchDelete(array $userIds)
129
    {
130
        $params = ['useridlist' => $userIds];
131
132
        return $this->parseJSON('json', [self::API_BATCH_DELETE, $params]);
133
    }
134
135
    /**
136
     * Convert userid to openid.
137
     *
138
     * @param string $userId
139
     * @param int    $agentId
140
     *
141
     * @return \EntWeChat\Support\Collection
142
     */
143 View Code Duplication
    public function toOpenId($userId, $agentId)
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...
144
    {
145
        $params = [
146
            'userid'  => $userId,
147
            'agentid' => $agentId,
148
        ];
149
150
        return $this->parseJSON('json', [self::API_TO_OPENID, $params]);
151
    }
152
153
    /**
154
     * Convert openid to userid.
155
     *
156
     * @param string $openId
157
     *
158
     * @return \EntWeChat\Support\Collection
159
     */
160
    public function toUserId($openId)
161
    {
162
        $params = ['openid' => $openId];
163
164
        return $this->parseJSON('json', [self::API_TO_USERID, $params]);
165
    }
166
}
167