Issues (36)

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.

Controller/SchedulesController.php (2 issues)

Labels
Severity

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
/*      This file is part of the Thelia package.                                     */
4
/*                                                                                   */
5
/*      Copyright (c) OpenStudio                                                     */
6
/*      email : [email protected]                                                       */
7
/*      web : http://www.thelia.net                                                  */
8
/*                                                                                   */
9
/*      For the full copyright and license information, please view the LICENSE.txt  */
10
/*      file that was distributed with this source code.                             */
11
/*************************************************************************************/
12
/*************************************************************************************/
13
14
namespace Dealer\Controller;
15
16
use Dealer\Controller\Base\BaseController;
17
use Dealer\Dealer;
18
use Dealer\Model\DealerShedules;
19
use Propel\Runtime\Propel;
20
use Symfony\Component\HttpFoundation\RedirectResponse;
21
use Thelia\Core\Security\AccessManager;
22
use Thelia\Core\Security\Resource\AdminResources;
23
use Thelia\Form\Exception\FormValidationException;
24
use Thelia\Tools\URL;
25
26
/**
27
 * Class SchedulesController
28
 * @package Dealer\Controller
29
 */
30
class SchedulesController extends BaseController
31
{
32
    const CONTROLLER_ENTITY_NAME = "dealer-schedules";
33
    const CONTROLLER_CHECK_RESOURCE = Dealer::RESOURCES_SCHEDULES;
34
35
    /**
36
     * Use to get render of list
37
     * @return mixed
38
     */
39
    protected function getListRenderTemplate()
40
    {
41
        $id = $this->getRequest()->request->get("dealer_id");
42
43
        return new RedirectResponse(URL::getInstance()->absoluteUrl("/admin/module/Dealer/dealer/edit",
44
            ["dealer_id" => $id, ]));
45
    }
46
47
    /**
48
     * Must return a RedirectResponse instance
49
     * @return \Symfony\Component\HttpFoundation\RedirectResponse
50
     */
51
    protected function redirectToListTemplate()
52
    {
53
        $id = $this->getRequest()->request->get("dealer_id");
54
55
        return new RedirectResponse(URL::getInstance()->absoluteUrl("/admin/module/Dealer/dealer/edit",
56
            ["dealer_id" => $id, ]));
57
    }
58
59
    /**
60
     * Use to get Edit render
61
     * @return mixed
62
     */
63
    protected function getEditRenderTemplate()
64
    {
65
        return $this->render("dealer-edit");
66
    }
67
68
    /**
69
     * Use to get Create render
70
     * @return mixed
71
     */
72
    protected function getCreateRenderTemplate()
73
    {
74
        return $this->render("dealer-edit");
75
    }
76
77
    /**
78
     * @return mixed
79
     */
80
    protected function getObjectId($object)
81
    {
82
        /** @var DealerShedules $object */
83
        $object->getId();
84
    }
85
86
    /**
87
     * Load an existing object from the database
88
     */
89
    protected function getExistingObject()
90
    {
91
        // TODO: Implement getExistingObject() method.
92
    }
93
94
    /**
95
     * Hydrate the update form for this object, before passing it to the update template
96
     *
97
     * @param mixed $object
98
     */
99
    protected function hydrateObjectForm($object)
100
    {
101
        // TODO: Implement hydrateObjectForm() method.
102
    }
103
104
    /**
105
     * Method to get current controller associated service
106
     * @return object
107
     */
108
    protected function getService()
109
    {
110
        if (!$this->service) {
111
            $this->service = $this->getContainer()->get("dealer_schedules_service");
112
        }
113
114
        return $this->service;
115
    }
116
117
    /**
118
     * Create an object
119
     * @return mixed|\Symfony\Component\HttpFoundation\Response
120
     */
121
    public function createAction()
122
    {
123
        // Check current user authorization
124
        if (null !== $response = $this->checkAuth(self::CONTROLLER_CHECK_RESOURCE, Dealer::getModuleCode(),
125
                AccessManager::CREATE)
126
        ) {
127
            return $response;
128
        }
129
130
        // Create the Creation Form
131
        $creationForm = $this->getCreationForm($this->getRequest());
132
133
        $con = Propel::getConnection();
134
        $con->beginTransaction();
135
136
        try {
137
            // Check the form against constraints violations
138
            $form = $this->validateForm($creationForm, "POST");
139
            // Get the form field values
140
            $data = $form->getData();
141
142
            if (empty($data["day"])) {
143
                $dataAM = $this->formatData($data);
144
                $dataPM = $this->formatData($data, 'PM');
145
146
                if ($this->hasNullDate($dataAM) && $this->hasNullDate($dataPM)) {
147
                    $this->getService()->createFromArray($dataAM, $this->getCurrentEditionLocale());
148
                } else {
149
                    if (!$this->hasNullDate($dataAM)) {
150
                        $this->getService()->createFromArray($dataAM, $this->getCurrentEditionLocale());
151
                    }
152
                    if (!$this->hasNullDate($dataPM)) {
153
                        $this->getService()->createFromArray($dataPM, $this->getCurrentEditionLocale());
154
                    }
155
                }
156
            } else {
157
                foreach ($data["day"] as $day) {
158
                    $currentData = $data;
159
                    $currentData["day"] = $day;
160
                    $dataAM = $this->formatData($currentData);
161
                    $dataPM = $this->formatData($currentData, 'PM');
162
163
                    if ($this->hasNullDate($dataAM) && $this->hasNullDate($dataPM)) {
164
                        $this->getService()->createFromArray($dataAM, $this->getCurrentEditionLocale());
165
                    } else {
166
                        if (!$this->hasNullDate($dataAM)) {
167
                            $this->getService()->createFromArray($dataAM, $this->getCurrentEditionLocale());
168
                        }
169
                        if (!$this->hasNullDate($dataPM)) {
170
                            $this->getService()->createFromArray($dataPM, $this->getCurrentEditionLocale());
171
                        }
172
                    }
173
                }
174
            }
175
176
177
            // Substitute _ID_ in the URL with the ID of the created object
178
            $successUrl = $creationForm->getSuccessUrl();
179
180
            $con->commit();
181
182
            // Redirect to the success URL
183
            return $this->generateRedirect($successUrl);
184
        } catch (FormValidationException $ex) {
0 ignored issues
show
The class Thelia\Form\Exception\FormValidationException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
185
            $con->rollBack();
186
            // Form cannot be validated
187
            $error_msg = $this->createStandardFormValidationErrorMessage($ex);
188
        } catch (\Exception $ex) {
189
            $con->rollBack();
190
            // Any other error
191
            $error_msg = $ex->getMessage();
192
        }
193
        if (false !== $error_msg) {
194
            $this->setupFormErrorContext(
195
                $this->getTranslator()->trans("%obj creation", ['%obj' => static::CONTROLLER_ENTITY_NAME]),
196
                $error_msg,
197
                $creationForm,
198
                $ex
199
            );
200
201
            // At this point, the form has error, and should be redisplayed.
202
            return $this->generateErrorRedirect($creationForm);
203
        }
204
    }
205
206
    protected function formatData($data, $type = "AM")
207
    {
208
        $retour = $data;
209
        if (isset($data["begin" . $type]) && $data["begin" . $type] != "") {
210
            $retour["begin"] = $data["begin" . $type];
211
        } else {
212
            $retour["begin"] = null;
213
        }
214
        if (isset($data["end" . $type]) && $data["end" . $type] != "") {
215
            $retour["end"] = $data["end" . $type];
216
        } else {
217
            $retour["end"] = null;
218
        }
219
220
        return $retour;
221
    }
222
223
    protected function hasNullDate($data)
224
    {
225
        return !($data["begin"] && $data["end"]);
226
    }
227
228
    public function cloneAction()
229
    {
230
        // Check current user authorization
231
        if (null !== $response = $this->checkAuth(self::CONTROLLER_CHECK_RESOURCE, Dealer::getModuleCode(),
232
                AccessManager::CREATE)
233
        ) {
234
            return $response;
235
        }
236
237
        // Create the Creation Form
238
        $cloneForm = $this->getCloneForm($this->getRequest());
239
240
        $con = Propel::getConnection();
241
        $con->beginTransaction();
242
243
        try {
244
            // Check the form against constraints violations
245
            $form = $this->validateForm($cloneForm, "POST");
246
            // Get the form field values
247
            $data = $form->getData();
248
249
            $this->getService()->cloneFromArray($data);
250
251
252
            // Substitute _ID_ in the URL with the ID of the created object
253
            $successUrl = $cloneForm->getSuccessUrl();
254
255
            $con->commit();
256
257
            // Redirect to the success URL
258
            return $this->generateRedirect($successUrl);
259
        } catch (FormValidationException $ex) {
0 ignored issues
show
The class Thelia\Form\Exception\FormValidationException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
260
            $con->rollBack();
261
            // Form cannot be validated
262
            $error_msg = $this->createStandardFormValidationErrorMessage($ex);
263
        } catch (\Exception $ex) {
264
            $con->rollBack();
265
            // Any other error
266
            $error_msg = $ex->getMessage();
267
        }
268
        if (false !== $error_msg) {
269
            $this->setupFormErrorContext(
270
                $this->getTranslator()->trans("%obj creation", ['%obj' => static::CONTROLLER_ENTITY_NAME]),
271
                $error_msg,
272
                $cloneForm,
273
                $ex
274
            );
275
276
            // At this point, the form has error, and should be redisplayed.
277
            return $this->getListRenderTemplate();
278
        }
279
    }
280
281
    /**
282
     * Method to get Base Clone Form
283
     * @return \Thelia\Form\BaseForm
284
     */
285
    protected function getCloneForm()
286
    {
287
        return $this->createForm(static::CONTROLLER_ENTITY_NAME . ".clone");
288
    }
289
}
290