Issues (3)

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/ThemesServiceProvider.php (3 issues)

Severity

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 PeterColes\Themes;
4
5
use Illuminate\Support\Facades\Route;
6
use Illuminate\Support\ServiceProvider;
7
8
class ThemesServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Register any application services.
12
     *
13
     * @return void
14
     */
15
    public function register()
16
    {
17
        $this->registerViewFinder();
18
19
        $this->registerThemes();
20
    }
21
22
    /**
23
     * Perform post-registration booting of services.
24
     *
25
     * @return void
26
     */
27
    public function boot()
28
    {
29
        $this->publishes([
30
            __DIR__.'/../config/themes.php' => config_path('themes.php'),
31
        ]);
32
33
        $this->app['themes']->setTheme($this->app['request']);
34
35
        $this->mapWebRoutes();
36
37
        $this->mapApiRoutes();
38
    }
39
40
    /**
41
     * Re-register the view finder to use use local copy.
42
     *
43
     * @return void
44
     */
45
    protected function registerViewFinder()
46
    {
47
        $this->app['view.finder'] = $this->app->share(function($app) {
48
            $paths = $app['config']['view.paths'];
49
50
            return new FileViewFinder($app['files'], $paths);
51
        });
52
53
        // Apply this finder to the already-registered view factory
54
        $this->app['view']->setFinder($this->app['view.finder']);
55
    }
56
57
    /**
58
     * Register the themes service.
59
     *
60
     * @return void
61
     */
62
    protected function registerThemes()
63
    {
64
        $this->app->singleton('themes', function() {
65
            return new Themes;
66
        });
67
    }
68
69
    /**
70
     * Define the "web" routes for the theme.
71
     *
72
     * These routes all receive session state, CSRF protection, etc.
73
     *
74
     * @return void
75
     */
76
    protected function mapWebRoutes()
77
    {
78
        Route::group([
79
            'middleware' => 'web',
80
            'namespace' => 'App\Http\Controllers',
81
        ], function ($router) {
0 ignored issues
show
The parameter $router is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
82
            $this->loadRouteFile('web');
83
        });
84
    }
85
86
    /**
87
     * Define the "api" routes for the theme. Routes are in two groups, those requiring
88
     * a user to be authenticated and another for routes that don't require any authentication.
89
     *
90
     * These routes are typically stateless.
91
     *
92
     * @return void
93
     */
94
    protected function mapApiRoutes()
95
    {
96
        Route::group([
97
            'middleware' => ['api', 'auth:api'],
98
            'namespace' => 'App\Http\Controllers',
99
            'prefix' => 'api',
100
        ], function ($router) {
0 ignored issues
show
The parameter $router is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
101
            $this->loadRouteFile('api');
102
        });
103
104
        Route::group([
105
            'middleware' => ['api'],
106
            'namespace' => 'App\Http\Controllers',
107
            'prefix' => 'api',
108
        ], function ($router) {
0 ignored issues
show
The parameter $router is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
109
            $this->loadRouteFile('api-no-auth');
110
        });
111
    }
112
113
    /**
114
     * Load route file, but only after checking whether it exists in the theme.
115
     *
116
     * @return void
117
     */
118
    protected function loadRouteFile($routeFile)
119
    {
120
        $routeFile = base_path('themes/'.$this->app['themes']->getTheme().'/routes/'.$routeFile.'.php');
121
        if (file_exists($routeFile)) {
122
            require $routeFile;
123
        }
124
    }
125
}
126