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.

ServiceProviders/SuiteServiceProvider.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\Foundation\ServiceProviders;
4
5
use EntWeChat\Auth\App;
6
use EntWeChat\Encryption\Encryptor;
7
use EntWeChat\Foundation\Application;
8
use EntWeChat\Suite\AccessToken;
9
use EntWeChat\Suite\Api\BaseApi;
10
use EntWeChat\Suite\Api\PreAuthorization;
11
use EntWeChat\Suite\Authorization;
12
use EntWeChat\Suite\AuthorizerAccessToken;
13
use EntWeChat\Suite\EventHandlers;
14
use EntWeChat\Suite\Guard;
15
use EntWeChat\Suite\Suite;
16
use EntWeChat\Suite\Ticket;
17
use Pimple\Container;
18
use Pimple\ServiceProviderInterface;
19
20
class SuiteServiceProvider implements ServiceProviderInterface
21
{
22
    /**
23
     * Registers services on the given container.
24
     *
25
     * This method should only be used to configure services and parameters.
26
     * It should not get services.
27
     *
28
     * @param Container $pimple A container instance
29
     */
30
    public function register(Container $pimple)
31
    {
32
        $pimple['suite.ticket'] = function ($pimple) {
33
            return new Ticket(
34
                $pimple['config']['suite']['suite_id'],
35
                $pimple['cache']
36
            );
37
        };
38
39
        $pimple['suite.access_token'] = function ($pimple) {
40
            $accessToken = new AccessToken(
41
                $pimple['config']['suite']['suite_id'],
42
                $pimple['config']['suite']['secret'],
43
                $pimple['cache']
44
            );
45
            $accessToken->setTicket($pimple['suite.ticket']);
46
47
            return $accessToken;
48
        };
49
50
        $pimple['suite.encryptor'] = function ($pimple) {
51
            return new Encryptor(
52
                $pimple['config']['suite']['suite_id'],
53
                $pimple['config']['suite']['token'],
54
                $pimple['config']['suite']['aes_key']
55
            );
56
        };
57
58
        $pimple['suite'] = function ($pimple) {
59
            return new Suite($pimple);
60
        };
61
62
        $pimple['suite.server'] = function ($pimple) {
63
            $server = new Guard($pimple['config']['suite']['token']);
0 ignored issues
show
The call to Guard::__construct() misses a required argument $corpId.

This check looks for function calls that miss required arguments.

Loading history...
64
            $server->debug($pimple['config']['debug']);
65
            $server->setEncryptor($pimple['suite.encryptor']);
66
            $server->setHandlers([
67
                Guard::EVENT_CREATE_AUTH  => $pimple['suite.handlers.create_auth'],
68
                Guard::EVENT_CANCEL_AUTH  => $pimple['suite.handlers.cancel_auth'],
69
                Guard::EVENT_CHANGE_AUTH  => $pimple['suite.handlers.change_auth'],
70
                Guard::EVENT_SUITE_TICKET => $pimple['suite.handlers.suite_ticket'],
71
            ]);
72
73
            return $server;
74
        };
75
76
        $pimple['suite.pre_auth'] = $pimple['suite.pre_authorization'] = function ($pimple) {
77
            return new PreAuthorization(
78
                $pimple['suite.access_token'],
79
                $pimple['request']
80
            );
81
        };
82
83
        $pimple['suite.api'] = function ($pimple) {
84
            return new BaseApi(
85
                $pimple['suite.access_token'],
86
                $pimple['request']
87
            );
88
        };
89
90
        $pimple['suite.authorization'] = function ($pimple) {
91
            return new Authorization(
92
                $pimple['suite.api'],
93
                $pimple['config']['suite']['corp_id'],
94
                $pimple['cache']
95
            );
96
        };
97
98
        $pimple['suite.authorizer_access_token'] = function ($pimple) {
99
            return new AuthorizerAccessToken(
100
                $pimple['config']['suite']['corp_id'],
101
                $pimple['suite.authorization']
102
            );
103
        };
104
105
        // Authorization events handlers.
106
        $pimple['suite.handlers.suite_ticket'] = function ($pimple) {
107
            return new EventHandlers\SuiteTicket($pimple['suite.ticket']);
108
        };
109
        $pimple['suite.handlers.create_auth'] = function () {
110
            return new EventHandlers\CreateAuth();
111
        };
112
        $pimple['suite.handlers.change_auth'] = function () {
113
            return new EventHandlers\ChangeAuth();
114
        };
115
        $pimple['suite.handlers.cancel_auth'] = function () {
116
            return new EventHandlers\CancelAuth();
117
        };
118
119
        $pimple['suite.app'] = function ($pimple) {
120
            return new Application($pimple['config']->toArray());
121
        };
122
123
        // OAuth for Suite.
124
        $pimple['suite.oauth'] = function ($pimple) {
125
            return new App($pimple['suite.authorizer_access_token']->getToken());
126
        };
127
    }
128
129
    /**
130
     * Prepare the OAuth callback url for wechat.
131
     *
132
     * @param Container $pimple
133
     *
134
     * @return string
135
     */
136
    private function prepareCallbackUrl($pimple)
0 ignored issues
show
This method is not used, and could be removed.
Loading history...
137
    {
138
        $callback = $pimple['config']->get('oauth.callback');
139
        if (0 === stripos($callback, 'http')) {
140
            return $callback;
141
        }
142
        $baseUrl = $pimple['request']->getSchemeAndHttpHost();
143
144
        return $baseUrl.'/'.ltrim($callback, '/');
145
    }
146
}
147