Issues (159)

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.

src/Admin/Admin.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
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\DoctrinePHPCRAdminBundle\Admin;
15
16
use PHPCR\Util\PathHelper;
17
use PHPCR\Util\UUIDHelper;
18
use Sonata\AdminBundle\Admin\AbstractAdmin;
19
use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
20
use Sonata\AdminBundle\Route\RouteCollection;
21
22
/**
23
 * Extend the Admin class to incorporate phpcr changes.
24
 *
25
 * Especially make sure that there are no duplicated slashes in the generated urls
26
 *
27
 * @author Uwe Jäger <[email protected]>
28
 */
29
class Admin extends AbstractAdmin
30
{
31
    /**
32
     * Path to the root node in the repository under which documents of this
33
     * admin should be created.
34
     *
35
     * @var string
36
     */
37
    private $rootPath;
38
39
    /**
40
     * Set the root path in the repository. To be able to create new items,
41
     * this path must already exist.
42
     *
43
     * @param string $rootPath
44
     */
45
    public function setRootPath($rootPath): void
46
    {
47
        $this->rootPath = $rootPath;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getRootPath()
54
    {
55
        return $this->rootPath;
56
    }
57
58
    /**
59
     * @param string $context
60
     *
61
     * @return ProxyQueryInterface
62
     */
63
    public function createQuery($context = 'list')
64
    {
65
        $query = $this->getModelManager()->createQuery($this->getClass());
66
        $query->setRootPath($this->getRootPath());
67
68
        foreach ($this->extensions as $extension) {
69
            $extension->configureQuery($this, $query, $context);
70
        }
71
72
        return $query;
73
    }
74
75
    /**
76
     * @param object $object
77
     *
78
     * @return string
79
     */
80
    public function id($object)
81
    {
82
        return $this->getUrlsafeIdentifier($object);
83
    }
84
85
    /**
86
     * Get subject.
87
     *
88
     * Overridden to allow a broader set of valid characters in the ID, and
89
     * if the ID is not a UUID, to call absolutizePath on the ID.
90
     *
91
     * @return mixed
92
     */
93
    public function getSubject()
94
    {
95
        if (null === $this->subject && $this->request) {
96
            $id = $this->request->get($this->getIdParameter());
97
            if (null === $id || !preg_match('#^[0-9A-Za-z/\-_]+$#', $id)) {
98
                $this->subject = false;
99
            } else {
100
                if (!UUIDHelper::isUUID($id)) {
101
                    $id = PathHelper::absolutizePath($id, '/');
102
                }
103
                $this->subject = $this->getObject($id);
104
            }
105
        }
106
107
        return $this->subject;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The expression $this->subject; of type object|null|false adds false to the return on line 107 which is incompatible with the return type declared by the interface Sonata\AdminBundle\Admin...inInterface::getSubject of type object|null. It seems like you forgot to handle an error condition.
Loading history...
108
    }
109
110
    /**
111
     * {@inheritdoc}
112
     */
113
    public function toString($object)
114
    {
115
        if (!\is_object($object)) {
116
            return parent::toString($object);
117
        }
118
119
        if (method_exists($object, '__toString') && null !== $object->__toString()) {
120
            $string = (string) $object;
121
122
            return '' !== $string ? $string : $this->trans('link_add', [], 'SonataAdminBundle');
123
        }
124
125
        $dm = $this->getModelManager()->getDocumentManager();
126
        if ($dm->contains($object)) {
127
            return PathHelper::getNodeName($dm->getUnitOfWork()->getDocumentId($object));
128
        }
129
130
        return parent::toString($object);
131
    }
132
133
    protected function configureRoutes(RouteCollection $collection): void
134
    {
135
        foreach (['edit', 'create', 'delete'] as $name) {
136
            if ($collection->has($name)) {
137
                $collection->get($name)->addOptions(['expose' => true]);
138
            }
139
        }
140
    }
141
}
142