Issues (22)

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/Routing/AnnotatedRouteControllerLoader.php (2 issues)

Labels
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
namespace Drupal\controller_annotations\Routing;
4
5
use Drupal\controller_annotations\Configuration\Method;
6
use Drupal\controller_annotations\Configuration\RouteModifierClassInterface;
7
use Drupal\controller_annotations\Configuration\RouteModifierMethodInterface;
8
use Symfony\Component\Routing\Loader\AnnotationClassLoader;
9
use Symfony\Component\Routing\Route;
10
11
class AnnotatedRouteControllerLoader extends AnnotationClassLoader
12
{
13
    /**
14
     * @param Route $route
15
     * @param \ReflectionClass $class
16
     * @param \ReflectionMethod $method
17
     * @param mixed $annotation
18
     */
19 8
    protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annotation)
20
    {
21 8
        $this->setController($route, $class, $method);
22 8
        $this->configureClassAnnotations($route, $class, $method);
23 8
        $this->configureMethodAnnotations($route, $class, $method);
24 8
    }
25
26
    /**
27
     * @param \ReflectionClass $class
28
     * @return array
29
     */
30 7
    protected function getGlobals(\ReflectionClass $class): array
31
    {
32 7
        $globals = parent::getGlobals($class);
33
34 7
        foreach ($this->reader->getClassAnnotations($class) as $configuration) {
35 7
            if ($configuration instanceof Method) {
36 7
                $globals['methods'] = array_merge($globals['methods'], $configuration->getMethods());
37
            }
38
        }
39
40 7
        return $globals;
41
    }
42
43
    /**
44
     * @param Route $route
45
     * @param \ReflectionClass $class
46
     * @param \ReflectionMethod $method
47
     */
48 8
    protected function configureClassAnnotations(Route $route, \ReflectionClass $class, \ReflectionMethod $method)
49
    {
50 8
        foreach ($this->reader->getClassAnnotations($class) as $configuration) {
51 7
            if ($configuration instanceof RouteModifierClassInterface) {
52 7
                $configuration->modifyRouteClass($route, $class, $method);
53
            }
54
        }
55 8
    }
56
57
    /**
58
     * @param Route $route
59
     * @param \ReflectionClass $class
60
     * @param \ReflectionMethod $method
61
     */
62 8
    protected function configureMethodAnnotations(Route $route, \ReflectionClass $class, \ReflectionMethod $method)
63
    {
64 8
        foreach ($this->reader->getMethodAnnotations($method) as $configuration) {
65 8
            if ($configuration instanceof RouteModifierMethodInterface) {
66 8
                $configuration->modifyRouteMethod($route, $class, $method);
67
            }
68
        }
69 8
    }
70
71
    /**
72
     * @param Route $route
73
     * @param \ReflectionClass $class
74
     * @param \ReflectionMethod $method
75
     */
76 8
    protected function setController(Route $route, \ReflectionClass $class, \ReflectionMethod $method)
77
    {
78 8
        $route->setDefault('_controller', $this->getControllerName($class, $method));
79 8
    }
80
81
    /**
82
     * @param \ReflectionClass $class
83
     * @param \ReflectionMethod $method
84
     * @return string
85
     */
86 8
    protected function getControllerName(\ReflectionClass $class, \ReflectionMethod $method)
87
    {
88 8
        $annotation = $this->reader->getClassAnnotation($class, $this->routeAnnotationClass);
89 8
        if ($annotation instanceof \Drupal\controller_annotations\Configuration\Route && $service = $annotation->getService(
90
            )) {
91 7
            return sprintf('%s:%s', $service, $method->getName());
0 ignored issues
show
Consider using $method->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
92
        }
93
94 8
        return sprintf('%s::%s', $class->getName(), $method->getName());
0 ignored issues
show
Consider using $class->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
95
    }
96
}
97