Issues (18)

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.

Classes/Loader.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
 * Central Loader object.
5
 */
6
declare(strict_types = 1);
7
8
namespace HDNET\Autoloader;
9
10
use HDNET\Autoloader\Cache\AutoloaderFileBackend;
11
use HDNET\Autoloader\Utility\ReflectionUtility;
12
use TYPO3\CMS\Core\Utility\GeneralUtility;
13
14
/**
15
 * Central Loader object.
16
 */
17
class Loader implements SingletonInterface
18
{
19
    /**
20
     * The different implementations and the order of the execution.
21
     *
22
     * @var array
23
     */
24
    protected $implementations = [
25
        // class replacement
26
        'Xclass',
27
        'AlternativeImplementations',
28
        // additional functions
29
        'Hooks',
30
        'Slots',
31
        // smart object management
32
        'SmartObjects',
33
        'ContentObjects',
34
        'TcaFiles',
35
        'ExtensionTypoScriptSetup',
36
        'ContextSensitiveHelps',
37
        // non-critical
38
        'Plugins',
39
        'FlexForms',
40
        'CommandController',
41
        'StaticTyposcript',
42
        'ExtensionId',
43
        'TypeConverter',
44
        'BackendLayout',
45
        'LanguageOverride',
46
        'Icon',
47
        'Gridelement',
48
        'FluidNamespace',
49
    ];
50
51
    /**
52
     * The Extension key.
53
     *
54
     * @var string
55
     */
56
    protected $extensionKey;
57
58
    /**
59
     * The vendorName.
60
     *
61
     * @var string
62
     */
63
    protected $vendorName;
64
65
    /**
66
     * Call this method in the ext_tables.php file.
67
     *
68
     * @param string $vendorName
69
     * @param string $extensionKey
70
     */
71
    public static function extTables($vendorName, $extensionKey, array $implementations = []): void
72
    {
73
        /** @var \HDNET\Autoloader\Loader $loader */
74
        $loader = GeneralUtility::makeInstance(self::class);
75
        $loader->loadExtTables($vendorName, $extensionKey, $implementations);
76
    }
77
78
    /**
79
     * Call this method in the ext_localconf.php file.
80
     *
81
     * @param string $vendorName
82
     * @param string $extensionKey
83
     */
84
    public static function extLocalconf($vendorName, $extensionKey, array $implementations = []): void
85
    {
86
        /** @var \HDNET\Autoloader\Loader $loader */
87
        $loader = GeneralUtility::makeInstance(self::class);
88
        $loader->loadExtLocalconf($vendorName, $extensionKey, $implementations);
89
    }
90
91
    /**
92
     * Load the ext tables information.
93
     *
94
     * @param string $vendorName
95
     * @param string $extensionKey
96
     */
97
    public function loadExtTables($vendorName, $extensionKey, array $implementations = []): void
98
    {
99
        $this->extensionKey = $extensionKey;
100
        $this->vendorName = $vendorName;
101
102
        $autoLoaderObjects = $this->buildAutoLoaderObjects($implementations);
103
        $information = $this->prepareAutoLoaderObjects($autoLoaderObjects, LoaderInterface::EXT_TABLES);
104
        foreach ($autoLoaderObjects as $object) {
105
            /** @var LoaderInterface $object */
106
            $informationArray = $information[\get_class($object)];
107
            if (\is_array($informationArray)) {
108
                $object->loadExtensionTables($this, $informationArray);
109
            }
110
        }
111
    }
112
113
    /**
114
     * Load the ext localconf information.
115
     *
116
     * @param string $vendorName
117
     * @param string $extensionKey
118
     */
119
    public function loadExtLocalconf($vendorName, $extensionKey, array $implementations = []): void
120
    {
121
        $this->extensionKey = $extensionKey;
122
        $this->vendorName = $vendorName;
123
124
        $autoLoaderObjects = $this->buildAutoLoaderObjects($implementations);
125
        $information = $this->prepareAutoLoaderObjects($autoLoaderObjects, LoaderInterface::EXT_LOCAL_CONFIGURATION);
126
        foreach ($autoLoaderObjects as $object) {
127
            /** @var LoaderInterface $object */
128
            $informationArray = $information[\get_class($object)];
129
            if (\is_array($informationArray)) {
130
                $object->loadExtensionConfiguration($this, $informationArray);
131
            }
132
        }
133
    }
134
135
    /**
136
     * Get the extension key.
137
     *
138
     * @return string
139
     */
140
    public function getExtensionKey()
141
    {
142
        return $this->extensionKey;
143
    }
144
145
    /**
146
     * Get the vendor name.
147
     *
148
     * @return string
149
     */
150
    public function getVendorName()
151
    {
152
        return $this->vendorName;
153
    }
154
155
    /**
156
     * check if the class is loadable and is instantiable
157
     * (exists and is no interface or abstraction etc.).
158
     *
159
     * @param $class
160
     *
161
     * @return bool
162
     */
163
    public function isInstantiableClass($class)
164
    {
165
        return ReflectionUtility::isInstantiable($class);
166
    }
167
168
    /**
169
     * Build the Autoloader objects.
170
     *
171
     * @return array
172
     */
173
    protected function buildAutoLoaderObjects(array $objectNames = [])
174
    {
175
        static $objectCache = [];
176
        $objectNames = $this->getAutoLoaderNamesInRightOrder($objectNames);
177
        $objects = [];
178
        foreach ($objectNames as $autoLoaderObjectName) {
179
            if (!isset($objectCache[$autoLoaderObjectName])) {
180
                if (class_exists('HDNET\\Autoloader\\Loader\\' . $autoLoaderObjectName)) {
181
                    $objectCache[$autoLoaderObjectName] = GeneralUtility::makeInstance('HDNET\\Autoloader\\Loader\\' . $autoLoaderObjectName);
182
                } else {
183
                    $objectCache[$autoLoaderObjectName] = GeneralUtility::makeInstance($autoLoaderObjectName);
184
                }
185
            }
186
            $objects[] = $objectCache[$autoLoaderObjectName];
187
        }
188
189
        return $objects;
190
    }
191
192
    /**
193
     * Get the Autoloader Names in the right order.
194
     *
195
     * @return array
196
     */
197
    protected function getAutoLoaderNamesInRightOrder(array $objectNames = [])
198
    {
199
        if (empty($objectNames)) {
200
            return $this->implementations;
201
        }
202
203
        // sort
204
        $names = [];
205
        foreach ($this->implementations as $className) {
206
            if (\in_array($className, $objectNames, true)) {
207
                $names[] = $className;
208
                unset($objectNames[array_search($className, $objectNames, true)]);
209
            }
210
        }
211
212
        return array_merge($names, $objectNames);
213
    }
214
215
    /**
216
     * Prepare the autoLoader information.
217
     *
218
     * @param int $type
219
     *
220
     * @return array
221
     */
222
    protected function prepareAutoLoaderObjects(array $objects, $type)
223
    {
224
        $cacheIdentifier = $this->getVendorName() . '_' . $this->getExtensionKey() . '_' . GeneralUtility::shortMD5(serialize($objects)) . '_' . $type;
225
226
        // Do not use Caching Framework here
227
        /** @var AutoloaderFileBackend $cacheBackend */
228
        $cacheBackend = GeneralUtility::makeInstance(AutoloaderFileBackend::class, null);
229
        if ($cacheBackend->has($cacheIdentifier)) {
230
            return $cacheBackend->get($cacheIdentifier);
231
        }
232
233
        $return = $this->buildLoaderInformation($objects, $type);
234
        $cacheBackend->set($cacheIdentifier, $return);
0 ignored issues
show
$return is of type array, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
235
236
        return $return;
237
    }
238
239
    /**
240
     * Build the loader information.
241
     *
242
     * @param $objects
243
     * @param $type
244
     *
245
     * @return array
246
     */
247
    protected function buildLoaderInformation($objects, $type)
248
    {
249
        $return = [];
250
        foreach ($objects as $object) {
251
            // LoaderInterface
252
            $return[\get_class($object)] = $object->prepareLoader($this, $type);
253
        }
254
255
        return $return;
256
    }
257
}
258