Issues (129)

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/Suite/Guard.php (1 issue)

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 YEntWeChat\Suite;
4
5
use YEntWeChat\Server\Guard as ServerGuard;
6
use YEntWeChat\Support\Collection;
7
use YEntWeChat\Support\Log;
8
use Symfony\Component\HttpFoundation\Response;
9
10
class Guard extends ServerGuard
11
{
12
    const EVENT_CREATE_AUTH = 'create_auth';
13
    const EVENT_CANCEL_AUTH = 'cancel_auth';
14
    const EVENT_CHANGE_AUTH = 'change_auth';
15
    const EVENT_SUITE_TICKET = 'suite_ticket';
16
17
    /**
18
     * Event handlers.
19
     *
20
     * @var \EntWeChat\Support\Collection
21
     */
22
    protected $handlers;
23
24
    /**
25
     * Get handlers.
26
     *
27
     * @return \EntWeChat\Support\Collection
28
     */
29
    public function getHandlers()
30
    {
31
        return $this->handlers;
32
    }
33
34
    /**
35
     * Set handlers.
36
     *
37
     * @param array $handlers
38
     */
39
    public function setHandlers(array $handlers)
40
    {
41
        $this->handlers = new Collection($handlers);
0 ignored issues
show
Documentation Bug introduced by
It seems like new \YEntWeChat\Support\Collection($handlers) of type object<YEntWeChat\Support\Collection> is incompatible with the declared type object<EntWeChat\Support\Collection> of property $handlers.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
42
43
        return $this;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function serve()
50
    {
51
        $message = $this->getMessage();
52
53
        // Handle Messages.
54
        if (isset($message['MsgType'])) {
55
            return parent::serve();
56
        }
57
58
        Log::debug('Suite Request received:', [
59
            'Method'   => $this->request->getMethod(),
60
            'URI'      => $this->request->getRequestUri(),
61
            'Query'    => $this->request->getQueryString(),
62
            'Protocal' => $this->request->server->get('SERVER_PROTOCOL'),
63
            'Content'  => $this->request->getContent(),
64
        ]);
65
66
        // If sees the `auth_code` query parameter in the url, that is,
67
        // authorization is successful and it calls back, meanwhile, an
68
        // `authorized` event, which also includes the auth code, is sent
69
        // from WeChat, and that event will be handled.
70
        if ($this->request->get('auth_code')) {
71
            return new Response(self::SUCCESS_EMPTY_RESPONSE);
72
        }
73
74
        $this->handleEventMessage($message);
75
76
        return new Response(self::SUCCESS_EMPTY_RESPONSE);
77
    }
78
79
    /**
80
     * Handle event message.
81
     *
82
     * @param array $message
83
     */
84
    protected function handleEventMessage(array $message)
85
    {
86
        Log::debug('Suite Event Message detail:', $message);
87
88
        $message = new Collection($message);
89
90
        $infoType = $message->get('InfoType');
91
92
        if ($handler = $this->getHandler($infoType)) {
93
            $handler->handle($message);
94
        } else {
95
            Log::notice("No existing handler for '{$infoType}'.");
96
        }
97
98
        if ($customHandler = $this->getMessageHandler()) {
99
            $customHandler($message);
100
        }
101
    }
102
103
    /**
104
     * Get handler.
105
     *
106
     * @param string $type
107
     *
108
     * @return \EntWeChat\Suite\EventHandlers\EventHandler|null
109
     */
110
    public function getHandler($type)
111
    {
112
        return $this->handlers->get($type);
113
    }
114
}
115