Issues (158)

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/Moip.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 Moip;
4
5
use Moip\Contracts\Authentication;
6
use Moip\Resource\Account;
7
use Moip\Resource\Balances;
8
use Moip\Resource\BankAccount;
9
use Moip\Resource\Customer;
10
use Moip\Resource\Entry;
11
use Moip\Resource\Holder;
12
use Moip\Resource\Keys;
13
use Moip\Resource\Multiorders;
14
use Moip\Resource\NotificationPreferences;
15
use Moip\Resource\Orders;
16
use Moip\Resource\Payment;
17
use Moip\Resource\Refund;
18
use Moip\Resource\Transfers;
19
use Moip\Resource\WebhookList;
20
use Requests_Session;
21
22
/**
23
 * Class Moip.
24
 */
25
class Moip
26
{
27
    /**
28
     * endpoint of production.
29
     *
30
     * @const string
31
     */
32
    const ENDPOINT_PRODUCTION = 'https://api.moip.com.br';
33
34
    /**
35
     * endpoint of sandbox.
36
     *
37
     * @const string
38
     */
39
    const ENDPOINT_SANDBOX = 'https://sandbox.moip.com.br';
40
41
    /**
42
     * Client name.
43
     *
44
     * @const string
45
     * */
46
    const CLIENT = 'MoipPhpSDK';
47
48
    /**
49
     * Client Version.
50
     *
51
     * @const string
52
     */
53
    const CLIENT_VERSION = '3.1.0';
54
55
    /**
56
     * Authentication that will be added to the header of request.
57
     *
58
     * @var \Moip\MoipAuthentication
59
     */
60
    private $moipAuthentication;
61
62
    /**
63
     * Endpoint of request.
64
     *
65
     * @var \Moip\Moip::ENDPOINT_PRODUCTION|\Moip\Moip::ENDPOINT_SANDBOX
66
     */
67
    private $endpoint;
68
69
    /**
70
     * @var Requests_Session HTTP session configured to use the moip API.
71
     */
72
    private $session;
73
74
    /**
75
     * Create a new aurhentication with the endpoint.
76
     *
77
     * @param \Moip\Auth\MoipAuthentication $moipAuthentication
78
     * @param string                        $endpoint
79
     */
80
    public function __construct(Authentication $moipAuthentication, $endpoint = self::ENDPOINT_PRODUCTION)
81
    {
82
        $this->moipAuthentication = $moipAuthentication;
0 ignored issues
show
Documentation Bug introduced by
It seems like $moipAuthentication of type object<Moip\Contracts\Authentication> is incompatible with the declared type object<Moip\MoipAuthentication> of property $moipAuthentication.

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...
83
        $this->endpoint = $endpoint;
0 ignored issues
show
Documentation Bug introduced by
It seems like $endpoint of type string is incompatible with the declared type object<Moip\Moip::ENDPOI...Moip::ENDPOINT_SANDBOX> of property $endpoint.

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...
84
        $this->createNewSession();
85
    }
86
87
    /**
88
     * Creates a new Request_Session with all the default values.
89
     * A Session is created at construction.
90
     *
91
     * @param float $timeout         How long should we wait for a response?(seconds with a millisecond precision, default: 30, example: 0.01).
92
     * @param float $connect_timeout How long should we wait while trying to connect? (seconds with a millisecond precision, default: 10, example: 0.01)
93
     */
94
    public function createNewSession($timeout = 30.0, $connect_timeout = 30.0)
95
    {
96
        $user_agent = sprintf('%s/%s (+https://github.com/moip/moip-sdk-php/)', self::CLIENT, self::CLIENT_VERSION);
97
        $sess = new Requests_Session($this->endpoint);
98
        $sess->options['auth'] = $this->moipAuthentication;
99
        $sess->options['timeout'] = $timeout;
100
        $sess->options['connect_timeout'] = $connect_timeout;
101
        $sess->options['useragent'] = $user_agent;
102
        $this->session = $sess;
103
    }
104
105
    /**
106
     * Returns the http session created.
107
     *
108
     * @return Requests_Session
109
     */
110
    public function getSession()
111
    {
112
        return $this->session;
113
    }
114
115
    /**
116
     * Replace the http session by a custom one.
117
     *
118
     * @param Requests_Session $session
119
     */
120
    public function setSession($session)
121
    {
122
        $this->session = $session;
123
    }
124
125
    /**
126
     * Create a new Customer instance.
127
     *
128
     * @return \Moip\Resource\Customer
129
     */
130
    public function customers()
131
    {
132
        return new Customer($this);
133
    }
134
135
    /**
136
     * Create a new Holder instance.
137
     *
138
     * @return \Moip\Resource\Holder
139
     */
140
    public function holders()
141
    {
142
        return new Holder($this);
143
    }
144
145
    /**
146
     * Create a new Account instance.
147
     *
148
     * @return \Moip\Resource\Account
149
     */
150
    public function accounts()
151
    {
152
        return new Account($this);
153
    }
154
155
    /**
156
     * Create a new Entry instance.
157
     *
158
     * @return \Moip\Resource\Entry
159
     */
160
    public function entries()
161
    {
162
        return new Entry($this);
163
    }
164
165
    /**
166
     * Create a new Orders instance.
167
     *
168
     * @return \Moip\Resource\Orders
169
     */
170
    public function orders()
171
    {
172
        return new Orders($this);
173
    }
174
175
    /**
176
     * Create a new Payment instance.
177
     *
178
     * @return \Moip\Resource\Payment
179
     */
180
    public function payments()
181
    {
182
        return new Payment($this);
183
    }
184
185
    /**
186
     * Create a new Multiorders instance.
187
     *
188
     * @return \Moip\Resource\Multiorders
189
     */
190
    public function multiorders()
191
    {
192
        return new Multiorders($this);
193
    }
194
195
    /**
196
     * Create a new Transfers.
197
     *
198
     * @return \Moip\Resource\Transfers
199
     */
200
201
    /**
202
     * Create a new Transfers instance.
203
     *
204
     * @return Transfers
205
     */
206
    public function transfers()
207
    {
208
        return new Transfers($this);
209
    }
210
211
    /**
212
     * Create a new Notification Prefences instance.
213
     *
214
     * @return NotificationPreferences
215
     */
216
    public function notifications()
217
    {
218
        return new NotificationPreferences($this);
219
    }
220
221
    /**
222
     * Create a new WebhookList instance.
223
     *
224
     * @return WebhookList
225
     */
226
    public function webhooks()
227
    {
228
        return new WebhookList($this);
229
    }
230
231
    /**
232
     * Create a new Keys instance.
233
     *
234
     * @return Keys
235
     */
236
    public function keys()
237
    {
238
        return new Keys($this);
239
    }
240
241
    /**
242
     * Create a new Refund instance.
243
     *
244
     * @return Refund
245
     */
246
    public function refunds()
247
    {
248
        return new Refund($this);
249
    }
250
251
    /**
252
     * Create a new BankAccount instance.
253
     *
254
     * @return BankAccount
255
     */
256
    public function bankaccount()
257
    {
258
        return new BankAccount($this);
259
    }
260
261
    /**
262
     * Create a new Balances instance.
263
     *
264
     * @return Balances
265
     */
266
    public function balances()
267
    {
268
        return new Balances($this);
269
    }
270
271
    /**
272
     * Get the endpoint.
273
     *
274
     * @return \Moip\Moip::ENDPOINT_PRODUCTION|\Moip\Moip::ENDPOINT_SANDBOX
275
     */
276
    public function getEndpoint()
277
    {
278
        return $this->endpoint;
279
    }
280
}
281