This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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\Http; |
||
2 | |||
3 | use Illuminate\Contracts\Foundation\Application; |
||
4 | use Illuminate\Routing\Router; |
||
5 | |||
6 | /** |
||
7 | * Class Kernel |
||
8 | * |
||
9 | * @link http://pyrocms.com/ |
||
10 | * @author PyroCMS, Inc. <[email protected]> |
||
11 | * @author Ryan Thompson <[email protected]> |
||
12 | */ |
||
13 | class Kernel extends \Illuminate\Foundation\Http\Kernel |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * The application's global HTTP middleware stack. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $middleware = [ |
||
22 | \Illuminate\Cookie\Middleware\EncryptCookies::class, |
||
23 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, |
||
24 | \Illuminate\Session\Middleware\StartSession::class, |
||
25 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, |
||
26 | \Anomaly\Streams\Platform\Http\Middleware\SetLocale::class, |
||
27 | ]; |
||
28 | |||
29 | /** |
||
30 | * The application's route middleware. |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $routeMiddleware = [ |
||
35 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, |
||
36 | 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, |
||
37 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, |
||
38 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, |
||
39 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, |
||
40 | //'guest' => \Illuminate\Auth\Middleware\RedirectIfAuthenticated::class, |
||
0 ignored issues
–
show
|
|||
41 | ]; |
||
42 | |||
43 | /** |
||
44 | * The application's route middleware groups. |
||
45 | * |
||
46 | * @var array |
||
47 | */ |
||
48 | protected $middlewareGroups = [ |
||
49 | 'web' => [ |
||
50 | \Illuminate\Cookie\Middleware\EncryptCookies::class, |
||
51 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, |
||
52 | \Illuminate\Session\Middleware\StartSession::class, |
||
53 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, |
||
54 | \Illuminate\Foundation\Http\Middleware\VerifyCsrfToken::class, |
||
55 | \Illuminate\Routing\Middleware\SubstituteBindings::class, |
||
56 | ], |
||
57 | |||
58 | 'api' => [ |
||
59 | 'throttle:60,1', |
||
60 | 'bindings', |
||
61 | ], |
||
62 | ]; |
||
63 | |||
64 | /** |
||
65 | * Create a new Kernel instance. |
||
66 | * |
||
67 | * @param Application $app |
||
68 | * @param Router $router |
||
69 | */ |
||
70 | public function __construct(Application $app, Router $router) |
||
71 | { |
||
72 | $this->defineLocale(); |
||
73 | |||
74 | $config = require base_path('config/streams.php'); |
||
75 | |||
76 | $this->middleware = array_get($config, 'middleware') ?: $this->middleware; |
||
0 ignored issues
–
show
It seems like
array_get($config, 'midd...') ?: $this->middleware of type * is incompatible with the declared type array of property $middleware .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
77 | $this->routeMiddleware = array_get($config, 'route_middleware') ?: $this->routeMiddleware; |
||
0 ignored issues
–
show
It seems like
array_get($config, 'rout... $this->routeMiddleware of type * is incompatible with the declared type array of property $routeMiddleware .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
78 | $this->middlewareGroups = array_get($config, 'middleware_groups') ?: $this->middlewareGroups; |
||
0 ignored issues
–
show
It seems like
array_get($config, 'midd...$this->middlewareGroups of type * is incompatible with the declared type array of property $middlewareGroups .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
79 | $this->middlewarePriority = array_get($config, 'middleware_priority') ?: $this->middlewarePriority; |
||
0 ignored issues
–
show
It seems like
array_get($config, 'midd...his->middlewarePriority of type * is incompatible with the declared type array of property $middlewarePriority .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
80 | |||
81 | parent::__construct($app, $router); |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * Define the locale |
||
86 | * based on our URI. |
||
87 | * |
||
88 | * Huge thanks to @keevitaja for this one. |
||
89 | * |
||
90 | * @link https://github.com/keevitaja/linguist |
||
91 | */ |
||
92 | protected function defineLocale() |
||
0 ignored issues
–
show
defineLocale uses the super-global variable $_SERVER which is generally not recommended.
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: // Bad
class Router
{
public function generate($path)
{
return $_SERVER['HOST'].$path;
}
}
// Better
class Router
{
private $host;
public function __construct($host)
{
$this->host = $host;
}
public function generate($path)
{
return $this->host.$path;
}
}
class Controller
{
public function myAction(Request $request)
{
// Instead of
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
// Better (assuming you use the Symfony2 request)
$page = $request->query->get('page', 1);
}
}
![]() |
|||
93 | { |
||
94 | /* |
||
95 | * Make sure the ORIGINAL_REQUEST_URI is always available |
||
96 | * Overwrite later as necessary |
||
97 | */ |
||
98 | $_SERVER['ORIGINAL_REQUEST_URI'] = array_get($_SERVER, 'REQUEST_URI'); |
||
99 | |||
100 | /* |
||
101 | * First grab the supported i18n locales |
||
102 | * that we should be looking for. |
||
103 | */ |
||
104 | $locales = require __DIR__ . '/../../resources/config/locales.php'; |
||
105 | |||
106 | if (file_exists($override = __DIR__ . '/../../../../../resources/core/config/streams/locales.php')) { |
||
107 | $locales = array_replace_recursive($locales, require $override); |
||
108 | } |
||
109 | |||
110 | if (!$hint = array_get($locales, 'hint')) { |
||
111 | return; |
||
112 | } |
||
113 | |||
114 | /* |
||
115 | * Check the domain for a locale. |
||
116 | */ |
||
117 | $url = parse_url(array_get($_SERVER, 'HTTP_HOST')); |
||
118 | |||
119 | if ($url === false) { |
||
120 | throw new \Exception('Malformed URL: ' . $url); |
||
121 | } |
||
122 | |||
123 | $host = array_get($url, 'host'); |
||
124 | |||
125 | $pattern = '/^(' . implode('|', array_keys($locales['supported'])) . ')(\.)./'; |
||
126 | |||
127 | if ($host && ($hint === 'domain' || $hint === true) && preg_match($pattern, $host, $matches)) { |
||
128 | |||
129 | define('LOCALE', $matches[1]); |
||
130 | |||
131 | return; |
||
132 | } |
||
133 | |||
134 | /* |
||
135 | * Let's first look in the URI |
||
136 | * path for for a locale. |
||
137 | */ |
||
138 | $pattern = '/^\/(' . implode('|', array_keys($locales['supported'])) . ')\//'; |
||
139 | |||
140 | $uri = array_get($_SERVER, 'REQUEST_URI', filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL)); |
||
141 | |||
142 | View Code Duplication | if (($hint === 'uri' || $hint === true) && preg_match($pattern, $uri, $matches)) { |
|
0 ignored issues
–
show
This code seems to be duplicated across 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. ![]() |
|||
143 | |||
144 | $_SERVER['ORIGINAL_REQUEST_URI'] = $uri; |
||
145 | $_SERVER['REQUEST_URI'] = preg_replace($pattern, '/', $uri); |
||
146 | |||
147 | define('LOCALE', $matches[1]); |
||
148 | |||
149 | return; |
||
150 | } |
||
151 | |||
152 | /* |
||
153 | * Check if we're on the home page. |
||
154 | */ |
||
155 | $pattern = '/^\/(' . implode('|', array_keys($locales['supported'])) . ')$/'; |
||
156 | |||
157 | $uri = array_get($_SERVER, 'REQUEST_URI', filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL)); |
||
158 | |||
159 | View Code Duplication | if (($hint === 'uri' || $hint === true) && preg_match($pattern, $uri, $matches)) { |
|
0 ignored issues
–
show
This code seems to be duplicated across 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. ![]() |
|||
160 | |||
161 | $_SERVER['ORIGINAL_REQUEST_URI'] = $uri; |
||
162 | $_SERVER['REQUEST_URI'] = preg_replace($pattern, '/', $uri); |
||
163 | |||
164 | define('LOCALE', $matches[1]); |
||
165 | |||
166 | return; |
||
167 | } |
||
168 | } |
||
169 | } |
||
170 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.