Issues (4141)

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.

app/Controller/PagseguroController.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
require 'GatewayInterface.php';
4
include(APP . 'Vendor/PagSeguro/source/PagSeguroLibrary/PagSeguroLibrary.php');
5
6
class PagseguroController extends AppController implements GatewayInterface
7
{
8
9
    private $paymentRequest;
10
    private $email;
11
    private $token;
12
    private $produtos = array();
13
    private $client = array();    
0 ignored issues
show
The property $client is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
14
    private $reference;
15
    private $valor_frete;
16
17
    public function __construct()
18
    {
19
        $this->paymentRequest = new PagSeguroPaymentRequest();
20
        // Set the currency
21
        $this->paymentRequest->setCurrency("BRL");
22
    }
23
    
24
    // $products, $andress, $client, $total, $valor_frete, $id_venda
25
    public function finalizarPedido()
26
    {
27
        $this->paymentRequest->setReference($this->reference);
28
        $this->paymentRequest->setShippingCost($this->valor_frete);
29
30
31
        // Set the url used by PagSeguro to redirect user after checkout process ends
32
        $this->paymentRequest->setRedirectUrl("http://www.lojamodelo.com.br");
33
34
        try {
35
36
            /*
37
             * #### Credentials #####
38
             * Replace the parameters below with your credentials
39
             * You can also get your credentials from a config file. See an example:
40
             * $credentials = PagSeguroConfig::getAccountCredentials();
41
            //  */
42
43
            // seller authentication
44
            $credentials = new PagSeguroAccountCredentials($this->email, $this->token);
45
46
            // application authentication
47
            //$credentials = PagSeguroConfig::getApplicationCredentials();
48
49
            //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3");
50
51
            // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer.
52
            $url = $this->paymentRequest->register($credentials);
53
            
54
            return $url;
55
56
        } catch (PagSeguroServiceException $e) {
57
58
            die($e->getMessage());
0 ignored issues
show
Coding Style Compatibility introduced by
The method finalizarPedido() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
59
60
        }
61
    }
62
63
    /**
64
    * @return void
65
    * @param String $token
66
    **/
67
    public function setToken($token)
68
    {
69
        $this->token = $token;
70
    }
71
72
    /**
73
    * @return String $token
74
    **/
75
    public function getToken()
76
    {
77
        return $this->token;
78
    }
79
80
    /**
81
    * @return void
82
    * @param String $email
83
    **/
84
    public function setEmail($email)
85
    {
86
        $this->email = $email;
87
    }
88
89
    /**
90
    * @return String $email
91
    **/
92
    public function getEmail()
93
    {
94
        return $this->email;
95
    }
96
97
    /**
98
    * @return void
99
    * @param Array $produtos
100
    **/
101
    public function setProdutos($produtos)
102
    {
103
        $this->produtos = $produtos;
104
    }
105
106
    /**
107
    * @return Array $produtos
108
    **/
109
    public function getProdutos()
110
    {
111
        return $this->produtos;
112
    }
113
114
    /**
115
    * @param Array Produtos
116
    * @return Array Produtos
117
    **/
118
    public function adicionarProdutosGateway()
119
    {
120
        if (empty($this->getProdutos()))
121
        {
122
            throw new Exception("Você precisa usar a função setar os dados do produto!", 1);            
123
        }
124
125
        foreach ($this->getProdutos() as $i => $item) {
126
            $this->paymentRequest->addItem(
127
                '000' . $item['Produto']['id'], 
128
                $item['Produto']['nome'] . '    Tamanho: '. $item['Produto']['variacao'], 
129
                $item['Produto']['quantidade'], 
130
                number_format($item['Produto']['preco'], 2, '.', '')
131
            );
132
        }
133
134
        return $this->getProdutos();
135
    }
136
137
    public function setEndereco($endereco)
138
    {
139
        $this->endereco = $endereco;
0 ignored issues
show
The property endereco does not exist on object<PagseguroController>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
140
    }
141
142
    public function getEndereco()
143
    {
144
        return $this->endereco;
145
    }
146
147
    public function setEnderecoClienteGateway()
148
    {
149
        if (empty($this->endereco))
150
        {
151
            throw new Exception("Você precisa usar a função setar os dados do cliente!", 1);            
152
        }
153
154
        $sedexCode = PagSeguroShippingType::getCodeByType('PAC');
155
        $paymentRequest->setShippingType($sedexCode);
0 ignored issues
show
The variable $paymentRequest does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
156
157
        $paymentRequest->setShippingAddress(
158
            $this->endereco['cep'],
159
            $this->endereco['endereco'],
160
            $this->endereco['numero'],
161
            $this->endereco['complemento'],
162
            $this->endereco['bairro'],
163
            $this->endereco['cidade'],
164
            $this->endereco['estado'],
165
            'BRA'
166
        );
167
168
        return $this->getEndereco();
169
    }
170
171
    public function setReference($reference)
172
    {
173
        $this->reference = $reference;
174
    }
175
176
    public function getReference()
177
    {
178
        return $this->reference;
179
    }
180
181
    public function setValorFrete($valor_frete)
182
    {
183
        $this->valor_frete = $valor_frete;
184
    }
185
186
    public function getValorFrete()
187
    {
188
        return $this->valor_frete;
189
    }
190
191
    public function setClienteGateway()
192
    {
193
        if (empty($this->cliente))
194
        {
195
            throw new Exception("Você precisa usar a função setar os dados do cliente!", 1);            
196
        }
197
198
        // Set your customer information.
199
        $this->paymentRequest->setSender(
200
            $this->cliente['nome'],
201
            $this->cliente['email'],
202
            $this->cliente['ddd'],
203
            $this->cliente['telefone'],
204
            'CPF',
205
            $this->cliente['cpf']
206
        );
207
208
        return $this->getCliente();
209
    }
210
211
    public function setCliente($cliente)
212
    {
213
        $this->cliente = $cliente;
214
    }
215
216
    public function getCliente()
217
    {
218
        return $this->cliente;
219
    }
220
221
}