Issues (3099)

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.

unit/EventListener/HostOverrideListenerTest.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 Kunstmaan\MultiDomainBundle\Tests\EventListener;
4
5
use Kunstmaan\MultiDomainBundle\EventListener\HostOverrideListener;
6
use PHPUnit\Framework\TestCase;
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpKernel\HttpKernelInterface;
9
10
class HostOverrideListenerTest extends TestCase
11
{
12
    /**
13
     * @var HostOverrideListener
14
     */
15
    protected $object;
16
17
    /**
18
     * @var
19
     */
20
    protected $session;
21
22
    /**
23
     * @covers \Kunstmaan\MultiDomainBundle\EventListener\HostOverrideListener::__construct
24
     * @covers \Kunstmaan\MultiDomainBundle\EventListener\HostOverrideListener::onKernelResponse
25
     */
26 View Code Duplication
    public function testHostOverrideMessageIsSetForAdmin()
27
    {
28
        $flashBag = $this->createMock('Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface');
29
        $flashBag
30
            ->expects($this->once())
31
            ->method('add')
32
            ->with('warning', 'multi_domain.host_override_active');
33
34
        $object = $this->getHostOverrideListener($flashBag);
35
36
        $event = $this->getFilterResponseEvent($this->getAdminRequest(), $this->getResponse());
37
        $object->onKernelResponse($event);
38
    }
39
40
    /**
41
     * @covers \Kunstmaan\MultiDomainBundle\EventListener\HostOverrideListener::__construct
42
     * @covers \Kunstmaan\MultiDomainBundle\EventListener\HostOverrideListener::onKernelResponse
43
     */
44 View Code Duplication
    public function testHostOverrideMessageIsNotSetForAdminRedirectResponse()
45
    {
46
        $flashBag = $this->createMock('Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface');
47
        $flashBag
48
            ->expects($this->never())
49
            ->method('add');
50
51
        $object = $this->getHostOverrideListener($flashBag);
52
53
        $event = $this->getFilterResponseEvent($this->getAdminRequest(), $this->getRedirectResponse());
54
        $object->onKernelResponse($event);
55
    }
56
57
    /**
58
     * @covers \Kunstmaan\MultiDomainBundle\EventListener\HostOverrideListener::__construct
59
     * @covers \Kunstmaan\MultiDomainBundle\EventListener\HostOverrideListener::onKernelResponse
60
     */
61 View Code Duplication
    public function testHostOverrideMessageIsNotSetForSubRequest()
62
    {
63
        $flashBag = $this->createMock('Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface');
64
        $flashBag
65
            ->expects($this->never())
66
            ->method('add');
67
68
        $object = $this->getHostOverrideListener($flashBag);
69
70
        $event = $this->getFilterResponseEvent($this->getAdminRequest(), $this->getResponse(), HttpKernelInterface::SUB_REQUEST);
71
        $object->onKernelResponse($event);
72
    }
73
74
    /**
75
     * @covers \Kunstmaan\MultiDomainBundle\EventListener\HostOverrideListener::__construct
76
     * @covers \Kunstmaan\MultiDomainBundle\EventListener\HostOverrideListener::onKernelResponse
77
     */
78 View Code Duplication
    public function testHostOverrideMessageIsNotSetForXmlRequest()
79
    {
80
        $flashBag = $this->createMock('Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface');
81
        $flashBag
82
            ->expects($this->never())
83
            ->method('add');
84
85
        $object = $this->getHostOverrideListener($flashBag);
86
87
        $event = $this->getFilterResponseEvent($this->getXmlHttpRequest(), $this->getResponse());
88
        $object->onKernelResponse($event);
89
    }
90
91
    /**
92
     * @covers \Kunstmaan\MultiDomainBundle\EventListener\HostOverrideListener::__construct
93
     * @covers \Kunstmaan\MultiDomainBundle\EventListener\HostOverrideListener::onKernelResponse
94
     */
95 View Code Duplication
    public function testHostOverrideMessageIsNotSetForPreview()
96
    {
97
        $flashBag = $this->createMock('Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface');
98
        $flashBag
99
            ->expects($this->never())
100
            ->method('add');
101
102
        $object = $this->getHostOverrideListener($flashBag);
103
104
        $event = $this->getFilterResponseEvent($this->getAdminPreviewRequest(), $this->getResponse());
105
        $object->onKernelResponse($event);
106
    }
107
108
    /**
109
     * @covers \Kunstmaan\MultiDomainBundle\EventListener\HostOverrideListener::__construct
110
     * @covers \Kunstmaan\MultiDomainBundle\EventListener\HostOverrideListener::onKernelResponse
111
     */
112 View Code Duplication
    public function testHostOverrideMessageIsNotSetForFrontend()
113
    {
114
        $flashBag = $this->createMock('Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface');
115
        $flashBag
116
            ->expects($this->never())
117
            ->method('add');
118
119
        $object = $this->getHostOverrideListener($flashBag);
120
121
        $event = $this->getFilterResponseEvent($this->getFrontendRequest(), $this->getResponse());
122
        $object->onKernelResponse($event);
123
    }
124
125
    private function getHostOverrideListener($flashBag)
126
    {
127
        $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')
128
            ->disableOriginalConstructor()
129
            ->getMock();
130
        $session->method('getFlashBag')
131
            ->willReturn($flashBag);
132
133
        $domainConfiguration = $this->createMock('Kunstmaan\AdminBundle\Helper\DomainConfigurationInterface');
134
        $domainConfiguration->method('getHost')
135
            ->willReturn('override-domain.tld');
136
        $translator = $this->createMock('Symfony\Component\Translation\TranslatorInterface');
137
        $translator->method('trans')
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
138
            ->willReturnArgument(0);
139
140
        $adminRouteReturnValueMap = array(
141
            array('/nl/admin/preview/some-uri', false),
142
            array('/nl/some-uri', false),
143
            array('/nl/admin/some-admin-uri', true),
144
        );
145
146
        $adminRouteHelper = $this->getMockBuilder('Kunstmaan\AdminBundle\Helper\AdminRouteHelper')
147
            ->disableOriginalConstructor()
148
            ->getMock();
149
        $adminRouteHelper
150
            ->expects($this->any())
151
            ->method('isAdminRoute')
152
            ->willReturnMap($adminRouteReturnValueMap);
153
154
        $listener = new HostOverrideListener($session, $translator, $domainConfiguration, $adminRouteHelper);
155
156
        return $listener;
157
    }
158
159
    private function getFilterResponseEvent($request, $response, $requestType = HttpKernelInterface::MASTER_REQUEST)
160
    {
161
        $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FilterResponseEvent')
162
            ->disableOriginalConstructor()
163
            ->getMock();
164
        $event->method('getRequestType')
165
            ->willReturn($requestType);
166
167
        $event->method('getResponse')
168
            ->willReturn($response);
169
170
        $event->method('getRequest')
171
            ->willReturn($request);
172
173
        return $event;
174
    }
175
176
    private function getResponse()
177
    {
178
        return $this->createMock('Symfony\Component\HttpFoundation\Response');
179
    }
180
181
    private function getRedirectResponse()
182
    {
183
        $response = $this->getMockBuilder('Symfony\Component\HttpFoundation\RedirectResponse')
184
            ->disableOriginalConstructor()
185
            ->getMock();
186
187
        return $response;
188
    }
189
190
    private function getXmlHttpRequest()
191
    {
192
        $request = Request::create('http://domain.tld/nl/admin/some-admin-uri');
193
        $request->headers->set('X-Requested-With', 'XMLHttpRequest');
194
195
        return $request;
196
    }
197
198
    private function getAdminRequest()
199
    {
200
        return Request::create('http://domain.tld/nl/admin/some-admin-uri');
201
    }
202
203
    private function getAdminPreviewRequest()
204
    {
205
        return Request::create('http://domain.tld/nl/admin/preview/some-uri');
206
    }
207
208
    private function getFrontendRequest()
209
    {
210
        return Request::create('http://domain.tld/nl/some-uri');
211
    }
212
}
213