Issues (3)

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.

Routing/DocumentUrlGenerator.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
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ONGR\RouterBundle\Routing;
13
14
use ONGR\ElasticsearchBundle\Mapping\MetadataCollector;
15
use ONGR\RouterBundle\Document\SeoAwareInterface;
16
use Symfony\Cmf\Component\Routing\ProviderBasedGenerator;
17
use Symfony\Cmf\Component\Routing\VersatileGeneratorInterface;
18
use Symfony\Component\Routing\Exception\RouteNotFoundException;
19
use Symfony\Component\Routing\Route;
20
21
class DocumentUrlGenerator extends ProviderBasedGenerator implements VersatileGeneratorInterface
22
{
23
    /**
24
     * @var array Route map configuration to map Elasticsearch types and Controllers.
25
     */
26
    private $routeMap;
27
28
    /**
29
     * @var MetadataCollector
30
     */
31
    private $collector;
32
33
    /**
34
     * @return mixed
35
     */
36
    public function getRouteMap()
37
    {
38
        return $this->routeMap;
39
    }
40
41
    /**
42
     * @param mixed $routeMap
43
     */
44
    public function setRouteMap($routeMap)
45
    {
46
        $this->routeMap = $routeMap;
0 ignored issues
show
Documentation Bug introduced by
It seems like $routeMap of type * is incompatible with the declared type array of property $routeMap.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
47
    }
48
49
    /**
50
     * @return MetadataCollector
51
     */
52
    public function getCollector()
53
    {
54
        return $this->collector;
55
    }
56
57
    /**
58
     * @param MetadataCollector $collector
59
     */
60
    public function setCollector(MetadataCollector $collector)
61
    {
62
        $this->collector = $collector;
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
69
    {
70
        try {
71
            if ($name instanceof SeoAwareInterface) {
72
                $documentUrl = $name->getUrl();
73
            } else {
74
                throw new RouteNotFoundException();
75
            }
76
77
            $type = $this->collector->getDocumentType(get_class($name));
78
            $route = new Route(
79
                $documentUrl,
80
                [
81
                    '_controller' => $this->routeMap[$type],
82
                    'document' => $name,
83
                    'type' => $type,
84
                ]
85
            );
86
87
            // the Route has a cache of its own and is not recompiled as long as it does not get modified
88
            $compiledRoute = $route->compile();
89
            $hostTokens = $compiledRoute->getHostTokens();
90
91
            return $this->doGenerate(
92
                $compiledRoute->getVariables(),
93
                $route->getDefaults(),
94
                $route->getRequirements(),
95
                $compiledRoute->getTokens(),
96
                $parameters,
97
                'ongr_route',
98
                $referenceType,
99
                $hostTokens
100
            );
101
        } catch (\Exception $e) {
102
            throw new RouteNotFoundException('Document is not correct or route cannot be generated.');
103
        }
104
    }
105
    /**
106
     * @param mixed $name The route "name" which may also be an object or anything
107
     *
108
     * @return bool
109
     * @throws RouteNotFoundException
110
     */
111
    public function supports($name)
112
    {
113
        return $name instanceof SeoAwareInterface;
114
    }
115
    /**
116
     * @param mixed $name
117
     * @param array $parameters which should contain a content field containing
118
     *                          a RouteReferrersReadInterface object
119
     *
120
     * @return string
121
     */
122
    public function getRouteDebugMessage($name, array $parameters = array())
123
    {
124
        if ($name instanceof SeoAwareInterface) {
125
            return 'The route object is fit for parsing to generate() method';
126
        }
127
128
        return 'Given route object must be an instance of SeoAwareInterface';
129
    }
130
}
131