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/AddonPaths.php (5 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\Application\Application;
4
use Illuminate\Contracts\Config\Repository;
5
6
/**
7
 * Class AddonPaths
8
 *
9
 * @link    http://pyrocms.com/
10
 * @author  PyroCMS, Inc. <[email protected]>
11
 * @author  Ryan Thompson <[email protected]>
12
 */
13
class AddonPaths
14
{
15
16
    /**
17
     * The config repository.
18
     *
19
     * @var Repository
20
     */
21
    protected $config;
22
23
    /**
24
     * The stream application.
25
     *
26
     * @var Application
27
     */
28
    protected $application;
29
30
    /**
31
     * Create a new AddonPaths instance.
32
     *
33
     * @param Application $application
34
     * @param Repository $config
35
     */
36
    public function __construct(Application $application, Repository $config)
37
    {
38
        $this->config      = $config;
39
        $this->application = $application;
40
    }
41
42
43
    /**
44
     * Return all addon paths in a given folder.
45
     *
46
     * @return array
47
     */
48
    public function all()
49
    {
50
        $eager    = $this->eager();
51
        $deferred = $this->deferred();
52
53
        $core        = $this->core() ?: [];
54
        $shared      = $this->shared() ?: [];
55
        $application = $this->application() ?: [];
56
57
        // Testing only addons.
58
        $testing = $this->testing() ?: [];
59
60
        // Other configured addons.
61
        $configured = $this->configured() ?: [];
62
63
        /*
64
         * Merge the eager and deferred
65
         * onto the front and back of
66
         * the paths respectively.
67
         */
68
69
        return array_unique(
70
            array_merge(
71
                $eager,
72
                array_reverse(
73
                    array_unique(
74
                        array_reverse(
75
                            array_merge(
76
                                array_filter(
77
                                    array_merge($core, $shared, $application, $configured, $testing)
78
                                ),
79
                                $deferred
80
                            )
81
                        )
82
                    )
83
                )
84
            )
85
        );
86
    }
87
88
    /**
89
     * Return paths to eager loaded addons.
90
     *
91
     * @return array
92
     */
93
    protected function eager()
94
    {
95
        return array_map(
96
            function ($path) {
97
                return base_path($path);
98
            },
99
            $this->config->get('streams::addons.eager', [])
100
        );
101
    }
102
103
    /**
104
     * Return paths to deferred addons.
105
     *
106
     * @return array
107
     */
108
    protected function deferred()
109
    {
110
        return array_map(
111
            function ($path) {
112
                return base_path($path);
113
            },
114
            $this->config->get('streams::addons.deferred', [])
115
        );
116
    }
117
118
    /**
119
     * Return all core addon paths in a given folder.
120
     *
121
     * @return bool
122
     */
123 View Code Duplication
    public function core()
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...
124
    {
125
        $path = base_path('core');
126
127
        if (!is_dir($path)) {
128
            return false;
129
        }
130
131
        return $this->vendorAddons(glob("{$path}/*", GLOB_ONLYDIR));
132
    }
133
134
    /**
135
     * Return vendor addons of a given type.
136
     *
137
     * @param $directories
138
     * @return array
139
     */
140
    protected function vendorAddons($directories)
141
    {
142
        $paths = [];
143
144
        foreach ($directories as $vendor) {
145
            foreach (glob("{$vendor}/*", GLOB_ONLYDIR) as $addon) {
146
                $paths[] = $addon;
147
            }
148
        }
149
150
        return $paths;
151
    }
152
153
    /**
154
     * Return all shared addon paths in a given folder.
155
     *
156
     * @return bool
157
     */
158 View Code Duplication
    public function shared()
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...
159
    {
160
        $path = base_path('addons/shared');
161
162
        if (!is_dir($path)) {
163
            return false;
164
        }
165
166
        return $this->vendorAddons(glob("{$path}/*", GLOB_ONLYDIR));
167
    }
168
169
    /**
170
     * Return all application addon paths in a given folder.
171
     *
172
     * @return bool
173
     */
174 View Code Duplication
    public function application()
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...
175
    {
176
        $path = base_path('addons/' . $this->application->getReference());
177
178
        if (!is_dir($path)) {
179
            return false;
180
        }
181
182
        return $this->vendorAddons(glob("{$path}/*", GLOB_ONLYDIR));
183
    }
184
185
    /**
186
     * Return paths to testing only addons.
187
     *
188
     * @return array|bool
189
     */
190 View Code Duplication
    protected function testing()
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...
191
    {
192
        $path = base_path('vendor/anomaly/streams-platform/addons');
193
194
        if (!is_dir($path) || env('APP_ENV') !== 'testing') {
195
            return false;
196
        }
197
198
        return $this->vendorAddons(glob("{$path}/*", GLOB_ONLYDIR));
199
    }
200
201
    /**
202
     * Return paths to testing only addons.
203
     *
204
     * @return array|bool
205
     */
206 View Code Duplication
    protected function directory($directory)
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
        $path = base_path($directory);
209
210
        if (!is_dir($path)) {
211
            return false;
212
        }
213
214
        return $this->vendorAddons(glob("{$path}/*", GLOB_ONLYDIR));
215
    }
216
217
    /**
218
     * Return paths to configured addons.
219
     *
220
     * @return array|bool
221
     */
222
    protected function configured()
223
    {
224
        $paths = array_map(
225
            function ($path) {
226
                return base_path($path);
227
            },
228
            $this->config->get('streams::addons.paths', [])
229
        );
230
231
        foreach ($this->config->get('streams::addons.directories', []) as $directory) {
232
            $paths = array_merge($paths, (array)$this->directory(trim($directory, '\\/')));
233
        }
234
235
        return array_unique(array_filter($paths));
236
    }
237
}
238