Issues (24)

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/Hydrator/ClassMapper.php (2 issues)

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 Dgame\Soap\Hydrator;
4
5
use Dgame\Variants\Variants;
6
7
/**
8
 * Class ClassMapper
9
 * @package Dgame\Soap\Hydrator
10
 */
11
final class ClassMapper
12
{
13
    /**
14
     * @var array
15
     */
16
    private $classmap = [];
17
    /**
18
     * @var array
19
     */
20
    private $pattern = [];
21
22
    /**
23
     * AutoLoad constructor.
24
     *
25
     * @param array $classmap
26
     */
27 9
    public function __construct(array $classmap = [])
28
    {
29 9
        $this->classmap = $classmap;
30 9
    }
31
32
    /**
33
     * @param string $name
34
     * @param string $class
35
     */
36
    public function appendClass(string $name, string $class)
37
    {
38
        $this->classmap[$name] = $class;
39
    }
40
41
    /**
42
     * @param string $pattern
43
     * @param string $class
44
     */
45 2
    public function appendPattern(string $pattern, string $class)
46
    {
47 2
        $this->pattern[$pattern] = $class;
48 2
    }
49
50
    /**
51
     * @param string $name
52
     *
53
     * @return object|null
54
     */
55 9
    public function new(string $name)
56
    {
57 9
        foreach (Variants::ofArguments($name)->withCamelSnakeCase() as $class) {
58 9
            $class = $this->findClass($class);
59
            if ($class !== null) {
60
                return new $class();
61 9
            }
62
        }
63
64
        return null;
65
    }
66
67
    /**
68
     * @param string $class
69 9
     *
70
     * @return null|string
71 9
     */
72 9
    private function findClass(string $class)
73 9
    {
74
        $class = $this->resolveClass($class);
0 ignored issues
show
Consider using a different name than the parameter $class. This often makes code more readable.
Loading history...
75
        if ($this->existsClass($class)) {
76 9
            return $class;
77 2
        }
78 2
79
        return $this->searchForClassPattern($class);
80
    }
81
82 9
    /**
83
     * @param string $class
84
     *
85
     * @return null|string
86
     */
87
    private function searchForClassPattern(string $class)
88
    {
89
        foreach ($this->pattern as $pattern => $name) {
90 9
            if (preg_match($pattern, $class) === 1) {
91
                $class = $this->resolveClass($name);
0 ignored issues
show
Consider using a different name than the parameter $class. This often makes code more readable.
Loading history...
92 9
                if ($this->existsClass($class)) {
93 9
                    return $class;
94 9
                }
95
            }
96
        }
97
98 9
        return null;
99
    }
100
101
    /**
102
     * @param string $class
103
     *
104
     * @return string
105
     */
106 9
    private function resolveClass(string $class): string
107
    {
108 9
        return $this->hasClassInClassmap($class) ? $this->classmap[$class] : $class;
109 9
    }
110 9
111
    /**
112
     * @param string $class
113 9
     *
114
     * @return bool
115
     */
116
    private function hasClassInClassmap(string $class): bool
117
    {
118
        return array_key_exists($class, $this->classmap);
119
    }
120 9
121
    /**
122 9
     * @param string $class
123
     *
124
     * @return bool
125
     */
126
    private function existsClass(string $class): bool
127
    {
128
        return class_exists($class);
129
    }
130
}