Issues (9)

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/Api/OrderApi.php (6 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
namespace SafeCrow\Api;
3
4
use SafeCrow\DataTransformer\OrderDataTransformer;
5
use SafeCrow\Model\Order;
6
use Symfony\Component\OptionsResolver\OptionsResolver;
7
8
/**
9
 * Class OrderApi
10
 * @package SafeCrow\Api
11
 */
12
class OrderApi extends AbstractApi
13
{
14
    /**
15
     * @param array $params
16
     * @return Order
17
     */
18
    public function add(array $params) : Order
19
    {
20
        $resolver = new OptionsResolver();
21
        $resolver
22
            ->setRequired([
23
                'consumer_id',
24
                'supplier_id',
25
                'price',
26
                'description',
27
                'service_cost_payer',
28
                'extra',
29
            ])
30
            ->setDefaults([
31
                'extra' => null,
32
            ])
33
            ->setAllowedTypes('consumer_id', 'int')
34
            ->setAllowedTypes('supplier_id', 'int')
35
            ->setAllowedTypes('price', 'int')
36
            ->setAllowedTypes('description', 'string')
37
            ->setAllowedTypes('service_cost_payer', 'string')
38
            ->setAllowedTypes('extra', ['array', 'null'])
39
            ->setAllowedValues('service_cost_payer', [Order::PAYER_HALF, Order::PAYER_CONSUMER, Order::PAYER_SUPPLIER]);
40
41
        $params = $resolver->resolve($params);
42
43
        $response = $this->post('/orders', $params);
44
45
        return $this->getResult($response, new OrderDataTransformer());
46
    }
47
48
    /**
49
     * @return array
50
     */
51
    public function all(): array
52
    {
53
        $response = $this->get('/orders');
54
55
        return $this->getArrayResult($response, new OrderDataTransformer());
56
    }
57
58
    /**
59
     * @param int $id
60
     * @return Order
61
     */
62
    public function show(int $id) : Order
63
    {
64
        $response = $this->get('/orders/'.$id);
65
66
        return $this->getResult($response, new OrderDataTransformer());
67
    }
68
69
    /**
70
     * @param int   $id
71
     * @param array $params
72
     * @return string
73
     */
74 View Code Duplication
    public function pay(int $id, array $params) : string
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
75
    {
76
        $resolver = new OptionsResolver();
77
        $resolver
78
            ->setRequired([
79
                'redirect_url',
80
            ])
81
            ->setAllowedTypes('redirect_url', 'string');
82
83
        $params = $resolver->resolve($params);
84
85
        $response = $this->post('/orders/'.$id.'/pay', $params);
86
87
        return $this->getSingleResult($response, 'redirect_url');
88
    }
89
90
    /**
91
     * @param int   $id
92
     * @param array $params
93
     * @return Order
94
     */
95 View Code Duplication
    public function annul(int $id, array $params) : Order
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
96
    {
97
        $resolver = new OptionsResolver();
98
        $resolver
99
            ->setRequired([
100
                'reason',
101
            ])
102
            ->setAllowedTypes('reason', 'string');
103
104
        $params = $resolver->resolve($params);
105
106
        $response = $this->post('/orders/'.$id.'/annul', $params);
107
108
        return $this->getResult($response, new OrderDataTransformer());
109
    }
110
111
    /**
112
     * @param int   $id
113
     * @param array $params
114
     * @return Order
115
     */
116 View Code Duplication
    public function cancel(int $id, array $params): Order
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
117
    {
118
        $resolver = new OptionsResolver();
119
        $resolver
120
            ->setRequired([
121
                'reason',
122
            ])
123
            ->setAllowedTypes('reason', 'string');
124
125
        $params = $resolver->resolve($params);
126
127
        $response = $this->post('/orders/'.$id.'/cancel', $params);
128
129
        return $this->getResult($response, new OrderDataTransformer());
130
    }
131
132
    /**
133
     * @param int   $id
134
     * @param array $params
135
     * @return Order
136
     */
137 View Code Duplication
    public function close(int $id, array $params) : Order
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
138
    {
139
        $resolver = new OptionsResolver();
140
        $resolver
141
            ->setRequired([
142
                'reason',
143
            ])
144
            ->setAllowedTypes('reason', 'string');
145
146
        $params = $resolver->resolve($params);
147
148
        $response = $this->post('/orders/'.$id.'/close', $params);
149
150
        return $this->getResult($response, new OrderDataTransformer());
151
    }
152
153
    /**
154
     * @param int   $id
155
     * @param array $params
156
     * @return Order
157
     */
158 View Code Duplication
    public function escalate(int $id, array $params) : Order
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
159
    {
160
        $resolver = new OptionsResolver();
161
        $resolver
162
            ->setRequired([
163
                'reason',
164
            ])
165
            ->setAllowedTypes('reason', 'string');
166
167
        $params = $resolver->resolve($params);
168
169
        $response = $this->post('/orders/'.$id.'/escalate', $params);
170
171
        return $this->getResult($response, new OrderDataTransformer());
172
    }
173
174
    /**
175
     * @param int   $userId
176
     * @param int   $orderId
177
     * @param array $params
178
     * @return Order
179
     */
180 View Code Duplication
    public function bind(int $userId, int $orderId, array $params) : Order
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
181
    {
182
        $resolver = new OptionsResolver();
183
        $resolver
184
            ->setRequired([
185
                'supplier_payout_card_id',
186
            ])
187
            ->setAllowedTypes('supplier_payout_card_id', 'int');
188
189
        $params = $resolver->resolve($params);
190
191
        $response = $this->post('/users/'.$userId.'/orders/'.$orderId, $params);
192
193
        return $this->getResult($response, new OrderDataTransformer());
194
    }
195
}
196