Issues (10)

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.

DynamicDispatchVisitor.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
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Cubiche\Core\Visitor;
12
13
/**
14
 * Abstract Dynamic Dispatch Visitor Class.
15
 *
16
 * @author Karel Osorio Ramírez <[email protected]>
17
 */
18
abstract class DynamicDispatchVisitor implements DynamicDispatchVisitorInterface
19
{
20
    /**
21
     * @var \ReflectionMethod[]
22
     */
23
    private $visitorMethods = null;
24
25
    /**
26
     * @var \ReflectionMethod[]
27
     */
28
    private $handlerMethods = array();
29
30
    /**
31
     * @var ResolverVisitorMethodInterface
32
     */
33
    protected $resolver;
34
35
    /**
36
     * @param ResolverVisitorMethodInterface $resolver
37
     */
38
    public function __construct(ResolverVisitorMethodInterface $resolver = null)
39
    {
40
        $this->resolver = $resolver === null ? new ResolverVisitorMethod() : $resolver;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function canHandlerVisitee(VisiteeInterface $visitee)
47
    {
48
        return $this->handlerMethod($visitee) !== null;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function visit(VisiteeInterface $visitee)
55
    {
56
        return $this->visitWith($visitee, \func_get_args());
57
    }
58
59
    /**
60
     * @param VisiteeInterface $visitee
61
     * @param array            $args
62
     *
63
     * @return mixed
64
     */
65
    protected function visitWith(VisiteeInterface $visitee, array $args)
66
    {
67
        $method = $this->handlerMethod($visitee);
68
69
        if ($method !== null) {
70
            return $method->invokeArgs($this, $args);
71
        }
72
73
        throw $this->notSupportedVisiteeException($visitee);
74
    }
75
76
    /**
77
     * @param VisiteeInterface $visitee
78
     *
79
     * @return \LogicException
80
     */
81
    protected function notSupportedVisiteeException(VisiteeInterface $visitee)
82
    {
83
        return new \LogicException(
84
            \sprintf('The %s visitee is not supported by %s visitor', \get_class($visitee), static::class)
85
        );
86
    }
87
88
    /**
89
     * @param VisiteeInterface $visitee
90
     *
91
     * @return \ReflectionMethod|null
92
     */
93
    private function handlerMethod(VisiteeInterface $visitee)
94
    {
95
        $class = new \ReflectionClass(\get_class($visitee));
96
        if (isset($this->handlerMethods[$class->name])) {
97
            return $this->handlerMethods[$class->name];
98
        }
99
        if ($this->visitorMethods === null) {
100
            $this->visitorMethods = $this->visitorMethods();
101
        }
102
103
        return $this->findHandlerMethod($class);
104
    }
105
106
    /**
107
     * @param \ReflectionClass $class
108
     *
109
     * @return \ReflectionMethod|null
110
     */
111
    private function findHandlerMethod(\ReflectionClass $class)
112
    {
113
        $current = $class;
114
        while ($current !== false) {
115
            if (isset($this->visitorMethods[$current->name])) {
116
                $this->handlerMethods[$class->name] = $this->visitorMethods[$current->name];
117
118
                return $this->handlerMethods[$class->name];
119
            }
120
121
            $current = $current->getParentClass();
122
        }
123
124
        return;
125
    }
126
127
    /**
128
     * @return \ReflectionMethod[]
129
     */
130
    private function visitorMethods()
131
    {
132
        $visitorMethods = array();
133
        $reflection = new \ReflectionClass(static::class);
134
        /** @var \ReflectionMethod $method */
135
        foreach ($reflection->getMethods() as $method) {
136
            if ($method->getName() !== 'visit') {
0 ignored issues
show
Consider using $method->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
137
                $visiteeClass = $this->resolver->resolveVisiteeClass($method);
138
                if ($visiteeClass !== null) {
139
                    $visitorMethods[$visiteeClass->getName()] = $method;
0 ignored issues
show
Consider using $visiteeClass->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
140
                }
141
            }
142
        }
143
144
        return $visitorMethods;
145
    }
146
}
147