Issues (508)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/Framework/ExtensionLoader.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace Leonidas\Framework;
4
5
use Leonidas\Contracts\Extension\ExtensionBootProcessInterface;
6
use Leonidas\Contracts\Extension\ExtensionLoaderInterface;
7
use Leonidas\Contracts\Extension\WpExtensionInterface;
8
use Leonidas\Framework\Exception\ExtensionInitiationException;
9
use Leonidas\Framework\Exception\PluginInitiationException;
10
use Leonidas\Framework\Exception\ThemeInitiationException;
11
use Panamax\Contracts\BootableProviderContainerInterface;
12
use Panamax\Contracts\ContainerAdapterInterface;
13
use Panamax\Contracts\ProviderContainerInterface;
14
use Panamax\Contracts\ServiceContainerInterface;
15
use Panamax\Contracts\ServiceCreatorInterface;
16
use WebTheory\Config\Config;
17
use WebTheory\Config\Interfaces\ConfigInterface;
18
19
class ExtensionLoader implements ExtensionLoaderInterface
20
{
21
    protected string $type;
22
23
    protected string $path;
24
25
    protected string $url;
26
27
    protected ServiceContainerInterface $container;
28
29
    protected WpExtensionInterface $extension;
30
31
    protected ConfigInterface $config;
32
33
    public function __construct(string $type, string $path, string $url)
34
    {
35
        $this->type = $type;
36
        $this->path = $path;
37
        $this->url = $url;
38
        $this->container = $this->defineContainer();
39
        $this->extension = $this->defineExtension();
40
    }
41
42
    public function getContainer(): ServiceContainerInterface
43
    {
44
        return $this->container;
45
    }
46
47
    public function getExtension(): WpExtensionInterface
48
    {
49
        return $this->extension;
50
    }
51
52
    public function bootstrap(): void
53
    {
54
        $this
55
            ->initiateConfig()
56
            ->bindServicesToContainer()
57
            ->loadBootProcesses()
58
            ->maybeBootProviders()
59
            ->initializeModules();
60
    }
61
62
    public function error(): void
63
    {
64
        $backtrace = debug_backtrace();
65
        $caller = $backtrace[1];
66
        $method = $caller['class'] . $caller['type'] . $caller['function'];
67
68
        switch ($this->extension->getType()) {
69
            case 'plugin':
70
                throw new PluginInitiationException($this->extension, $method);
71
72
            case 'theme':
73
                throw new ThemeInitiationException($this->extension, $method);
74
75
            default:
76
                throw new ExtensionInitiationException($this->extension, $method);
77
        }
78
    }
79
80
    protected function defineContainer(): ServiceContainerInterface
81
    {
82
        return require $this->path . '/boot/container.php';
83
    }
84
85
    protected function defineExtension(): WpExtensionInterface
86
    {
87
        $container = $this->container instanceof ContainerAdapterInterface
88
            ? $this->container->getAdaptedContainer()
0 ignored issues
show
The method getAdaptedContainer() does not exist on Panamax\Contracts\ServiceContainerInterface. It seems like you code against a sub-type of Panamax\Contracts\ServiceContainerInterface such as Panamax\Contracts\ContainerAdapterInterface or Panamax\Adapters\League\LeagueAdapter. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

88
            ? $this->container->/** @scrutinizer ignore-call */ getAdaptedContainer()
Loading history...
89
            : $this->container;
90
91
        return new WpExtension($this->type, $this->path, $this->url, $container);
92
    }
93
94
    /**
95
     * @return $this
96
     */
97
    protected function initiateConfig(): ExtensionLoader
98
    {
99
        $this->config = new Config($this->path . '/config');
100
101
        return $this;
102
    }
103
104
    /**
105
     * @return $this
106
     */
107
    protected function bindServicesToContainer(): ExtensionLoader
108
    {
109
        $container = $this->container;
110
111
        $container->share('root', $this->path);
112
        $container->share('url', $this->url);
113
        $container->share('config', $this->config);
114
115
        if ($container instanceof ProviderContainerInterface) {
116
            $container->addServiceProviders(
117
                $this->config->get('app.providers', [])
118
            );
119
        }
120
121
        if ($container instanceof ServiceCreatorInterface) {
122
            $container->createServices($this->config->get('app.services', []));
123
        }
124
125
        return $this;
126
    }
127
128
    /**
129
     * @return $this
130
     */
131
    protected function loadBootProcesses(): ExtensionLoader
132
    {
133
        foreach ($this->config->get('app.bootstrap', []) as $bootProcess) {
134
            /** @var ExtensionBootProcessInterface $bootProcess */
135
            $bootProcess = new $bootProcess();
136
            $bootProcess->boot($this->extension, $this->container);
137
        }
138
139
        return $this;
140
    }
141
142
    /**
143
     * @return $this
144
     */
145
    protected function maybeBootProviders(): ExtensionLoader
146
    {
147
        if ($this->container instanceof BootableProviderContainerInterface) {
148
            $this->container->bootServiceProviders();
0 ignored issues
show
The method bootServiceProviders() does not exist on Panamax\Contracts\ServiceContainerInterface. It seems like you code against a sub-type of Panamax\Contracts\ServiceContainerInterface such as Panamax\Contracts\Bootab...viderContainerInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

148
            $this->container->/** @scrutinizer ignore-call */ 
149
                              bootServiceProviders();
Loading history...
149
        }
150
151
        return $this;
152
    }
153
154
    /**
155
     * @return $this
156
     */
157
    protected function initializeModules(): ExtensionLoader
158
    {
159
        (new ModuleInitializer(
160
            $this->extension,
161
            $this->config->get('app.modules', [])
162
        ))->init();
163
164
        return $this;
165
    }
166
}
167