@@ -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 | }); |
@@ -23,8 +23,8 @@ |
||
23 | 23 | */ |
24 | 24 | public function addMessage($message) |
25 | 25 | { |
26 | - collect((array) $message)->each(function ($item) { |
|
27 | - collect($item)->flatten()->each(function ($flattened) { |
|
26 | + collect((array) $message)->each(function($item) { |
|
27 | + collect($item)->flatten()->each(function($flattened) { |
|
28 | 28 | $this->messages->push($flattened); |
29 | 29 | }); |
30 | 30 | }); |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('firewall', function (Blueprint $table) { |
|
16 | + Schema::create('firewall', function(Blueprint $table) { |
|
17 | 17 | $table->increments('id'); |
18 | 18 | |
19 | 19 | $table->string('ip_address', 39)->unique()->index(); |
@@ -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) { |
@@ -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 |
@@ -237,8 +237,7 @@ discard block |
||
237 | 237 | public function addToProperList($whitelist, $ip) |
238 | 238 | { |
239 | 239 | $this->config->get('use_database') ? |
240 | - $this->addToDatabaseList($whitelist, $ip) : |
|
241 | - $this->addToArrayList($whitelist, $ip); |
|
240 | + $this->addToDatabaseList($whitelist, $ip) : $this->addToArrayList($whitelist, $ip); |
|
242 | 241 | } |
243 | 242 | |
244 | 243 | /** |
@@ -250,8 +249,7 @@ discard block |
||
250 | 249 | public function delete($ipAddress) |
251 | 250 | { |
252 | 251 | $this->config->get('use_database') ? |
253 | - $this->removeFromDatabaseList($ipAddress) : |
|
254 | - $this->removeFromArrayList($ipAddress); |
|
252 | + $this->removeFromDatabaseList($ipAddress) : $this->removeFromArrayList($ipAddress); |
|
255 | 253 | } |
256 | 254 | |
257 | 255 | public function cacheKey($ip) |
@@ -325,7 +323,7 @@ discard block |
||
325 | 323 | { |
326 | 324 | $country = $this->makeCountryFromString($country); |
327 | 325 | |
328 | - return $this->all()->filter(function ($item) use ($country) { |
|
326 | + return $this->all()->filter(function($item) use ($country) { |
|
329 | 327 | return $item['ip_address'] == $country || |
330 | 328 | $this->makeCountryFromString($this->getCountryFromIp($item['ip_address'])) == $country; |
331 | 329 | }); |
@@ -375,13 +373,13 @@ discard block |
||
375 | 373 | private function getNonDatabaseIps() |
376 | 374 | { |
377 | 375 | return array_merge_recursive( |
378 | - array_map(function ($ip) { |
|
376 | + array_map(function($ip) { |
|
379 | 377 | $ip['whitelisted'] = true; |
380 | 378 | |
381 | 379 | return $ip; |
382 | 380 | }, $this->formatIpArray($this->config->get('whitelist'))), |
383 | 381 | |
384 | - array_map(function ($ip) { |
|
382 | + array_map(function($ip) { |
|
385 | 383 | $ip['whitelisted'] = false; |
386 | 384 | |
387 | 385 | return $ip; |
@@ -497,7 +495,7 @@ discard block |
||
497 | 495 | */ |
498 | 496 | private function formatIpArray($list) |
499 | 497 | { |
500 | - return array_map(function ($ip) { |
|
498 | + return array_map(function($ip) { |
|
501 | 499 | return ['ip_address' => $ip]; |
502 | 500 | }, $this->makeArrayOfIps($list)); |
503 | 501 | } |