@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | protected function checkExpiration() |
| 138 | 138 | { |
| 139 | - $this->enabledItems->each(function ($index, $type) { |
|
| 139 | + $this->enabledItems->each(function($index, $type) { |
|
| 140 | 140 | if (($this->record[$type]['lastRequestAt']->diffInSeconds(Carbon::now())) <= ($this->getMaxSecondsForType($type))) { |
| 141 | 141 | return $this->record; |
| 142 | 142 | } |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | protected function increment() |
| 253 | 253 | { |
| 254 | - $this->enabledItems->each(function ($index, $type) { |
|
| 254 | + $this->enabledItems->each(function($index, $type) { |
|
| 255 | 255 | $this->save($type, ['requestCount' => $this->record[$type]['requestCount'] + 1]); |
| 256 | 256 | }); |
| 257 | 257 | } |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | */ |
| 264 | 264 | protected function isAttack() |
| 265 | 265 | { |
| 266 | - return $this->enabledItems->filter(function ($index, $type) { |
|
| 266 | + return $this->enabledItems->filter(function($index, $type) { |
|
| 267 | 267 | if (!$this->isWhitelisted($type) && $isAttack = $this->record[$type]['requestCount'] > $this->getMaxRequestCountForType($type)) { |
| 268 | 268 | // $this->takeAction($this->record[$type]); |
| 269 | 269 | |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | */ |
| 317 | 317 | private function loadConfig() |
| 318 | 318 | { |
| 319 | - $this->enabledItems = collect($this->config->get('attack_blocker.enabled'))->filter(function ($item) { |
|
| 319 | + $this->enabledItems = collect($this->config->get('attack_blocker.enabled'))->filter(function($item) { |
|
| 320 | 320 | return $item === true; |
| 321 | 321 | }); |
| 322 | 322 | } |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | */ |
| 345 | 345 | protected function loadRecordItems() |
| 346 | 346 | { |
| 347 | - $this->enabledItems->each(function ($index, $type) { |
|
| 347 | + $this->enabledItems->each(function($index, $type) { |
|
| 348 | 348 | if (is_null($this->record[$type] = $this->cache->get($key = $this->makeKeyForType($type, $this->ipAddress)))) { |
| 349 | 349 | $this->record[$type] = $this->getEmptyRecord($key, $type); |
| 350 | 350 | } |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | if (!$record['wasNotified'] && $this->config->get('notifications.enabled')) { |
| 481 | 481 | $this->save($record['type'], ['wasNotified' => true]); |
| 482 | 482 | |
| 483 | - collect($this->config->get('notifications.channels'))->filter(function ($value, $channel) use ($record) { |
|
| 483 | + collect($this->config->get('notifications.channels'))->filter(function($value, $channel) use ($record) { |
|
| 484 | 484 | try { |
| 485 | 485 | event(new AttackDetected($record, $channel)); |
| 486 | 486 | } catch (\Exception $exception) { |
@@ -385,13 +385,13 @@ discard block |
||
| 385 | 385 | private function getNonDatabaseIps() |
| 386 | 386 | { |
| 387 | 387 | return array_merge_recursive( |
| 388 | - array_map(function ($ip) { |
|
| 388 | + array_map(function($ip) { |
|
| 389 | 389 | $ip['whitelisted'] = true; |
| 390 | 390 | |
| 391 | 391 | return $ip; |
| 392 | 392 | }, $this->formatIpArray($this->config->get('whitelist'))), |
| 393 | 393 | |
| 394 | - array_map(function ($ip) { |
|
| 394 | + array_map(function($ip) { |
|
| 395 | 395 | $ip['whitelisted'] = false; |
| 396 | 396 | |
| 397 | 397 | return $ip; |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | |
| 476 | 476 | private function formatIpArray($list) |
| 477 | 477 | { |
| 478 | - return array_map(function ($ip) { |
|
| 478 | + return array_map(function($ip) { |
|
| 479 | 479 | return ['ip_address' => $ip]; |
| 480 | 480 | }, $this->makeArrayOfIps($list)); |
| 481 | 481 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | private function getNotifiableUsers() |
| 15 | 15 | { |
| 16 | - return collect(config('firewall.notifications.users.emails'))->map(function ($item) { |
|
| 16 | + return collect(config('firewall.notifications.users.emails'))->map(function($item) { |
|
| 17 | 17 | if (class_exists($class = config('firewall.notifications.users.model'))) { |
| 18 | 18 | $model = app($class); |
| 19 | 19 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | private function registerAttackBlocker() |
| 136 | 136 | { |
| 137 | - $this->app->singleton('firewall.attackBlocker', function ($app) { |
|
| 137 | + $this->app->singleton('firewall.attackBlocker', function($app) { |
|
| 138 | 138 | return new AttackBlocker( |
| 139 | 139 | $app['firewall.config'], |
| 140 | 140 | $app['firewall.cache'] |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | private function registerBlacklistCommand() |
| 151 | 151 | { |
| 152 | - $this->app->singleton('firewall.blacklist.command', function ($app) { |
|
| 152 | + $this->app->singleton('firewall.blacklist.command', function($app) { |
|
| 153 | 153 | return new BlacklistCommand(); |
| 154 | 154 | }); |
| 155 | 155 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | private function registerCache() |
| 165 | 165 | { |
| 166 | - $this->app->singleton('firewall.cache', function ($app) { |
|
| 166 | + $this->app->singleton('firewall.cache', function($app) { |
|
| 167 | 167 | return new CacheManager($app); |
| 168 | 168 | }); |
| 169 | 169 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | private function registerClearCommand() |
| 177 | 177 | { |
| 178 | - $this->app->singleton('firewall.clear.command', function ($app) { |
|
| 178 | + $this->app->singleton('firewall.clear.command', function($app) { |
|
| 179 | 179 | return new ClearCommand(); |
| 180 | 180 | }); |
| 181 | 181 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | private function registerDataRepository() |
| 191 | 191 | { |
| 192 | - $this->app->singleton('firewall.dataRepository', function ($app) { |
|
| 192 | + $this->app->singleton('firewall.dataRepository', function($app) { |
|
| 193 | 193 | return new DataRepository( |
| 194 | 194 | $this->getFirewallModel(), |
| 195 | 195 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | private function registerFileSystem() |
| 223 | 223 | { |
| 224 | - $this->app->singleton('firewall.fileSystem', function ($app) { |
|
| 224 | + $this->app->singleton('firewall.fileSystem', function($app) { |
|
| 225 | 225 | return new Filesystem(); |
| 226 | 226 | }); |
| 227 | 227 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | private function registerFirewall() |
| 236 | 236 | { |
| 237 | - $this->app->singleton('firewall', function ($app) { |
|
| 237 | + $this->app->singleton('firewall', function($app) { |
|
| 238 | 238 | $app['firewall.loaded'] = true; |
| 239 | 239 | |
| 240 | 240 | $this->firewall = new Firewall( |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | private function registerMessageRepository() |
| 261 | 261 | { |
| 262 | - $this->app->singleton('firewall.message', function ($app) { |
|
| 262 | + $this->app->singleton('firewall.message', function($app) { |
|
| 263 | 263 | return new Message(); |
| 264 | 264 | }); |
| 265 | 265 | } |
@@ -271,11 +271,11 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | private function registerMiddleware() |
| 273 | 273 | { |
| 274 | - $this->app->singleton('firewall.middleware.blacklist', function ($app) { |
|
| 274 | + $this->app->singleton('firewall.middleware.blacklist', function($app) { |
|
| 275 | 275 | return new FirewallBlacklist(new Blacklist()); |
| 276 | 276 | }); |
| 277 | 277 | |
| 278 | - $this->app->singleton('firewall.middleware.whitelist', function ($app) { |
|
| 278 | + $this->app->singleton('firewall.middleware.whitelist', function($app) { |
|
| 279 | 279 | return new FirewallWhitelist(new Whitelist()); |
| 280 | 280 | }); |
| 281 | 281 | } |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | |
| 288 | 288 | private function registerGeoIp() |
| 289 | 289 | { |
| 290 | - $this->app->singleton('firewall.geoip', function () { |
|
| 290 | + $this->app->singleton('firewall.geoip', function() { |
|
| 291 | 291 | return new GeoIp($this->getConfig('geoip_database_path')); |
| 292 | 292 | }); |
| 293 | 293 | } |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | */ |
| 300 | 300 | private function registerRemoveCommand() |
| 301 | 301 | { |
| 302 | - $this->app->singleton('firewall.remove.command', function ($app) { |
|
| 302 | + $this->app->singleton('firewall.remove.command', function($app) { |
|
| 303 | 303 | return new RemoveCommand(); |
| 304 | 304 | }); |
| 305 | 305 | |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | private function registerReportCommand() |
| 315 | 315 | { |
| 316 | - $this->app->singleton('firewall.list.command', function ($app) { |
|
| 316 | + $this->app->singleton('firewall.list.command', function($app) { |
|
| 317 | 317 | return new ReportCommand(); |
| 318 | 318 | }); |
| 319 | 319 | |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | private function registerUpdateGeoIpCommand() |
| 327 | 327 | { |
| 328 | - $this->app->singleton('firewall.updategeoip.command', function ($app) { |
|
| 328 | + $this->app->singleton('firewall.updategeoip.command', function($app) { |
|
| 329 | 329 | return new UpdateGeoIpCommand(); |
| 330 | 330 | }); |
| 331 | 331 | |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | */ |
| 340 | 340 | private function registerWhitelistCommand() |
| 341 | 341 | { |
| 342 | - $this->app->singleton('firewall.whitelist.command', function ($app) { |
|
| 342 | + $this->app->singleton('firewall.whitelist.command', function($app) { |
|
| 343 | 343 | return new WhitelistCommand(); |
| 344 | 344 | }); |
| 345 | 345 | |