Issues (655)

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

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
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\AdminBundle\Command;
15
16
use Sonata\AdminBundle\Admin\Pool;
17
use Symfony\Component\Console\Command\Command;
18
use Symfony\Component\Console\Input\InputArgument;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Console\Output\OutputInterface;
21
use Symfony\Component\Validator\Mapping\ClassMetadata;
22
use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface;
23
24
/**
25
 * @author Thomas Rabaix <[email protected]>
26
 */
27
final class ExplainAdminCommand extends Command
28
{
29
    protected static $defaultName = 'sonata:admin:explain';
30
31
    /**
32
     * @var Pool
33
     */
34
    private $pool;
35
36
    /**
37
     * @var MetadataFactoryInterface
38
     */
39
    private $validator;
40
41
    public function __construct(Pool $pool, MetadataFactoryInterface $validator)
42
    {
43
        $this->pool = $pool;
44
        $this->validator = $validator;
45
46
        parent::__construct();
47
    }
48
49
    public function configure(): void
50
    {
51
        $this->setDescription('Explain an admin service');
52
53
        $this->addArgument('admin', InputArgument::REQUIRED, 'The admin service id');
54
    }
55
56
    public function execute(InputInterface $input, OutputInterface $output): int
57
    {
58
        $admin = $this->pool->getInstance($input->getArgument('admin'));
0 ignored issues
show
It seems like $input->getArgument('admin') targeting Symfony\Component\Consol...nterface::getArgument() can also be of type array<integer,string> or null; however, Sonata\AdminBundle\Admin\Pool::getInstance() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
59
60
        $output->writeln('<comment>AdminBundle Information</comment>');
61
        $output->writeln(sprintf('<info>% -20s</info> : %s', 'id', $admin->getCode()));
62
        $output->writeln(sprintf('<info>% -20s</info> : %s', 'Admin', \get_class($admin)));
63
        $output->writeln(sprintf('<info>% -20s</info> : %s', 'Model', $admin->getClass()));
64
        $output->writeln(sprintf('<info>% -20s</info> : %s', 'Controller', $admin->getBaseControllerName()));
65
        $output->writeln(sprintf('<info>% -20s</info> : %s', 'Model Manager', \get_class($admin->getModelManager())));
66
        $output->writeln(sprintf('<info>% -20s</info> : %s', 'Form Builder', \get_class($admin->getFormBuilder())));
67
        $output->writeln(sprintf('<info>% -20s</info> : %s', 'Datagrid Builder', \get_class($admin->getDatagridBuilder())));
68
        $output->writeln(sprintf('<info>% -20s</info> : %s', 'List Builder', \get_class($admin->getListBuilder())));
69
70
        if ($admin->isChild()) {
71
            $output->writeln(sprintf('<info>% -15s</info> : %s', 'Parent', $admin->getParent()->getCode()));
72
        }
73
74
        $output->writeln('');
75
        $output->writeln('<info>Routes</info>');
76
        foreach ($admin->getRoutes()->getElements() as $route) {
77
            $output->writeln(sprintf('  - % -25s %s', $route->getDefault('_sonata_name'), $route->getPath()));
78
        }
79
80
        $output->writeln('');
81
        $output->writeln('<info>Datagrid Columns</info>');
82
        foreach ($admin->getListFieldDescriptions() as $name => $fieldDescription) {
83
            $output->writeln(sprintf(
84
                '  - % -25s  % -15s % -15s',
85
                $name,
86
                $fieldDescription->getType(),
87
                $fieldDescription->getTemplate()
88
            ));
89
        }
90
91
        $output->writeln('');
92
        $output->writeln('<info>Datagrid Filters</info>');
93
        foreach ($admin->getFilterFieldDescriptions() as $name => $fieldDescription) {
94
            $output->writeln(sprintf(
95
                '  - % -25s  % -15s % -15s',
96
                $name,
97
                $fieldDescription->getType(),
98
                $fieldDescription->getTemplate()
99
            ));
100
        }
101
102
        $output->writeln('');
103
        $output->writeln('<info>Form theme(s)</info>');
104
        foreach ($admin->getFormTheme() as $template) {
105
            $output->writeln(sprintf('  - %s', $template));
106
        }
107
108
        $output->writeln('');
109
        $output->writeln('<info>Form Fields</info>');
110
        foreach ($admin->getFormFieldDescriptions() as $name => $fieldDescription) {
111
            $output->writeln(sprintf(
112
                '  - % -25s  % -15s % -15s',
113
                $name,
114
                $fieldDescription->getType(),
115
                $fieldDescription->getTemplate()
116
            ));
117
        }
118
119
        $metadata = $this->validator->getMetadataFor($admin->getClass());
120
        if (!$metadata instanceof ClassMetadata) {
121
            throw new \UnexpectedValueException(
122
                sprintf(
123
                    'Cannot read metadata properties of %s because its metadata is an instance of %s instead of %s',
124
                    $admin->getClass(),
125
                    \get_class($metadata),
126
                    ClassMetadata::class
127
                )
128
            );
129
        }
130
131
        $output->writeln('');
132
        $output->writeln('<comment>Validation Framework</comment> - http://symfony.com/doc/3.0/book/validation.html');
133
        $output->writeln('<info>Properties constraints</info>');
134
135
        if (0 === \count($metadata->properties)) {
136
            $output->writeln('    <error>no property constraints defined !!</error>');
137
        } else {
138
            foreach ($metadata->properties as $name => $property) {
139
                $output->writeln(sprintf('  - %s', $name));
140
141
                foreach ($property->getConstraints() as $constraint) {
142
                    $output->writeln(sprintf(
143
                        '    % -70s %s',
144
                        \get_class($constraint),
145
                        implode('|', $constraint->groups)
146
                    ));
147
                }
148
            }
149
        }
150
151
        $output->writeln('');
152
        $output->writeln('<info>Getters constraints</info>');
153
154
        if (0 === \count($metadata->getters)) {
155
            $output->writeln('    <error>no getter constraints defined !!</error>');
156
        } else {
157
            foreach ($metadata->getters as $name => $property) {
158
                $output->writeln(sprintf('  - %s', $name));
159
160
                foreach ($property->getConstraints() as $constraint) {
161
                    $output->writeln(sprintf(
162
                        '    % -70s %s',
163
                        \get_class($constraint),
164
                        implode('|', $constraint->groups)
165
                    ));
166
                }
167
            }
168
        }
169
170
        $output->writeln('');
171
        $output->writeln('<info>done!</info>');
172
173
        return 0;
174
    }
175
}
176