Issues (1191)

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.

src/Addon/AddonManager.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 namespace Anomaly\Streams\Platform\Addon;
2
3
use Anomaly\Streams\Platform\Addon\Event\AddonsHaveRegistered;
4
use Anomaly\Streams\Platform\Addon\Extension\ExtensionModel;
5
use Anomaly\Streams\Platform\Addon\Module\ModuleModel;
6
use Illuminate\Contracts\Container\Container;
7
use Illuminate\Contracts\Events\Dispatcher;
8
9
/**
10
 * Class AddonManager
11
 *
12
 * @link    http://pyrocms.com/
13
 * @author  PyroCMS, Inc. <[email protected]>
14
 * @author  Ryan Thompson <[email protected]>
15
 */
16
class AddonManager
17
{
18
19
    /**
20
     * The addon paths.
21
     *
22
     * @var AddonPaths
23
     */
24
    protected $paths;
25
26
    /**
27
     * The addon collection.
28
     *
29
     * @var AddonCollection
30
     */
31
    protected $addons;
32
33
    /**
34
     * The addon loader.
35
     *
36
     * @var AddonLoader
37
     */
38
    protected $loader;
39
40
    /**
41
     * The service container.
42
     *
43
     * @var Container
44
     */
45
    protected $container;
46
47
    /**
48
     * The addon integrator.
49
     *
50
     * @var AddonIntegrator
51
     */
52
    protected $integrator;
53
54
    /**
55
     * The modules model.
56
     *
57
     * @var ModuleModel
58
     */
59
    protected $modules;
60
61
    /**
62
     * The event dispatcher.
63
     *
64
     * @var Dispatcher
65
     */
66
    protected $dispatcher;
67
68
    /**
69
     * The extensions model.
70
     *
71
     * @var ExtensionModel
72
     */
73
    protected $extensions;
74
75
    /**
76
     * Create a new AddonManager instance.
77
     *
78
     * @param AddonPaths      $paths
79
     * @param AddonLoader     $loader
80
     * @param ModuleModel     $modules
81
     * @param Container       $container
82
     * @param Dispatcher      $dispatcher
83
     * @param ExtensionModel  $extensions
84
     * @param AddonIntegrator $integrator
85
     * @param AddonCollection $addons
86
     */
87
    public function __construct(
88
        AddonPaths $paths,
89
        AddonLoader $loader,
90
        ModuleModel $modules,
91
        Container $container,
92
        Dispatcher $dispatcher,
93
        ExtensionModel $extensions,
94
        AddonIntegrator $integrator,
95
        AddonCollection $addons
96
    ) {
97
        $this->paths      = $paths;
98
        $this->addons     = $addons;
99
        $this->loader     = $loader;
100
        $this->modules    = $modules;
101
        $this->container  = $container;
102
        $this->integrator = $integrator;
103
        $this->dispatcher = $dispatcher;
104
        $this->extensions = $extensions;
105
    }
106
107
    /**
108
     * Register all addons.
109
     */
110
    public function register()
111
    {
112
        $enabled   = $this->getEnabledAddonNamespaces();
113
        $installed = $this->getInstalledAddonNamespaces();
114
115
        $this->container->bind(
116
            'streams::addons.enabled',
117
            function () use ($enabled) {
118
                return $enabled;
119
            }
120
        );
121
        $this->container->bind(
122
            'streams::addons.installed',
123
            function () use ($installed) {
124
                return $installed;
125
            }
126
        );
127
128
        $paths = $this->paths->all();
129
130
        /*
131
         * First load all the addons
132
         * so they're available.
133
         */
134
        foreach ($paths as $path) {
135
            $this->loader->load($path);
136
        }
137
138
        $this->loader->register();
139
140
        /*
141
         * Then register all of the addons now
142
         * that they're all PSR autoloaded.
143
         */
144
        foreach ($paths as $path) {
145
146
            $namespace = $this->getAddonNamespace($path);
147
148
            $this->integrator->register(
149
                $path,
150
                $namespace,
151
                in_array($namespace, $enabled),
152
                in_array($namespace, $installed)
153
            );
154
        }
155
156
        // Sort all addons.
157
        $this->addons = $this->addons->sort();
158
159
        /*
160
         * Disperse addons to their
161
         * respective collections and
162
         * finish the integration service.
163
         */
164
        $this->addons->disperse();
165
        $this->addons->registered();
166
        $this->integrator->finish();
167
168
        $this->dispatcher->fire(new AddonsHaveRegistered($this->addons));
169
    }
170
171
    /**
172
     * Get namespaces for enabled addons.
173
     *
174
     * @return array
175
     */
176 View Code Duplication
    protected function getEnabledAddonNamespaces()
0 ignored issues
show
This method seems to be duplicated in 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...
177
    {
178
        if (!env('INSTALLED')) {
179
            return [];
180
        }
181
182
        $modules = $this->modules->cache(
183
            'streams::modules.enabled',
184
            9999,
185
            function () {
186
                return $this->modules->getEnabledNamespaces()->all();
187
            }
188
        );
189
190
        $extensions = $this->extensions->cache(
191
            'streams::extensions.enabled',
192
            9999,
193
            function () {
194
                return $this->extensions->getEnabledNamespaces()->all();
195
            }
196
        );
197
198
        return array_merge($modules, $extensions);
199
    }
200
201
    /**
202
     * Get namespaces for installed addons.
203
     *
204
     * @return array
205
     */
206 View Code Duplication
    protected function getInstalledAddonNamespaces()
0 ignored issues
show
This method seems to be duplicated in 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...
207
    {
208
        if (!env('INSTALLED')) {
209
            return [];
210
        }
211
212
        $modules = $this->modules->cache(
213
            'streams::modules.installed',
214
            9999,
215
            function () {
216
                return $this->modules->getInstalledNamespaces()->all();
217
            }
218
        );
219
220
        $extensions = $this->extensions->cache(
221
            'streams::extensions.installed',
222
            9999,
223
            function () {
224
                return $this->extensions->getInstalledNamespaces()->all();
225
            }
226
        );
227
228
        return array_merge($modules, $extensions);
229
    }
230
231
    /**
232
     * Get the addon namespace.
233
     *
234
     * @param $path
235
     * @return string
236
     */
237
    protected function getAddonNamespace($path)
238
    {
239
        $vendor = strtolower(basename(dirname($path)));
240
        $slug   = strtolower(substr(basename($path), 0, strpos(basename($path), '-')));
241
        $type   = strtolower(substr(basename($path), strpos(basename($path), '-') + 1));
242
243
        return "{$vendor}.{$type}.{$slug}";
244
    }
245
}
246