Issues (13)

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.

src/Factory/AbstractDriver.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
declare(strict_types=1);
3
4
/*
5
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
9
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
10
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
 * THE SOFTWARE.
12
 *
13
 * This software consists of voluntary contributions made by many individuals
14
 * and is licensed under the MIT license.
15
 *
16
 * Copyright (c) 2018 Yuuki Takezawa
17
 */
18
19
namespace Ytake\Lom\Factory;
20
21
use PhpParser\BuilderFactory;
22
use PhpParser\Node\Stmt\Class_;
23
use PhpParser\Node\Stmt\ClassMethod;
24
use ReflectionClass;
25
use ReflectionMethod;
26
use ReflectionProperty;
27
use Ytake\Lom\Access;
28
29
/**
30
 * Class AbstractDriver.
31
 *
32
 * @author  yuuki.takezawa<[email protected]>
33
 * @license http://opensource.org/licenses/MIT MIT
34
 */
35
abstract class AbstractDriver implements FactoryInterface
36
{
37
    /** @var ReflectionClass */
38
    protected $reflector;
39
40
    /** @var array */
41
    protected $parsed = [];
42
43
    /** @var BuilderFactory */
44
    protected $builder;
45
46
    /** @var */
47
    protected $annotation;
48
49
    /** @var ReflectionProperty */
50
    protected $property;
51
52
    /** @var ReflectionMethod */
53
    protected $method;
54
55
    /**
56
     * @param array          $parsed
57
     * @param BuilderFactory $builder
58
     */
59
    public function __construct(array $parsed, BuilderFactory $builder)
60
    {
61
        $this->parsed = $parsed;
62
        $this->builder = $builder;
63
    }
64
65
    /**
66
     * set ReflectionClass.
67
     *
68
     * @param ReflectionClass $reflection
69
     *
70
     * @return $this
71
     */
72
    public function setReflector(ReflectionClass $reflection): AbstractDriver
73
    {
74
        $this->reflector = $reflection;
75
76
        return $this;
77
    }
78
79
    /**
80
     * @param $annotation
81
     *
82
     * @return $this
83
     */
84
    public function setAnnotationInstance($annotation): AbstractDriver
85
    {
86
        $this->annotation = $annotation;
87
88
        return $this;
89
    }
90
91
    /**
92
     * @param ReflectionProperty $name
93
     *
94
     * @return $this
95
     */
96
    public function setProperty(ReflectionProperty $name): AbstractDriver
97
    {
98
        $this->property = $name;
99
100
        return $this;
101
    }
102
103
    /**
104
     * @param Class_ $part
105
     */
106
    protected function removeConstructor(Class_ $part)
107
    {
108
        if (!is_null($this->reflector->getConstructor())) {
109
            $this->removeMethod($part, '__construct');
110
        }
111
    }
112
113
    /**
114
     * @param Class_ $part
115
     * @param string $name
116
     */
117
    protected function removeMethod(Class_ $part, string $name)
118
    {
119 View Code Duplication
        foreach ($part->stmts as $key => $statement) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
120
            if ($statement instanceof ClassMethod) {
121
                if ($statement->name === $name) {
122
                    unset($part->stmts[$key]);
123
                }
124
            }
125
        }
126
    }
127
128
    /**
129
     * detect constructor access level.
130
     *
131
     * @return string
132
     */
133
    protected function setAccessLevel(): string
134
    {
135
        switch ($this->annotation->access) {
136
            case Access::LEVEL_PRIVATE:
137
                return 'makePrivate';
138
            case Access::LEVEL_PROTECTED:
139
                return 'makeProtected';
140
            default:
141
                return 'makePublic';
142
        }
143
    }
144
}
145