Issues (47)

Security Analysis    no request data  

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.

lib/Subscriber/Phpcr/GeneralSubscriber.php (2 issues)

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
/*
4
 * This file is part of Sulu.
5
 *
6
 * (c) MASSIVE ART WebServices GmbH
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Sulu\Component\DocumentManager\Subscriber\Phpcr;
13
14
use Sulu\Component\DocumentManager\DocumentRegistry;
15
use Sulu\Component\DocumentManager\Event\ClearEvent;
16
use Sulu\Component\DocumentManager\Event\CopyEvent;
17
use Sulu\Component\DocumentManager\Event\FlushEvent;
18
use Sulu\Component\DocumentManager\Event\HydrateEvent;
19
use Sulu\Component\DocumentManager\Event\MoveEvent;
20
use Sulu\Component\DocumentManager\Event\RefreshEvent;
21
use Sulu\Component\DocumentManager\Events;
22
use Sulu\Component\DocumentManager\NodeManager;
23
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
24
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
25
26
/**
27
 * This class aggregates some basic repository operations.
28
 *
29
 * NOTE: If any of these methods need to become more complicated, and
30
 *       the changes cannot be done by implementing ANOTHER subscriber, then
31
 *       the individual operations should be broken out into individual subscribers.
32
 *
33
 * NOTE: The event dispatcher is added here for the "refresh" method. This is a clear
34
 *       sign that this should be refactored. The hydration, at least, should be outsourced.
35
 */
36
class GeneralSubscriber implements EventSubscriberInterface
37
{
38
    /**
39
     * @var DocumentRegistry
40
     */
41
    private $documentRegistry;
42
43
    /**
44
     * @var NodeManager
45
     */
46
    private $nodeManager;
47
48
    /**
49
     * @var EventDispatcherInterface
50
     */
51
    private $eventDispatcher;
52
53
    public function __construct(
54
        DocumentRegistry $documentRegistry,
55
        NodeManager $nodeManager,
56
        EventDispatcherInterface $eventDispatcher
57
    ) {
58
        $this->documentRegistry = $documentRegistry;
59
        $this->nodeManager = $nodeManager;
60
        $this->eventDispatcher = $eventDispatcher;
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public static function getSubscribedEvents()
67
    {
68
        return [
69
            Events::MOVE => ['handleMove', 400],
70
            Events::COPY => ['handleCopy', 400],
71
            Events::CLEAR => ['handleClear', 500],
72
            Events::FLUSH => ['handleFlush', 500],
73
            Events::REFRESH => ['handleRefresh', 500],
74
        ];
75
    }
76
77
    /**
78
     * @param MoveEvent $event
79
     */
80
    public function handleMove(MoveEvent $event)
81
    {
82
        $document = $event->getDocument();
83
        $node = $this->documentRegistry->getNodeForDocument($document);
84
        $this->nodeManager->move($node->getPath(), $event->getDestId(), $event->getDestName());
85
    }
86
87
    /**
88
     * @param CopyEvent $event
89
     */
90
    public function handleCopy(CopyEvent $event)
91
    {
92
        $document = $event->getDocument();
93
        $node = $this->documentRegistry->getNodeForDocument($document);
94
        $newPath = $this->nodeManager->copy($node->getPath(), $event->getDestId(), $event->getDestName());
95
        $event->setCopiedPath($newPath);
96
    }
97
98
    /**
99
     * @param RefreshEvent $event
100
     */
101
    public function handleRefresh(RefreshEvent $event)
102
    {
103
        $document = $event->getDocument();
104
        $node = $this->documentRegistry->getNodeForDocument($document);
105
        $locale = $this->documentRegistry->getLocaleForDocument($document);
106
107
        // revert/reload the node to the persisted state
108
        $node->revert();
109
110
        // rehydrate the document
111
        $hydrateEvent = new HydrateEvent($node, $locale);
112
        $hydrateEvent->setDocument($document);
113
        $this->eventDispatcher->dispatch(Events::HYDRATE, $hydrateEvent);
114
    }
115
116
    /**
117
     * @param ClearEvent $event
118
     */
119
    public function handleClear(ClearEvent $event)
0 ignored issues
show
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
120
    {
121
        $this->nodeManager->clear();
122
    }
123
124
    /**
125
     * @param FlushEvent $event
126
     */
127
    public function handleFlush(FlushEvent $event)
0 ignored issues
show
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
128
    {
129
        $this->nodeManager->save();
130
    }
131
}
132