Issues (71)

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

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\CMSBundle\Controller;
4
5
use Sonata\AdminBundle\Controller\CRUDController as Controller;
6
use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException;
7
use Symfony\Component\HttpFoundation\RedirectResponse;
8
use Symfony\Component\HttpFoundation\Request;
9
10
class AdminNodeController extends Controller
11
{
12
    public function forwardEditAction(Request $request)
13
    {
14
        $entityManager = $this->get('doctrine.orm.entity_manager');
15
16
        $node = $entityManager->getRepository('AlpixelCMSBundle:Node')
17
            ->find($request->get('id'));
18
19
        // Forward edit action from EN page set locale for admin to EN instead default locale
20
        $defaultLocale = $this->getParameter('default_locale');
21
        $request->setLocale($defaultLocale);
22
23
        if ($node !== null) {
24
            $instanceAdmin = $this->admin->getConfigurationPool()->getAdminByClass(get_class($node));
25
            if ($instanceAdmin !== null) {
26
                return $this->redirect($instanceAdmin->generateUrl('edit', ['id' => $request->get('id')]));
27
            }
28
        }
29
30
        $instanceAdmin = $this->admin->getConfigurationPool()->getInstance('alpixel_cms.admin.node');
31
32
        return $this->redirect($instanceAdmin->generateUrl('list'));
33
    }
34
35
    public function createTranslationAction(Request $request)
36
    {
37
        $object = $this->admin->getSubject();
38
        $locale = $request->query->get('locale');
39
40
        if ($locale === null || $object === null) {
41
            return $this->createNotFoundException();
42
        }
43
44
        $entityManager = $this->get('doctrine.orm.entity_manager');
45
        $translation = $entityManager->getRepository('AlpixelCMSBundle:Node')
46
            ->findTranslation($object, $locale);
47
48
        if ($translation !== null) {
49
            return $this->redirect($this->admin->generateUrl('edit', ['id' => $translation->getId()]));
50
        } else {
51
            $translatedContent = $this->get('alpixel_cms.helper.cms')->createTranslation($object, $locale);
52
            $entityManager->persist($translatedContent);
53
            $entityManager->flush();
54
55
            return $this->redirect($this->admin->generateUrl('edit', ['id' => $translatedContent->getId()]));
56
        }
57
    }
58
59
    public function seeAction(Request $request)
60
    {
61
        $object = $this->admin->getSubject();
62
        $contentTypes = $this->admin->getCMSTypes();
63
64
        foreach ($contentTypes as $key => $contentType) {
65
            if ($key === $object->getType()) {
66
                if (isset($contentType['controller'])) {
67
                    return $this->redirectToRoute('alpixel_cms', [
68
                        'slug'    => $object->getSlug(),
69
                        '_locale' => $object->getLocale(),
70
                    ]);
71
                } elseif ($contentType['admin'] !== null && $contentType['admin']->showCustomURL($object) !== null) {
72
                    return $this->redirect($contentType['admin']->showCustomURL($object));
73
                }
74
            }
75
        }
76
77
        $this->get('session')->getFlashBag()->add('warning', 'Impossible de trouver une adresse pour cette page');
78
79
        return $this->redirectTo($object);
80
    }
81
82
    public function listAction(Request $request = null)
83
    {
84
        if (false === $this->admin->isGranted('LIST')) {
85
            throw new AccessDeniedException("You can't access the list view");
86
        }
87
88
        $datagrid = $this->admin->getDatagrid();
89
        $formView = $datagrid->getForm()->createView();
90
91
        if (!$this->container->hasParameter('alpixel_cms.content_types')) {
92
            throw $this->createNotFoundException('alpixel_cms.content_types parameters has not been  not found, maybe you must be configured cms.yml file');
93
        }
94
95
        $cmsContentType = $this->container->getParameter('alpixel_cms.content_types');
96
        $this->get('twig')->getExtension('form')->renderer->setTheme($formView, $this->admin->getFilterTheme());
97
98
        return $this->render($this->admin->getTemplate('list'), [
99
            'action'         => 'list',
100
            'cmsContentType' => $cmsContentType,
101
            'form'           => $formView,
102
            'datagrid'       => $datagrid,
103
            'csrf_token'     => $this->getCsrfToken('sonata.batch'),
104
        ], null, $request);
105
    }
106
107
    /**
108
     * {@inheritdoc}
109
     */
110
    protected function redirectTo($object)
111
    {
112
        $request = $this->getRequest();
113
114
        $url = $backToNodeList = false;
115
        $instanceAdmin = $this->admin->getConfigurationPool()->getInstance('alpixel_cms.admin.node');
116
117 View Code Duplication
        if (null !== $request->get('btn_update_and_list') || null !== $request->get('btn_create_and_list')) {
118
            $backToNodeList = true;
119
        }
120
121 View Code Duplication
        if (null !== $request->get('btn_create_and_create')) {
122
            $params = [];
123
            if ($this->admin->hasActiveSubClass()) {
124
                $params['subclass'] = $request->get('subclass');
125
            }
126
            $url = $this->admin->generateUrl('create', $params);
127
        }
128
129 View Code Duplication
        if (null !== $request->get('btn_update_and_see_page') || null !== $request->get('btn_create_and_see_page')) {
0 ignored issues
show
This code seems to be duplicated across 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
            return $this->redirectToRoute('alpixel_cms', [
131
                'slug'    => $object->getSlug(),
132
                '_locale' => $object->getLocale(),
133
            ]);
134
        }
135
136
        if ($this->getRestMethod() === 'DELETE') {
137
            $backToNodeList = true;
138
        }
139
140 View Code Duplication
        if (!$url && !$backToNodeList) {
141
            foreach (['edit', 'show'] as $route) {
142
                if ($this->admin->hasRoute($route) && $this->admin->isGranted(strtoupper($route), $object)) {
143
                    $url = $this->admin->generateObjectUrl($route, $object);
144
                    break;
145
                }
146
            }
147
        }
148
149
        if ($backToNodeList || !$url) {
150
            $url = $instanceAdmin->generateUrl('list');
151
        }
152
153
        return new RedirectResponse($url);
154
    }
155
}
156