Issues (116)

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.

Bundle/CoreBundle/Helper/Router/RouterHelper.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
 * WellCommerce Open-Source E-Commerce Platform
4
 * 
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 * 
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
13
namespace WellCommerce\Bundle\CoreBundle\Helper\Router;
14
15
use Symfony\Component\HttpFoundation\RedirectResponse;
16
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
17
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
18
use Symfony\Component\Routing\RequestContext;
19
use Symfony\Component\Routing\Route;
20
use Symfony\Component\Routing\RouterInterface;
21
use WellCommerce\Bundle\CoreBundle\Helper\Request\RequestHelperInterface;
22
23
/**
24
 * Class RouterHelper
25
 *
26
 * @author  Adam Piotrowski <[email protected]>
27
 */
28
final class RouterHelper implements RouterHelperInterface
29
{
30
    /**
31
     * @var RouterInterface
32
     */
33
    private $router;
34
    
35
    /**
36
     * @var RequestHelperInterface
37
     */
38
    private $requestHelper;
39
    
40
    /**
41
     * RouterHelper constructor.
42
     *
43
     * @param RouterInterface        $router
44
     * @param RequestHelperInterface $requestHelper
45
     */
46
    public function __construct(RouterInterface $router, RequestHelperInterface $requestHelper)
47
    {
48
        $this->router        = $router;
49
        $this->requestHelper = $requestHelper;
50
    }
51
    
52
    public function getCurrentAction(): string
53
    {
54
        $currentPath  = $this->getRouterRequestContext()->getPathInfo();
55
        $currentRoute = $this->router->match($currentPath);
56
        list(, $action) = explode(':', $currentRoute['_controller']);
57
        
58
        return $action;
59
    }
60
    
61
    public function getRouterRequestContext(): RequestContext
62
    {
63
        return $this->router->getContext();
64
    }
65
    
66
    public function redirectToAction(string $action, array $params = []): RedirectResponse
67
    {
68
        $route = $this->getActionForCurrentController($action);
69
        
70
        return $this->redirectTo($route, $params);
71
    }
72
    
73
    public function getRedirectToActionUrl(string $action, array $params = []): string
74
    {
75
        $route = $this->getActionForCurrentController($action);
76
        
77
        return $this->router->generate($route, $params);
78
    }
79
    
80
    public function getActionForCurrentController(string $action): string
81
    {
82
        $currentPath  = $this->getRouterRequestContext()->getPathInfo();
83
        $currentRoute = $this->router->match($currentPath);
84
        list($mode, $controller) = explode('.', $currentRoute['_route'], 3);
85
        
86
        $route = sprintf('%s.%s.%s', $mode, $controller, $action);
87
        
88
        return $route;
89
    }
90
    
91
    public function generateUrl(string $routeName, array $params = [], int $referenceType = UrlGeneratorInterface::ABSOLUTE_URL): string
92
    {
93
        return $this->router->generate($routeName, $params, $referenceType);
94
    }
95
    
96
    public function redirectTo(string $route, array $routeParams = []): RedirectResponse
97
    {
98
        $url      = $this->router->generate($route, $routeParams, true);
0 ignored issues
show
true is of type boolean, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
99
        $response = new RedirectResponse($url);
100
        $response->setContent(
101
            sprintf(
102
                '<!DOCTYPE html><html><head></head><script>window.location.href = "%s";</script></html>',
103
                htmlspecialchars($url, ENT_QUOTES, 'UTF-8')
104
            )
105
        );
106
        
107
        return $response;
108
    }
109
    
110
    public function redirectToUrl(string $url, int $status = 302): RedirectResponse
111
    {
112
        return new RedirectResponse($url, $status);
113
    }
114
    
115
    public function getCurrentRoute(): Route
116
    {
117
        $routeName = $this->getCurrentRouteName();
118
        $route     = $this->router->getRouteCollection()->get($routeName);
119
        
120
        if (null === $route) {
121
            throw new NotFoundHttpException('Cannot determine current route from request');
122
        }
123
        
124
        return $route;
125
    }
126
    
127
    public function getCurrentRouteName(): string
128
    {
129
        return (string)$this->requestHelper->getAttributesBagParam('_route');
130
    }
131
}
132