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