Issues (30)

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/ItemCRUDController.php (4 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 Alpixel\Bundle\MenuBundle\Controller;
4
5
use Alpixel\Bundle\MenuBundle\Entity\Item;
6
use Alpixel\Bundle\MenuBundle\Entity\Menu;
7
use Pix\SortableBehaviorBundle\Controller\SortableAdminController as Controller;
8
use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
9
use Sonata\AdminBundle\Exception\ModelManagerException;
10
use Symfony\Component\HttpFoundation\RedirectResponse;
11
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
12
13
/**
14
 * @author Alexis BUSSIERES <[email protected]>
15
 */
16
class ItemCRUDController extends Controller
17
{
18
    private function deleteItems($items)
19
    {
20
        $menu = $this->get('alpixel_menu.menu.menu');
21
        $menu->deleteItems($items);
22
    }
23
24
    public function batchActionDelete(ProxyQueryInterface $query)
25
    {
26
        $this->admin->checkAccess('batchDelete');
27
28
        try {
29
            $this->deleteItems($query->execute());
30
            $this->addFlash('sonata_flash_success', 'flash_batch_delete_success');
31
        } catch (ModelManagerException $e) {
0 ignored issues
show
The class Sonata\AdminBundle\Exception\ModelManagerException 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...
32
            $this->handleModelManagerException($e);
33
            $this->addFlash('sonata_flash_error', 'flash_batch_delete_error');
34
        }
35
36
        return new RedirectResponse($this->admin->generateUrl(
37
            'list',
38
            array('filter' => $this->admin->getFilterParameters())
39
        ));
40
    }
41
42
    public function deleteAction($id)
43
    {
44
        $request = $this->getRequest();
45
        $object = $this->admin->getObject($id);
46
47
        if (!$object) {
48
            throw $this->createNotFoundException(sprintf('unable to find the object with id : %s', $id));
49
        }
50
51
        $this->admin->checkAccess('delete', $object);
52
53
        $preResponse = $this->preDelete($request, $object);
54
        if ($preResponse !== null) {
55
            return $preResponse;
56
        }
57
58
        if ($this->getRestMethod() == 'DELETE') {
59
            // check the csrf token
60
            $this->validateCsrfToken('sonata.delete');
61
62
            $objectName = $this->admin->toString($object);
63
64
            try {
65
                $this->deleteItems([$object]);
66
67
                if ($this->isXmlHttpRequest()) {
68
                    return $this->renderJson(array('result' => 'ok'), 200, array());
69
                }
70
71
                $this->addFlash(
72
                    'sonata_flash_success',
73
                    $this->admin->trans(
74
                        'flash_delete_success',
75
                        array('%name%' => $this->escapeHtml($objectName)),
76
                        'SonataAdminBundle'
77
                    )
78
                );
79
            } catch (ModelManagerException $e) {
0 ignored issues
show
The class Sonata\AdminBundle\Exception\ModelManagerException 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...
80
                $this->handleModelManagerException($e);
81
82
                if ($this->isXmlHttpRequest()) {
83
                    return $this->renderJson(array('result' => 'error'), 200, array());
84
                }
85
86
                $this->addFlash(
87
                    'sonata_flash_error',
88
                    $this->admin->trans(
89
                        'flash_delete_error',
90
                        array('%name%' => $this->escapeHtml($objectName)),
91
                        'SonataAdminBundle'
92
                    )
93
                );
94
            }
95
96
            return $this->redirectTo($object);
97
        }
98
99
        return $this->render($this->admin->getTemplate('delete'), array(
100
            'object' => $object,
101
            'action' => 'delete',
102
            'csrf_token' => $this->getCsrfToken('sonata.delete'),
103
        ), null);
104
    }
105
106 View Code Duplication
    protected function redirectTo($object)
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...
107
    {
108
        $request = $this->getRequest();
109
110
        $url = false;
111
        $params = [];
112
113
        if ($object instanceof Item) {
114
            if ($object->getParent() !== null) {
115
                $itemId = $object->getParent()->getId();
116
                $params['list']['item'] = $itemId;
117
                $params['create']['create-item'] = $itemId;
118
            }
119
            $menuId = $object->getMenu()->getId();
120
            $params['list']['menu'] = $menuId;
121
            $params['create']['create-menu'] = $menuId;
122
        } elseif ($object instanceof Menu) {
123
            $menuId = $object->getId();
124
            $params['list']['menu'] = $menuId;
125
            $params['create']['create-menu'] = $menuId;
126
        }
127
128
        if (null !== $request->get('btn_update_and_list')) {
129
            $url = $this->admin->generateUrl('list', $params['list']);
130
        } elseif (null !== $request->get('btn_create_and_list')) {
131
            $url = $this->admin->generateUrl('list', $params['list']);
132
        }
133
134
        if (null !== $request->get('btn_create_and_create')) {
135
            if ($this->admin->hasActiveSubClass()) {
136
                $params['create']['subclass'] = $request->get('subclass');
137
            }
138
            $url = $this->admin->generateUrl('create', $params['create']);
139
        }
140
141
        if ($this->getRestMethod() === 'DELETE') {
142
            if ($object instanceof Item) {
143
                $url = $this->admin->generateUrl('list', $params['list']);
144
            } else {
145
                $router = $this->get('router');
146
                $url = $router->generate('admin_alpixel_menu_menu_list');
147
            }
148
        }
149
150
        if (!$url) {
151
            foreach (['edit', 'show'] as $route) {
152
                if ($this->admin->hasRoute($route) && $this->admin->isGranted(strtoupper($route), $object)) {
153
                    $url = $this->admin->generateObjectUrl($route, $object);
154
                    break;
155
                }
156
            }
157
        }
158
159
        if (!$url) {
160
            $router = $this->get('router');
161
            $url = $router->generate('admin_alpixel_menu_menu_list');
162
        }
163
164
        return new RedirectResponse($url);
165
    }
166
167 View Code Duplication
    public function itemAction()
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...
168
    {
169
        $object = $this->admin->getSubject();
170
        $router = $this->container->get('router');
171
        $parameters = [];
172
173
        if ($object instanceof Menu) {
174
            $parameters['menu'] = $object->getId();
175
        } elseif ($object instanceof Item) {
176
            $parameters['menu'] = $object->getMenu()->getId();
177
            $parameters['item'] = $object->getId();
178
        }
179
180
        $url = $router->generate('admin_alpixel_menu_item_list', $parameters, UrlGeneratorInterface::ABSOLUTE_PATH);
181
182
        return new RedirectResponse($url);
183
    }
184
}
185