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 |
||
2 | |||
3 | namespace Tracking; |
||
4 | |||
5 | use Illuminate\Foundation\AliasLoader; |
||
6 | use Illuminate\Routing\Router; |
||
7 | use Illuminate\Support\Collection; |
||
8 | use Illuminate\Support\Facades\App; |
||
9 | // use Sitec\Laracogs\LaracogsProvider; |
||
10 | use Illuminate\Support\Facades\Schema; |
||
11 | use Illuminate\Support\Facades\View; |
||
12 | use Illuminate\Support\ServiceProvider; |
||
13 | use Muleta\Traits\Providers\ConsoleTools; |
||
14 | use Route; |
||
15 | use Tracking\Console\Commands\MigrateCommand; |
||
16 | use Tracking\Console\Commands\PublishCommand; |
||
17 | use Tracking\Console\Commands\RollbackCommand; |
||
18 | use Tracking\Http\Middleware\Analytics; |
||
19 | use Tracking\Http\Middleware\TrackStatistics; |
||
20 | use Tracking\Models\Statistics\Agent; |
||
21 | use Tracking\Models\Statistics\Datum; |
||
22 | use Tracking\Models\Statistics\Device; |
||
23 | use Tracking\Models\Statistics\Geoip; |
||
24 | use Tracking\Models\Statistics\Path; |
||
25 | use Tracking\Models\Statistics\Platform; |
||
26 | use Tracking\Models\Statistics\Request; |
||
27 | use Tracking\Models\Statistics\Route as RouteBase; |
||
28 | use Tracking\Services\TrackingService; |
||
29 | |||
30 | class TrackingProvider extends ServiceProvider |
||
31 | { |
||
32 | use ConsoleTools; |
||
33 | |||
34 | public $packageName = 'tracking'; |
||
35 | const pathVendor = 'sierratecnologia/tracking'; |
||
36 | |||
37 | /** |
||
38 | * The commands to be registered. |
||
39 | * |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $commands = [ |
||
43 | MigrateCommand::class => 'command.tracking.statistics.migrate', |
||
44 | PublishCommand::class => 'command.tracking.statistics.publish', |
||
45 | RollbackCommand::class => 'command.tracking.statistics.rollback', |
||
46 | ]; |
||
47 | |||
48 | public static $aliasProviders = [ |
||
49 | 'Horizon' => \Laravel\Horizon\Horizon::class, |
||
50 | |||
51 | 'LaravelAnalytics' => \Spatie\LaravelAnalytics\LaravelAnalyticsFacade::class, |
||
52 | |||
53 | |||
54 | /* |
||
55 | * Log and Monitoring |
||
56 | */ |
||
57 | 'Sentry' => \Sentry\Laravel\Facade::class, |
||
58 | 'Debugbar' => \Barryvdh\Debugbar\Facade::class, |
||
59 | ]; |
||
60 | |||
61 | public static $providers = [ |
||
62 | /** |
||
63 | * Configuracoes |
||
64 | */ |
||
65 | \Tracking\Providers\HorizonServiceProvider::class, |
||
66 | |||
67 | /** |
||
68 | * |
||
69 | */ |
||
70 | |||
71 | \Audit\AuditProvider::class, |
||
72 | |||
73 | /** |
||
74 | * Externos |
||
75 | */ |
||
76 | \Spatie\Analytics\AnalyticsServiceProvider::class, |
||
77 | \Aschmelyun\Larametrics\LarametricsServiceProvider::class, |
||
78 | \Laravel\Horizon\HorizonServiceProvider::class, |
||
79 | ]; |
||
80 | |||
81 | /** |
||
82 | * Rotas do Menu |
||
83 | */ |
||
84 | public static $menuItens = [ |
||
85 | 'Admin' => [ |
||
86 | [ |
||
87 | 'text' => 'Metrics', |
||
88 | 'icon' => 'fas fa-fw fa-search', |
||
89 | 'icon_color' => "blue", |
||
90 | 'label_color' => "success", |
||
91 | 'section' => 'admin', |
||
92 | 'level' => 2, // 0 (Public), 1, 2 (Admin) , 3 (Root) |
||
93 | ], |
||
94 | 'Metrics' => [ |
||
95 | [ |
||
96 | 'text' => 'Analytics', |
||
97 | 'route' => 'rica.tracking.analytics', |
||
98 | 'icon' => 'dashboard', |
||
99 | 'icon_color' => 'blue', |
||
100 | 'label_color' => 'success', |
||
101 | 'section' => 'admin', |
||
102 | 'level' => 2, |
||
103 | // 'access' => \App\Models\Role::$ADMIN |
||
104 | ], |
||
105 | ], |
||
106 | ], |
||
107 | ]; |
||
108 | |||
109 | /** |
||
110 | * Alias the services in the boot. |
||
111 | */ |
||
112 | public function boot(Router $router) |
||
113 | { |
||
114 | // Push middleware to web group |
||
115 | $router->pushMiddlewareToGroup('web', TrackStatistics::class); |
||
116 | $router->pushMiddlewareToGroup('web', Analytics::class); |
||
117 | |||
118 | |||
119 | // Register configs, migrations, etc |
||
120 | $this->registerDirectories(); |
||
121 | |||
122 | // // Wire up model event callbacks even if request is not for admin. Do this |
||
123 | // // after the usingAdmin call so that the callbacks run after models are |
||
124 | // // mutated by Decoy logic. This is important, in particular, so the |
||
125 | // // Validation observer can alter validation rules before the onValidation |
||
126 | // // callback runs. |
||
127 | // $this->app['events']->listen('eloquent.*', |
||
128 | // 'Tracking\Observers\ModelCallbacks'); |
||
129 | // $this->app['events']->listen('tracking::model.*', |
||
130 | // 'Tracking\Observers\ModelCallbacks'); |
||
131 | // // Log model change events after others in case they modified the record |
||
132 | // // before being saved. |
||
133 | // $this->app['events']->listen('eloquent.*', |
||
134 | // 'Tracking\Observers\Changes'); |
||
135 | |||
136 | // // COloquei no register pq nao tava reconhecendo as rotas para o adminlte |
||
137 | // $this->app->booted(function () { |
||
138 | // $this->routes(); |
||
139 | // }); |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * Register the tool's routes. |
||
144 | * |
||
145 | * @return void |
||
146 | */ |
||
147 | protected function routes() |
||
148 | { |
||
149 | if ($this->app->routesAreCached()) { |
||
150 | return; |
||
151 | } |
||
152 | |||
153 | // Route::middleware(['nova', Authorize::class]) |
||
154 | // ->prefix('nova-vendor/beyondcode/tinker-tool') |
||
155 | // ->group(__DIR__.'/../routes/api.php'); |
||
156 | |||
157 | /** |
||
158 | * Transmissor; Routes |
||
159 | */ |
||
160 | $this->loadRoutesForRiCa(__DIR__.'/../routes'); |
||
161 | } |
||
162 | |||
163 | /** |
||
164 | * Register the services. |
||
165 | */ |
||
166 | public function register() |
||
167 | { |
||
168 | |||
169 | |||
170 | // Merge own configs into user configs |
||
171 | $this->mergeConfigFrom($this->getPublishesPath('config/tracking/analytics.php'), 'tracking.analytics'); |
||
172 | $this->mergeConfigFrom($this->getPublishesPath('config/tracking/conf.php'), 'tracking.conf'); |
||
173 | $this->mergeConfigFrom($this->getPublishesPath('config/tracking/statistics.php'), 'tracking.statistics'); |
||
174 | |||
175 | $this->mergeConfigFrom($this->getPublishesPath('config/horizon.php'), 'horizon'); |
||
176 | $this->mergeConfigFrom($this->getPublishesPath('config/larametrics.php'), 'larametrics'); |
||
177 | $this->mergeConfigFrom($this->getPublishesPath('config/stats.php'), 'stats'); |
||
178 | |||
179 | // Register external packages |
||
180 | $this->setProviders(); |
||
181 | $this->routes(); |
||
182 | $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
||
183 | |||
184 | // // Configs |
||
185 | // $this->app->config->set('Tracking.modules.Tracking', include(__DIR__.'/config.php')); |
||
186 | |||
187 | $loader = AliasLoader::getInstance(); |
||
188 | $loader->alias('TrackingService', \Tracking\Facades\TrackingServiceFacade::class); |
||
189 | |||
190 | $this->app->bind( |
||
191 | 'TrackingService', function ($app) { |
||
0 ignored issues
–
show
|
|||
192 | return new TrackingService(); |
||
193 | } |
||
194 | ); |
||
195 | |||
196 | /* |
||
197 | |-------------------------------------------------------------------------- |
||
198 | | statistics |
||
199 | |-------------------------------------------------------------------------- |
||
200 | */ |
||
201 | |||
202 | // Bind eloquent models to IoC container |
||
203 | $this->app->singleton('tracking.statistics.datum', $datumModel = $this->app['config']['tracking.statistics.models.datum']); |
||
204 | $datumModel === Datum::class || $this->app->alias('tracking.statistics.datum', Datum::class); |
||
205 | |||
206 | $this->app->singleton('tracking.statistics.request', $requestModel = $this->app['config']['tracking.statistics.models.request']); |
||
207 | $requestModel === Request::class || $this->app->alias('tracking.statistics.request', Request::class); |
||
208 | |||
209 | $this->app->singleton('tracking.statistics.agent', $agentModel = $this->app['config']['tracking.statistics.models.agent']); |
||
210 | $agentModel === Agent::class || $this->app->alias('tracking.statistics.agent', Agent::class); |
||
211 | |||
212 | $this->app->singleton('tracking.statistics.geoip', $geoipModel = $this->app['config']['tracking.statistics.models.geoip']); |
||
213 | $geoipModel === Geoip::class || $this->app->alias('tracking.statistics.geoip', Geoip::class); |
||
214 | |||
215 | $this->app->singleton('tracking.statistics.route', $routeModel = $this->app['config']['tracking.statistics.models.route']); |
||
216 | $routeModel === RouteBase::class || $this->app->alias('tracking.statistics.route', RouteBase::class); |
||
217 | |||
218 | $this->app->singleton('tracking.statistics.device', $deviceModel = $this->app['config']['tracking.statistics.models.device']); |
||
219 | $deviceModel === Device::class || $this->app->alias('tracking.statistics.device', Device::class); |
||
220 | |||
221 | $this->app->singleton('tracking.statistics.platform', $platformModel = $this->app['config']['tracking.statistics.models.platform']); |
||
222 | $platformModel === Platform::class || $this->app->alias('tracking.statistics.platform', Platform::class); |
||
223 | |||
224 | $this->app->singleton('tracking.statistics.path', $pathModel = $this->app['config']['tracking.statistics.models.path']); |
||
225 | $pathModel === Path::class || $this->app->alias('tracking.statistics.path', Path::class); |
||
226 | |||
227 | // Register console commands |
||
228 | ! $this->app->runningInConsole() || $this->registerCommands(); |
||
229 | } |
||
230 | |||
231 | |||
232 | /** |
||
233 | * Register middlewares |
||
234 | * |
||
235 | * @return void |
||
236 | */ |
||
237 | protected function registerMiddlewares() |
||
238 | { |
||
239 | |||
240 | // Register middleware individually |
||
241 | foreach ([ |
||
242 | 'tracking.auth' => \Tracking\Http\Middleware\Auth::class, |
||
243 | 'tracking.edit-redirect' => \Tracking\Http\Middleware\EditRedirect::class, |
||
244 | 'tracking.guest' => \Tracking\Http\Middleware\Guest::class, |
||
245 | 'tracking.save-redirect' => \Tracking\Http\Middleware\SaveRedirect::class, |
||
246 | ] as $key => $class) { |
||
247 | $this->app['router']->aliasMiddleware($key, $class); |
||
248 | } |
||
249 | |||
250 | // This group is used by public tracking routes |
||
251 | $this->app['router']->middlewareGroup( |
||
252 | 'tracking.public', |
||
253 | [ |
||
254 | 'web', |
||
255 | ] |
||
256 | ); |
||
257 | |||
258 | // The is the starndard auth protected group |
||
259 | $this->app['router']->middlewareGroup( |
||
260 | 'tracking.protected', |
||
261 | [ |
||
262 | 'web', |
||
263 | 'tracking.auth', |
||
264 | 'tracking.save-redirect', |
||
265 | 'tracking.edit-redirect', |
||
266 | ] |
||
267 | ); |
||
268 | |||
269 | // Require a logged in admin session but no CSRF token |
||
270 | $this->app['router']->middlewareGroup( |
||
271 | 'tracking.protected_endpoint', |
||
272 | [ |
||
273 | \App\Http\Middleware\EncryptCookies::class, |
||
274 | \Illuminate\Session\Middleware\StartSession::class, |
||
275 | 'tracking.auth', |
||
276 | ] |
||
277 | ); |
||
278 | |||
279 | // An open endpoint, like used by Zendcoder |
||
280 | $this->app['router']->middlewareGroup( |
||
281 | 'tracking.endpoint', |
||
282 | [ |
||
283 | 'api' |
||
284 | ] |
||
285 | ); |
||
286 | } |
||
287 | /** |
||
288 | * Register configs, migrations, etc |
||
289 | * |
||
290 | * @return void |
||
291 | */ |
||
292 | public function registerDirectories() |
||
293 | { |
||
294 | // @todo Nao usado mais. Avaliar |
||
295 | // // Publish Resources |
||
296 | // ! $this->app->runningInConsole() || $this->publishesConfig('sierratecnologia/laravel-statistics'); |
||
297 | // ! $this->app->runningInConsole() || $this->publishesMigrations('sierratecnologia/laravel-statistics'); |
||
298 | |||
299 | // Publish config files |
||
300 | $this->publishes( |
||
301 | [ |
||
302 | // Paths |
||
303 | $this->getPublishesPath('config/tracking') => config_path('tracking'), |
||
304 | // Files |
||
305 | $this->getPublishesPath('config/horizon.php') => config_path('horizon.php'), |
||
306 | $this->getPublishesPath('config/larametrics.php') => config_path('larametrics.php'), |
||
307 | // $this->getPublishesPath('config/slow-query-logger.php') => config_path('slow-query-logger.php'), |
||
308 | $this->getPublishesPath('config/stats.php') => config_path('stats.php') |
||
309 | ], |
||
310 | ['config', 'sitec', 'sitec-config'] |
||
311 | ); |
||
312 | |||
313 | // Publish tracking css and js to public directory |
||
314 | $this->publishes( |
||
315 | [ |
||
316 | $this->getDistPath() => public_path('assets/tracking'), |
||
317 | $this->getPublishesPath('public/horizon') => public_path('vendor/horizon'), |
||
318 | $this->getPublishesPath('public/larametrics') => public_path('vendor/larametrics') |
||
319 | ], |
||
320 | ['public', 'sitec', 'sitec-public'] |
||
321 | ); |
||
322 | |||
323 | |||
324 | $this->loadViews(); |
||
325 | $this->loadTranslations(); |
||
0 ignored issues
–
show
The call to the method
Tracking\TrackingProvider::loadTranslations() seems un-needed as the method has no side-effects.
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left. Let’s take a look at an example: class User
{
private $email;
public function getEmail()
{
return $this->email;
}
public function setEmail($email)
{
$this->email = $email;
}
}
If we look at the $user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.
On the hand, if we look at the $user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
// instance variable).
![]() |
|||
326 | } |
||
327 | |||
328 | private function loadViews() |
||
329 | { |
||
330 | // View namespace |
||
331 | $viewsPath = $this->getResourcesPath('views'); |
||
332 | $this->loadViewsFrom($viewsPath, 'tracking'); |
||
333 | $this->publishes( |
||
334 | [ |
||
335 | $viewsPath => base_path('resources/views/vendor/tracking'), |
||
336 | ], |
||
337 | ['views', 'sitec', 'sitec-views', 'tracking-views'] |
||
338 | ); |
||
339 | |||
340 | $viewsPath = $this->getResourcesPath('views-larametrics'); |
||
341 | $this->loadViewsFrom($viewsPath, 'larametrics'); |
||
342 | $this->publishes( |
||
343 | [ |
||
344 | $viewsPath => base_path('resources/views/vendor/larametrics'), |
||
345 | ], |
||
346 | ['views', 'sitec', 'sitec-views', 'tracking-views'] |
||
347 | ); |
||
348 | |||
349 | |||
350 | // // Publish lanaguage files |
||
351 | // $this->publishes([ |
||
352 | // $this->getResourcesPath('lang') => resource_path('lang/vendor/tracking') |
||
353 | // ], 'lang'); |
||
354 | |||
355 | // // Load translations |
||
356 | // $this->loadTranslationsFrom($this->getResourcesPath('lang'), 'tracking'); |
||
357 | } |
||
358 | |||
359 | private function loadTranslations() |
||
360 | { |
||
361 | // $translationsPath = $this->getResourcesPath('lang'); |
||
362 | // $this->loadTranslationsFrom($translationsPath, 'tracking'); |
||
363 | // $this->publishes([ |
||
364 | // $translationsPath => resource_path('lang/vendor/tracking'), |
||
365 | // ], 'translations');// @todo ou lang, verificar (invez de translations) |
||
366 | } |
||
367 | |||
368 | /** |
||
369 | * Configs Paths |
||
370 | */ |
||
371 | private function getResourcesPath($folder) |
||
372 | { |
||
373 | return __DIR__.'/../resources/'.$folder; |
||
374 | } |
||
375 | |||
376 | private function getPublishesPath($folder) |
||
377 | { |
||
378 | return __DIR__.'/../publishes/'.$folder; |
||
379 | } |
||
380 | |||
381 | private function getDistPath($folder = '') |
||
382 | { |
||
383 | return __DIR__.'/../dist/'.$folder; |
||
384 | } |
||
385 | |||
386 | /** |
||
387 | * Load Alias and Providers |
||
388 | */ |
||
389 | private function setProviders() |
||
390 | { |
||
391 | $this->setDependencesAlias(); |
||
392 | (new Collection(self::$providers))->map( |
||
393 | function ($provider) { |
||
394 | if (class_exists($provider)) { |
||
395 | $this->app->register($provider); |
||
396 | } |
||
397 | } |
||
398 | ); |
||
399 | } |
||
400 | private function setDependencesAlias() |
||
401 | { |
||
402 | $loader = AliasLoader::getInstance(); |
||
403 | (new Collection(self::$aliasProviders))->map( |
||
404 | function ($class, $alias) use ($loader) { |
||
405 | $loader->alias($alias, $class); |
||
406 | } |
||
407 | ); |
||
408 | } |
||
409 | } |
||
410 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.