Issues (306)

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/Block/AuditBlockService.php (2 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
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\DoctrineORMAdminBundle\Block;
15
16
use SimpleThings\EntityAudit\AuditReader;
17
use Sonata\AdminBundle\Form\FormMapper;
18
use Sonata\BlockBundle\Block\BlockContextInterface;
19
use Sonata\BlockBundle\Block\Service\AbstractBlockService;
20
use Sonata\BlockBundle\Model\BlockInterface;
21
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
22
use Symfony\Component\HttpFoundation\Response;
23
use Symfony\Component\OptionsResolver\OptionsResolver;
24
use Twig\Environment;
25
26
/**
27
 * @final since sonata-project/doctrine-orm-admin-bundle 3.x
28
 *
29
 * @author Thomas Rabaix <[email protected]>
30
 */
31
class AuditBlockService extends AbstractBlockService
32
{
33
    /**
34
     * @var AuditReader
35
     */
36
    protected $auditReader;
37
38
    /**
39
     * NEXT_MAJOR: Allow only Environment|EngineInterface for argument 1 and AuditReader for argument 2.
40
     *
41
     * @param Environment|EngineInterface|string $templatingOrDeprecatedName
42
     * @param EngineInterface|AuditReader        $templatingOrAuditReader
43
     */
44
    public function __construct($templatingOrDeprecatedName, object $templatingOrAuditReader, ?AuditReader $auditReader = null)
45
    {
46
        if ($templatingOrAuditReader instanceof EngineInterface) {
47
            @trigger_error(sprintf(
48
                'Passing %s as argument 2 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.21'
49
                .' and will throw a \TypeError in version 4.0. You must pass an instance of %s instead.',
50
                EngineInterface::class,
51
                __METHOD__,
52
                AuditReader::class
53
            ), E_USER_DEPRECATED);
54
55
            if (null === $auditReader) {
56
                throw new \TypeError(sprintf(
57
                    'Passing null as argument 3 to %s() is not allowed when %s is passed as argument 2.'
58
                    .' You must pass an instance of %s instead.',
59
                    __METHOD__,
60
                    EngineInterface::class,
61
                    AuditReader::class
62
                ));
63
            }
64
65
            parent::__construct($templatingOrDeprecatedName, $templatingOrAuditReader);
66
67
            $this->auditReader = $auditReader;
68
        } elseif ($templatingOrAuditReader instanceof AuditReader) {
69
            if (!$templatingOrDeprecatedName instanceof Environment
70
                && !$templatingOrDeprecatedName instanceof EngineInterface
71
            ) {
72
                throw new \TypeError(sprintf(
0 ignored issues
show
The call to TypeError::__construct() has too many arguments starting with sprintf('Argument 1 pass...atingOrDeprecatedName)).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
73
                    'Argument 1 passed to %s() must be either an instance of %s or preferably %s, %s given.',
74
                    __METHOD__,
75
                    EngineInterface::class,
76
                    Environment::class,
77
                    \is_object($templatingOrDeprecatedName)
78
                        ? 'instance of '.\get_class($templatingOrDeprecatedName)
79
                        : \gettype($templatingOrDeprecatedName)
80
                ));
81
            }
82
83
            parent::__construct($templatingOrDeprecatedName);
84
85
            $this->auditReader = $templatingOrAuditReader;
86
        } else {
87
            throw new \TypeError(sprintf(
0 ignored issues
show
The call to TypeError::__construct() has too many arguments starting with sprintf('Argument 2 pass...mplatingOrAuditReader)).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
88
                'Argument 2 passed to %s() must be either an instance of %s or preferably %s, instance of %s given.',
89
                __METHOD__,
90
                EngineInterface::class,
91
                AuditReader::class,
92
                \get_class($templatingOrAuditReader)
93
            ));
94
        }
95
    }
96
97
    public function execute(BlockContextInterface $blockContext, ?Response $response = null): Response
98
    {
99
        $revisions = [];
100
101
        foreach ($this->auditReader->findRevisionHistory($blockContext->getSetting('limit'), 0) as $revision) {
102
            $revisions[] = [
103
                'revision' => $revision,
104
                'entities' => $this->auditReader->findEntitiesChangedAtRevision($revision->getRev()),
105
            ];
106
        }
107
108
        return $this->renderResponse($blockContext->getTemplate(), [
109
            'block' => $blockContext->getBlock(),
110
            'settings' => $blockContext->getSettings(),
111
            'revisions' => $revisions,
112
        ], $response);
113
    }
114
115
    public function buildEditForm(FormMapper $formMapper, BlockInterface $block): void
116
    {
117
    }
118
119
    public function getName()
120
    {
121
        return 'Audit List';
122
    }
123
124
    public function configureSettings(OptionsResolver $resolver): void
125
    {
126
        $resolver->setDefaults([
127
            'limit' => 10,
128
            'template' => '@SonataDoctrineORMAdmin/Block/block_audit.html.twig',
129
        ]);
130
    }
131
}
132