Issues (80)

Security Analysis    no request data  

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/Services/PersonService.php (5 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 Telefonica\Services;
4
5
use Illuminate\Support\Collection;
6
use Illuminate\Support\Facades\Config;
7
use Informate\Models\Refund;
8
use SierraTecnologia\Crypto\Services\Crypto;
9
use Telefonica\Repositories\PersonRepository;
10
use Telefonica\Models\Actors\Person;
11
use Muleta\Utils\Modificators\StringModificator;
12
13
class PersonService
14
{
15
    public function __construct(
16
        PersonRepository $personRepository
17
    ) {
18
        $this->repo = $personRepository;
0 ignored issues
show
The property repo does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
19
    }
20
21
    /**
22
     * @todo Terminar de Fazer
23
     *  "Nome Artístico/ apelido" => ""                                                                                                                                                                                                             
24
  "Nome Completo" => "Paulo Gonçalves Júnior "                                                                                                                                                                                                
25
  "Nascimento " => "01/07/1988"                                                                                                                                                                                                               
26
  "Idade" => "32 anos "                                                                                                                                                                                                                       
27
  "Sexo / Identificação de Gênero" => "Masculino"                                                                                                                                                                                             
28
  "Endereço Completo" => "Rua Mercúrio 479 Casa 1"                                                                                                                                                                                            
29
  "Bairro" => "Pavuna "                                                                                                                                                                                                                       
30
  "Cidade" => "Rio de Janeiro "                                                                                                                                                                                                               
31
  "Telefone que mais usa" => "21982899701"                                                                                                                                                                                                    
32
  "Profissão" => "Produtor Cultural e Dançarino"                                                                                                                                                                                              
33
  "Grau de Escolaridade" => "Segundo Grau Completo (5ª a 3ºano)"                                                                                                                                                                              
34
  "Curso técnico? " => " Gestão Cultural Pela Instituição Idea e Produção Cultural Pela Produtora Burburinho Cultural  ( Em Andamento)"                                                                                                       
35
  "Fala Inglês?" => "Entendo um Pouco"                                                                                                                                                                                                        
36
  "Fala Espanhol?" => "Entendo um Pouco"                                                                                                                                                                                                      
37
  "Fala Francês?" => "Nada"                                                                                                                                                                                                                   
38
  "Fala Alemão?" => "Nada"                                                                                                                                                                                                                    
39
  "Você tem DRT? " => "Não "                                                                                                                                                                                                                  
40
  " RG" => "21.551.582-6"                                                                                                                                                                                                                     
41
  "CPF" => "133.546.337-27"                                                                                                                                                                                                                   
42
  "Você tem MEI? " => "Não "                                                                                                                                                                                                                  
43
  "Agência e conta" => "Agência:0001 Conta Corrente: 20939021-8  Banco: Nubank "                                                                                                                                                              
44
  " PIX" => "Pix: 133.546.337-27"
45
  "Cargos na RUA?" => "Produção Executiva, Dançarina(o)"
46
  "Peso?" => "80 kg"
47
  "Calça?" => "Tamanho G"
48
  " Blusa?" => "Tamanho G"
49
  "Altura?" => "1.68"
50
  "Nº sapato?" => "Numeração  40"
51
  "Redes Sociais." => "Estou no Instagram como @lilp_king. Instale o aplicativo para seguir minhas fotos e vídeos. https://www.instagram.com/invites/contact/?i=g0zjwr5kwk4h&utm_content=wedbxz"
52
53
     */
54
    public static function import($data)
55
    {   
56
        $registerData = [];
57
        if (isset($data['Nome'])) {
58
            $registerData['name'] = $data["Nome"];
59
        }
60
        if (isset($data['Nome Completo'])) {
61
            $registerData['name'] = $data["Nome Completo"];
62
        }
63
        if (isset($data['CPF'])) {
64
            $registerData['cpf'] = $data["CPF"];
65
        }
66
        if (isset($data['Nascimento'])) {
67
            $registerData['birthday'] = $data["Nascimento"];
68
        }
69
        $code = $registerData['code'] = StringModificator::cleanCodeSlug($registerData['name']);
70
71
        if (\Telefonica\Models\Actors\Person::find($code)) {
72
            return true;
73
        }
74
        $person = Person::createIfNotExistAndReturn($registerData);
0 ignored issues
show
$person is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
75
        return true;
76
    }
77
78
    /**
79
     * Get all Persons.
80
     *
81
     * @return Collection
82
     */
83
    public function all()
84
    {
85
        return $this->repo->all();
86
    }
87
88
    /**
89
     * Get all Persons.
90
     *
91
     * @return Illuminate\Pagination\LengthAwarePaginator
92
     */
93
    public function paginated()
94
    {
95
        return $this->repo->paginated(\Illuminate\Support\Facades\Config::get('siravel.pagination', 25));
96
    }
97
98
    /**
99
     * Find the Person by ID.
100
     *
101
     * @param int $id
102
     *
103
     * @return Persons
104
     */
105
    public function find($id)
106
    {
107
        return $this->repo->find($id);
108
    }
109
110
    /**
111
     * Search the orders.
112
     *
113
     * @param array $payload
114
     *
115
     * @return Collection
116
     */
117
    public function search($payload)
118
    {
119
        return $this->repo->search($payload, \Illuminate\Support\Facades\Config::get('siravel.pagination', 25));
120
    }
121
122
    /**
123
     * Create an order.
124
     *
125
     * @param array $payload
126
     *
127
     * @return Persons
128
     */
129
    public function create($payload)
130
    {
131
        $order = $this->repo->store($payload);
132
133
        $this->logistics->orderCreated($order);
0 ignored issues
show
The property logistics does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
134
135
        return $order;
136
    }
137
138
    /**
139
     * Update an order.
140
     *
141
     * @param int   $id
142
     * @param array $payload
143
     *
144
     * @return Persons
145
     */
146
    public function update($id, $payload)
147
    {
148
        $order = $this->find($id);
149
150
        if (isset($payload['is_shipped']) && $payload['is_shipped'] !== false) {
151
            $this->logistics->shipPerson($order);
152
        }
153
154
        return $this->repo->update($order, $payload);
155
    }
156
157
    /**
158
     * Cancel an order.
159
     *
160
     * @param int $id
0 ignored issues
show
There is no parameter named $id. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
161
     *
162
     * @return Persons
163
     */
164
    public function cancel($orderId)
165
    {
166
        $order = $this->repo->find($orderId);
167
168
        if ($order->status != 'complete') {
169
            $this->logistics->cancelPerson($order);
170
171
            if ($order->hasActivePersonItems()) {
172
                $refund = $this->transactions->refund($order->transaction('uuid'), $order->remainingValue());
0 ignored issues
show
The property transactions does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
173
174
                if ($refund) {
175
                    $refundRecord = app(Refund::class)->create(
176
                        [
177
                        'transaction_id' => $order->transaction('id'),
178
                        'provider_id' => $refund->id,
179
                        'uuid' => Crypto::uuid(),
180
                        'amount' => $refund->amount,
181
                        'provider' => 'SierraTecnologia',
182
                        'charge' => $refund->charge,
183
                        'currency' => $refund->currency,
184
                        ]
185
                    );
186
187
                    foreach ($order->items as $item) {
188
                        $item->update(
189
                            [
190
                            'was_refunded' => true,
191
                            'status' => 'cancelled',
192
                            'refund_id' => $refundRecord->id,
193
                            ]
194
                        );
195
                    }
196
197
                    return $this->update(
198
                        $order->id,
199
                        [
200
                        'status' => 'cancelled',
201
                        'is_shipped' => false,
202
                        ]
203
                    );
204
                }
205
            }
206
        }
207
208
        return false;
209
    }
210
}
211