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/DealerController.php (1 issue)

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 as DealerModule;
18
use Dealer\Model\Dealer;
19
use Dealer\Model\DealerQuery;
20
use Propel\Runtime\Propel;
21
use Symfony\Component\HttpFoundation\RedirectResponse;
22
use Thelia\Core\HttpFoundation\JsonResponse;
23
use Thelia\Core\Security\AccessManager;
24
use Thelia\Core\Security\Resource\AdminResources;
25
use Thelia\Tools\URL;
26
27
/**
28
 * Class DealerController
29
 * @package Dealer\Controller
30
 */
31
class DealerController extends BaseController
32
{
33
    /**
34
     * Load an existing object from the database
35
     */
36
    protected function getExistingObject()
37
    {
38
        return DealerQuery::create()->findPk($this->getRequest()->query->get("dealer_id"));
39
    }
40
41
    /**
42
     * Hydrate the update form for this object, before passing it to the update template
43
     *
44
     * @param mixed $object
45
     */
46
    protected function hydrateObjectForm($object)
47
    {
48
        $data = array(
49
            "id" => $object->getId(),
50
            "title" => $object->getTitle(),
51
            "address1" => $object->getAddress1(),
52
            "address2" => $object->getAddress2(),
53
            "address3" => $object->getAddress3(),
54
            "zipcode" => $object->getZipcode(),
55
            "city" => $object->getCity(),
56
            "country_id" => $object->getCountryId(),
57
            "description" => $object->getDescription(),
58
            "big_description" => $object->getBigDescription(),
59
            "hard_open_hour" => $object->getHardOpenHour(),
60
            "latitude" => $object->getLatitude(),
61
            "longitude" => $object->getLongitude(),
62
        );
63
64
        return $this->getUpdateForm($data);
65
    }
66
67
    const CONTROLLER_ENTITY_NAME = "dealer";
68
69
    /**
70
     * Use to get render of list
71
     * @return mixed
72
     */
73
    protected function getListRenderTemplate()
74
    {
75
        return $this->render("dealers");
76
    }
77
78
    /**
79
     * Use to get Edit render
80
     * @return mixed
81
     */
82
    protected function getEditRenderTemplate()
83
    {
84
        return $this->render("dealer-edit");
85
    }
86
87
    /**
88
     * Use to get Create render
89
     * @return mixed
90
     */
91
    protected function getCreateRenderTemplate()
92
    {
93
        // TODO: Implement getCreateRenderTemplate() method.
94
    }
95
96
    /**
97
     * @return mixed
98
     */
99
    protected function getObjectId($object)
100
    {
101
        /** @var Dealer $object */
102
        return $object->getId();
103
    }
104
105
    protected function redirectToListTemplate()
106
    {
107
        return new RedirectResponse(URL::getInstance()->absoluteUrl("/admin/module/Dealer/dealer"));
108
    }
109
110
    protected function redirectToEditionTemplate()
111
    {
112
        $id = $this->getRequest()->query->get("dealer_id");
113
114
        return new RedirectResponse(URL::getInstance()->absoluteUrl("/admin/module/Dealer/dealer/edit",
115
            ["dealer_id" => $id, ]));
116
    }
117
118
    public function toggleVisibleAction($id)
119
    {
120
        // Check current user authorization
121
        if (null !== $response = $this->checkAuth(AdminResources::MODULE, DealerModule::getModuleCode(),
122
                AccessManager::UPDATE)
123
        ) {
124
            return $response;
125
        }
126
127
        // Error (Default: false)
128
        $error_msg = false;
0 ignored issues
show
$error_msg 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...
129
130
        $retour = [];
131
        $code = 200;
132
133
134
        $con = Propel::getConnection();
135
        $con->beginTransaction();
136
137
        try {
138
            $updatedObject = $this->getService()->toggleVisibilityFromId($id);
139
140
            // Check if object exist
141
            if (!$updatedObject) {
142
                throw new \LogicException(
143
                    $this->getTranslator()->trans("No %obj was updated.", ['%obj' => static::CONTROLLER_ENTITY_NAME])
144
                );
145
            }
146
147
            $con->commit();
148
149
            $retour["message"] = "Visibility was updated";
150
        } catch (\Exception $ex) {
151
            $con->rollBack();
152
            // Any other error
153
            $retour["message"] = "Visibility can be updated";
154
            $code = 500;
155
            $retour["error"] = $ex->getMessage();
156
        }
157
158
        return JsonResponse::create($retour, $code);
159
    }
160
}
161