Issues (71)

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/Service/CasesService.php (8 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 OmnideskBundle\Service;
3
4
use GuzzleHttp\Exception\ClientException;
5
use OmnideskBundle\Exception\CasesNotFoundException;
6
use OmnideskBundle\Exception\IncorrectUserEmailException;
7
use OmnideskBundle\Exception\StaffNotActiveException;
8
use OmnideskBundle\Factory\Cases\CasesConfigurationFactory;
9
use OmnideskBundle\Factory\Cases\CasesDataTransformerFactory;
10
use OmnideskBundle\Request\Cases\AddCasesRequest;
11
use OmnideskBundle\Request\Cases\EditCasesRequest;
12
use OmnideskBundle\Request\Cases\ListCasesRequest;
13
use OmnideskBundle\Request\Cases\ViewCasesRequest;
14
use OmnideskBundle\Response\Cases\CasesResponse;
15
use OmnideskBundle\Response\Cases\GetCasesResponse;
16
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
17
18
/**
19
 * Class CasesService
20
 * @package OmnideskBundle\Service
21
 */
22
class CasesService extends AbstractService
23
{
24
    /**
25
     * @var RequestService
26
     */
27
    protected $requestService;
28
29
    /**
30
     * @var CasesDataTransformerFactory
31
     */
32
    protected $transformerFactory;
33
34
    /**
35
     * @var CasesConfigurationFactory
36
     */
37
    protected $configurationFactory;
38
39
    /**
40
     * CasesService constructor.
41
     * @param RequestService              $requestService
42
     * @param CasesDataTransformerFactory $transformerFactory
43
     * @param CasesConfigurationFactory   $configurationFactory
44
     */
45
    public function __construct(
46
        RequestService $requestService,
47
        CasesDataTransformerFactory $transformerFactory,
48
        CasesConfigurationFactory $configurationFactory
49
    ) {
50
        $this->requestService = $requestService;
51
        $this->transformerFactory = $transformerFactory;
52
        $this->configurationFactory = $configurationFactory;
53
    }
54
55
    /**
56
     * @param AddCasesRequest $request
57
     * @return CasesResponse
58
     * @throws IncorrectUserEmailException
59
     */
60 View Code Duplication
    public function add(AddCasesRequest $request)
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...
61
    {
62
        $transformer = $this->transformerFactory->get(CasesDataTransformerFactory::REQUEST_ADD);
63
        $configuration = $this->configurationFactory->get(CasesConfigurationFactory::CONFIGURATION_ADD);
64
65
        try {
66
            $params = $this->checkRequest($request, $transformer, $configuration);
67
        } catch (InvalidConfigurationException $exception) {
68
            throw new InvalidConfigurationException($exception->getMessage());
69
        }
70
71
        $result = $this->requestService->postMultipart('cases', 'case', $params);
72
73
        return $this->transformerFactory->get(CasesDataTransformerFactory::RESPONSE_VIEW)->transform($result);
74
    }
75
76
    /**
77
     * @param EditCasesRequest $request
78
     * @return CasesResponse
79
     */
80 View Code Duplication
    public function edit(EditCasesRequest $request)
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...
81
    {
82
        $transformer = $this->transformerFactory->get(CasesDataTransformerFactory::REQUEST_EDIT);
83
        $configuration = $this->configurationFactory->get(CasesConfigurationFactory::CONFIGURATION_EDIT);
84
85
        try {
86
            $params = $this->checkRequest($request, $transformer, $configuration);
87
        } catch (InvalidConfigurationException $exception) {
88
            throw new InvalidConfigurationException($exception->getMessage());
89
        }
90
91
        try {
92
            $result = $this->requestService->put("cases/{$params['case_id']}", ['case' => $params]);
93
        } catch (ClientException $exception) {
94
            $contents = json_decode($exception->getResponse()->getBody(), JSON_UNESCAPED_UNICODE);
95
96
            if ($contents['error'] === CasesResponse::ERROR_STAFF_HAS_NOT_ACCESS) {
97
                throw new StaffNotActiveException(CasesResponse::ERROR_STAFF_HAS_NOT_ACCESS);
98
            }
99
100
            throw $exception;
101
        }
102
103
        return $this->transformerFactory->get(CasesDataTransformerFactory::RESPONSE_VIEW)->transform($result);
104
    }
105
106
    /**
107
     * @param ListCasesRequest $request
108
     * @return GetCasesResponse
109
     */
110 View Code Duplication
    public function lists(ListCasesRequest $request)
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...
111
    {
112
        $transformer = $this->transformerFactory->get(CasesDataTransformerFactory::REQUEST_LIST);
113
        $configuration = $this->configurationFactory->get(CasesConfigurationFactory::CONFIGURATION_LIST);
114
115
        try {
116
            $params = $this->checkRequest($request, $transformer, $configuration);
117
        } catch (InvalidConfigurationException $exception) {
118
            throw new InvalidConfigurationException($exception->getMessage());
119
        }
120
121
        $result = $this->requestService->get('cases', $params);
122
123
        return $this->transformerFactory->get(CasesDataTransformerFactory::RESPONSE_LIST)->transform($result);
124
    }
125
126
    /**
127
     * @param ViewCasesRequest $request
128
     * @return CasesResponse
129
     */
130 View Code Duplication
    public function view(ViewCasesRequest $request)
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...
131
    {
132
        $transformer = $this->transformerFactory->get(CasesDataTransformerFactory::REQUEST_VIEW);
133
        $configuration = $this->configurationFactory->get(CasesConfigurationFactory::CONFIGURATION_VIEW);
134
135
        try {
136
            $params = $this->checkRequest($request, $transformer, $configuration);
137
        } catch (InvalidConfigurationException $exception) {
138
            throw new InvalidConfigurationException($exception->getMessage());
139
        }
140
141
        $result = $this->requestService->get("cases/{$params['case_id']}");
142
143
        return $this->transformerFactory->get(CasesDataTransformerFactory::RESPONSE_VIEW)->transform($result);
144
    }
145
146
    /**
147
     * @param ViewCasesRequest $request
148
     * @return CasesResponse
149
     * @throws CasesNotFoundException
150
     */
151 View Code Duplication
    public function trash(ViewCasesRequest $request)
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...
152
    {
153
        $transformer = $this->transformerFactory->get(CasesDataTransformerFactory::REQUEST_VIEW);
154
        $configuration = $this->configurationFactory->get(CasesConfigurationFactory::CONFIGURATION_VIEW);
155
156
        try {
157
            $params = $this->checkRequest($request, $transformer, $configuration);
158
        } catch (InvalidConfigurationException $exception) {
159
            throw new InvalidConfigurationException($exception->getMessage());
160
        }
161
162
        $result = $this->requestService->put("cases/{$params['case_id']}/trash");
163
164
        return $this->transformerFactory->get(CasesDataTransformerFactory::RESPONSE_VIEW)->transform($result);
165
    }
166
167
    /**
168
     * @param ViewCasesRequest $request
169
     * @return CasesResponse
170
     * @throws CasesNotFoundException
171
     */
172 View Code Duplication
    public function spam(ViewCasesRequest $request)
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...
173
    {
174
        $transformer = $this->transformerFactory->get(CasesDataTransformerFactory::REQUEST_VIEW);
175
        $configuration = $this->configurationFactory->get(CasesConfigurationFactory::CONFIGURATION_VIEW);
176
177
        try {
178
            $params = $this->checkRequest($request, $transformer, $configuration);
179
        } catch (InvalidConfigurationException $exception) {
180
            throw new InvalidConfigurationException($exception->getMessage());
181
        }
182
183
        $result = $this->requestService->put("cases/{$params['case_id']}/spam");
184
185
        return $this->transformerFactory->get(CasesDataTransformerFactory::RESPONSE_VIEW)->transform($result);
186
    }
187
188
    /**
189
     * @param ViewCasesRequest $request
190
     * @return CasesResponse
191
     * @throws CasesNotFoundException
192
     */
193 View Code Duplication
    public function restore(ViewCasesRequest $request)
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...
194
    {
195
        $transformer = $this->transformerFactory->get(CasesDataTransformerFactory::REQUEST_VIEW);
196
        $configuration = $this->configurationFactory->get(CasesConfigurationFactory::CONFIGURATION_VIEW);
197
198
        try {
199
            $params = $this->checkRequest($request, $transformer, $configuration);
200
        } catch (InvalidConfigurationException $exception) {
201
            throw new InvalidConfigurationException($exception->getMessage());
202
        }
203
204
        $result = $this->requestService->put("cases/{$params['case_id']}/restore");
205
206
        return $this->transformerFactory->get(CasesDataTransformerFactory::RESPONSE_VIEW)->transform($result);
207
    }
208
209
    /**
210
     * @param ViewCasesRequest $request
211
     * @throws CasesNotFoundException
212
     */
213 View Code Duplication
    public function delete(ViewCasesRequest $request)
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...
214
    {
215
        $transformer = $this->transformerFactory->get(CasesDataTransformerFactory::REQUEST_VIEW);
216
        $configuration = $this->configurationFactory->get(CasesConfigurationFactory::CONFIGURATION_VIEW);
217
218
        try {
219
            $params = $this->checkRequest($request, $transformer, $configuration);
220
        } catch (InvalidConfigurationException $exception) {
221
            throw new InvalidConfigurationException($exception->getMessage());
222
        }
223
224
        try {
225
            $this->requestService->delete("cases/{$params['case_id']}");
226
        } catch (ClientException $exception) {
227
            throw $exception;
228
        }
229
    }
230
}
231