@@ -51,21 +51,21 @@ |
||
| 51 | 51 | }) |
| 52 | 52 | ->attachment(function ($attachment) use ($item) { |
| 53 | 53 | $attachment->title($title = config('firewall.notifications.message.uri.title')) |
| 54 | - ->content($item['server']['REQUEST_URI']); |
|
| 54 | + ->content($item['server']['REQUEST_URI']); |
|
| 55 | 55 | }) |
| 56 | 56 | ->attachment(function ($attachment) use ($item) { |
| 57 | 57 | $attachment->title(config('firewall.notifications.message.user_agent.title')) |
| 58 | - ->content($item['userAgent']); |
|
| 58 | + ->content($item['userAgent']); |
|
| 59 | 59 | }) |
| 60 | 60 | ->attachment(function ($attachment) use ($item) { |
| 61 | 61 | $attachment->title(config('firewall.notifications.message.blacklisted.title')) |
| 62 | - ->content($item['isBlacklisted'] ? 'YES' : 'NO'); |
|
| 62 | + ->content($item['isBlacklisted'] ? 'YES' : 'NO'); |
|
| 63 | 63 | }); |
| 64 | 64 | |
| 65 | 65 | if ($item['geoIp']) { |
| 66 | 66 | $message->attachment(function ($attachment) use ($item) { |
| 67 | 67 | $attachment->title(config('firewall.notifications.message.geolocation.title')) |
| 68 | - ->fields($this->getGeolocation($item)); |
|
| 68 | + ->fields($this->getGeolocation($item)); |
|
| 69 | 69 | }); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | config('firewall.notifications.from.icon_emoji') |
| 39 | 39 | ) |
| 40 | 40 | ->content($this->getMessage($item)) |
| 41 | - ->attachment(function ($attachment) use ($item) { |
|
| 41 | + ->attachment(function($attachment) use ($item) { |
|
| 42 | 42 | $attachment->title(config('firewall.notifications.message.request_count.title')) |
| 43 | 43 | ->content( |
| 44 | 44 | sprintf( |
@@ -49,21 +49,21 @@ discard block |
||
| 49 | 49 | ) |
| 50 | 50 | ); |
| 51 | 51 | }) |
| 52 | - ->attachment(function ($attachment) use ($item) { |
|
| 52 | + ->attachment(function($attachment) use ($item) { |
|
| 53 | 53 | $attachment->title($title = config('firewall.notifications.message.uri.title')) |
| 54 | 54 | ->content($item['server']['REQUEST_URI']); |
| 55 | 55 | }) |
| 56 | - ->attachment(function ($attachment) use ($item) { |
|
| 56 | + ->attachment(function($attachment) use ($item) { |
|
| 57 | 57 | $attachment->title(config('firewall.notifications.message.user_agent.title')) |
| 58 | 58 | ->content($item['userAgent']); |
| 59 | 59 | }) |
| 60 | - ->attachment(function ($attachment) use ($item) { |
|
| 60 | + ->attachment(function($attachment) use ($item) { |
|
| 61 | 61 | $attachment->title(config('firewall.notifications.message.blacklisted.title')) |
| 62 | 62 | ->content($item['isBlacklisted'] ? 'YES' : 'NO'); |
| 63 | 63 | }); |
| 64 | 64 | |
| 65 | 65 | if ($item['geoIp']) { |
| 66 | - $message->attachment(function ($attachment) use ($item) { |
|
| 66 | + $message->attachment(function($attachment) use ($item) { |
|
| 67 | 67 | $attachment->title(config('firewall.notifications.message.geolocation.title')) |
| 68 | 68 | ->fields($this->getGeolocation($item)); |
| 69 | 69 | }); |
@@ -116,11 +116,11 @@ |
||
| 116 | 116 | $class = new ReflectionClass(get_class($this->model)); |
| 117 | 117 | |
| 118 | 118 | $model = $class->newInstanceArgs([ |
| 119 | - [ |
|
| 120 | - 'ip_address' => $ip, |
|
| 121 | - 'whitelisted' => $whitelist, |
|
| 122 | - ], |
|
| 123 | - ]); |
|
| 119 | + [ |
|
| 120 | + 'ip_address' => $ip, |
|
| 121 | + 'whitelisted' => $whitelist, |
|
| 122 | + ], |
|
| 123 | + ]); |
|
| 124 | 124 | |
| 125 | 125 | return $model; |
| 126 | 126 | } |
@@ -312,13 +312,13 @@ discard block |
||
| 312 | 312 | private function getNonDatabaseIps() |
| 313 | 313 | { |
| 314 | 314 | return array_merge_recursive( |
| 315 | - array_map(function ($ip) { |
|
| 315 | + array_map(function($ip) { |
|
| 316 | 316 | $ip['whitelisted'] = true; |
| 317 | 317 | |
| 318 | 318 | return $ip; |
| 319 | 319 | }, $this->formatIpArray($this->config->get('whitelist'))), |
| 320 | 320 | |
| 321 | - array_map(function ($ip) { |
|
| 321 | + array_map(function($ip) { |
|
| 322 | 322 | $ip['whitelisted'] = false; |
| 323 | 323 | |
| 324 | 324 | return $ip; |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | { |
| 331 | 331 | $current = $this->getSessionIps(); |
| 332 | 332 | |
| 333 | - $current = $current->filter(function ($model) use ($ip) { |
|
| 333 | + $current = $current->filter(function($model) use ($ip) { |
|
| 334 | 334 | return $model->ip_address !== $ip->ip_address; |
| 335 | 335 | }); |
| 336 | 336 | |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | |
| 389 | 389 | private function formatIpArray($list) |
| 390 | 390 | { |
| 391 | - return array_map(function ($ip) { |
|
| 391 | + return array_map(function($ip) { |
|
| 392 | 392 | return ['ip_address' => $ip]; |
| 393 | 393 | }, $this->makeArrayOfIps($list)); |
| 394 | 394 | } |
@@ -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 | $model = app(config('firewall.notifications.users.model')); |
| 18 | 18 | |
| 19 | 19 | $model->email = $item; |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | private function registerAttackBlocker() |
| 149 | 149 | { |
| 150 | - $this->app->singleton('firewall.attackBlocker', function ($app) { |
|
| 150 | + $this->app->singleton('firewall.attackBlocker', function($app) { |
|
| 151 | 151 | return new AttackBlocker( |
| 152 | 152 | $app['firewall.config'], |
| 153 | 153 | $app['firewall.cache'] |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | private function registerBlacklistCommand() |
| 164 | 164 | { |
| 165 | - $this->app->singleton('firewall.blacklist.command', function ($app) { |
|
| 165 | + $this->app->singleton('firewall.blacklist.command', function($app) { |
|
| 166 | 166 | return new BlacklistCommand(); |
| 167 | 167 | }); |
| 168 | 168 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | private function registerCache() |
| 178 | 178 | { |
| 179 | - $this->app->singleton('firewall.cache', function ($app) { |
|
| 179 | + $this->app->singleton('firewall.cache', function($app) { |
|
| 180 | 180 | return new CacheManager($app); |
| 181 | 181 | }); |
| 182 | 182 | } |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | private function registerClearCommand() |
| 190 | 190 | { |
| 191 | - $this->app->singleton('firewall.clear.command', function ($app) { |
|
| 191 | + $this->app->singleton('firewall.clear.command', function($app) { |
|
| 192 | 192 | return new ClearCommand(); |
| 193 | 193 | }); |
| 194 | 194 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | private function registerDataRepository() |
| 204 | 204 | { |
| 205 | - $this->app->singleton('firewall.dataRepository', function ($app) { |
|
| 205 | + $this->app->singleton('firewall.dataRepository', function($app) { |
|
| 206 | 206 | return new DataRepository( |
| 207 | 207 | new FirewallRepository( |
| 208 | 208 | $this->getFirewallModel(), |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | private function registerFileSystem() |
| 239 | 239 | { |
| 240 | - $this->app->singleton('firewall.fileSystem', function ($app) { |
|
| 240 | + $this->app->singleton('firewall.fileSystem', function($app) { |
|
| 241 | 241 | return new Filesystem(); |
| 242 | 242 | }); |
| 243 | 243 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | private function registerFirewall() |
| 252 | 252 | { |
| 253 | - $this->app->singleton('firewall', function ($app) { |
|
| 253 | + $this->app->singleton('firewall', function($app) { |
|
| 254 | 254 | $app['firewall.loaded'] = true; |
| 255 | 255 | |
| 256 | 256 | $this->firewall = new Firewall( |
@@ -277,18 +277,18 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | private function registerMiddleware() |
| 279 | 279 | { |
| 280 | - $this->app->singleton('firewall.middleware.blacklist', function ($app) { |
|
| 280 | + $this->app->singleton('firewall.middleware.blacklist', function($app) { |
|
| 281 | 281 | return new FirewallBlacklist(new Blacklist()); |
| 282 | 282 | }); |
| 283 | 283 | |
| 284 | - $this->app->singleton('firewall.middleware.whitelist', function ($app) { |
|
| 284 | + $this->app->singleton('firewall.middleware.whitelist', function($app) { |
|
| 285 | 285 | return new FirewallWhitelist(new Whitelist()); |
| 286 | 286 | }); |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | private function registerMigrator() |
| 290 | 290 | { |
| 291 | - $this->app->singleton('firewall.migrator', function ($app) { |
|
| 291 | + $this->app->singleton('firewall.migrator', function($app) { |
|
| 292 | 292 | $connection = $this->getConfig('connection'); |
| 293 | 293 | |
| 294 | 294 | return new Migrator($app['db'], $connection); |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | |
| 299 | 299 | private function registerGeoIp() |
| 300 | 300 | { |
| 301 | - $this->app->singleton('firewall.geoip', function () { |
|
| 301 | + $this->app->singleton('firewall.geoip', function() { |
|
| 302 | 302 | return new GeoIp($this->getConfig('geoip_database_path')); |
| 303 | 303 | }); |
| 304 | 304 | } |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | */ |
| 311 | 311 | private function registerRemoveCommand() |
| 312 | 312 | { |
| 313 | - $this->app->singleton('firewall.remove.command', function ($app) { |
|
| 313 | + $this->app->singleton('firewall.remove.command', function($app) { |
|
| 314 | 314 | return new RemoveCommand(); |
| 315 | 315 | }); |
| 316 | 316 | |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | */ |
| 325 | 325 | private function registerReportCommand() |
| 326 | 326 | { |
| 327 | - $this->app->singleton('firewall.list.command', function ($app) { |
|
| 327 | + $this->app->singleton('firewall.list.command', function($app) { |
|
| 328 | 328 | return new ReportCommand(); |
| 329 | 329 | }); |
| 330 | 330 | |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | private function registerTablesCommand() |
| 335 | 335 | { |
| 336 | - $this->app->singleton('firewall.tables.command', function ($app) { |
|
| 336 | + $this->app->singleton('firewall.tables.command', function($app) { |
|
| 337 | 337 | return new TablesCommand(); |
| 338 | 338 | }); |
| 339 | 339 | |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | */ |
| 346 | 346 | private function registerUpdateGeoIpCommand() |
| 347 | 347 | { |
| 348 | - $this->app->singleton('firewall.updategeoip.command', function ($app) { |
|
| 348 | + $this->app->singleton('firewall.updategeoip.command', function($app) { |
|
| 349 | 349 | return new UpdateGeoIpCommand(); |
| 350 | 350 | }); |
| 351 | 351 | |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | */ |
| 360 | 360 | private function registerWhitelistCommand() |
| 361 | 361 | { |
| 362 | - $this->app->singleton('firewall.whitelist.command', function ($app) { |
|
| 362 | + $this->app->singleton('firewall.whitelist.command', function($app) { |
|
| 363 | 363 | return new WhitelistCommand(); |
| 364 | 364 | }); |
| 365 | 365 | |
@@ -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 | } |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | protected function increment() |
| 240 | 240 | { |
| 241 | - $this->enabledItems->each(function ($index, $type) { |
|
| 241 | + $this->enabledItems->each(function($index, $type) { |
|
| 242 | 242 | $this->save($type, ['requestCount' => $this->record[$type]['requestCount'] + 1]); |
| 243 | 243 | }); |
| 244 | 244 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | protected function isAttack() |
| 252 | 252 | { |
| 253 | - $this->enabledItems->filter(function ($index, $type) { |
|
| 253 | + $this->enabledItems->filter(function($index, $type) { |
|
| 254 | 254 | if (!$this->isWhitelisted($type) && $isAttack = $this->record[$type]['requestCount'] > $this->getMaxRequestCountForType($type)) { |
| 255 | 255 | $this->takeAction($this->record[$type]); |
| 256 | 256 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | */ |
| 310 | 310 | private function loadConfig() |
| 311 | 311 | { |
| 312 | - $this->enabledItems = collect($this->config->get('attack_blocker.enabled'))->filter(function ($item) { |
|
| 312 | + $this->enabledItems = collect($this->config->get('attack_blocker.enabled'))->filter(function($item) { |
|
| 313 | 313 | return $item === true; |
| 314 | 314 | }); |
| 315 | 315 | } |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | */ |
| 338 | 338 | protected function loadRecordItems() |
| 339 | 339 | { |
| 340 | - $this->enabledItems->each(function ($index, $type) { |
|
| 340 | + $this->enabledItems->each(function($index, $type) { |
|
| 341 | 341 | if (is_null($this->record[$type] = $this->cache->get($key = $this->makeKeyForType($type, $this->ipAddress)))) { |
| 342 | 342 | $this->record[$type] = $this->getEmptyRecord($key, $type); |
| 343 | 343 | } |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | if (!$record['wasNotified'] && $this->config->get('notifications.enabled')) { |
| 469 | 469 | $this->save($record['type'], ['wasNotified' => true]); |
| 470 | 470 | |
| 471 | - collect($this->config->get('notifications.channels'))->filter(function ($value, $channel) use ($record) { |
|
| 471 | + collect($this->config->get('notifications.channels'))->filter(function($value, $channel) use ($record) { |
|
| 472 | 472 | try { |
| 473 | 473 | event(new AttackDetected($record, $channel)); |
| 474 | 474 | } catch (\Exception $exception) { |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | { |
| 20 | 20 | $this->builder->create( |
| 21 | 21 | 'firewall', |
| 22 | - function ($table) { |
|
| 22 | + function($table) { |
|
| 23 | 23 | $table->increments('id'); |
| 24 | 24 | |
| 25 | 25 | $table->string('ip_address', 39)->unique()->index(); |