@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | /** |
232 | 232 | * Check for attacks. |
233 | 233 | * |
234 | - * @param $ipAddress |
|
234 | + * @param null|string $ipAddress |
|
235 | 235 | * |
236 | 236 | * @return bool |
237 | 237 | */ |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | /** |
368 | 368 | * Make the cache key to record countries. |
369 | 369 | * |
370 | - * @param $ipAddress |
|
370 | + * @param string $ipAddress |
|
371 | 371 | * |
372 | 372 | * @return string|null |
373 | 373 | */ |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | protected function checkExpiration() |
121 | 121 | { |
122 | - $this->enabledItems->each(function ($index, $type) { |
|
122 | + $this->enabledItems->each(function($index, $type) { |
|
123 | 123 | if (($this->now()->diffInSeconds($this->record[$type]['lastRequestAt'])) <= ($this->getMaxSecondsForType($type))) { |
124 | 124 | return $this->record; |
125 | 125 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | protected function increment() |
209 | 209 | { |
210 | - $this->enabledItems->each(function ($index, $type) { |
|
210 | + $this->enabledItems->each(function($index, $type) { |
|
211 | 211 | $this->save($type, ['requestCount' => $this->record[$type]['requestCount'] + 1]); |
212 | 212 | }); |
213 | 213 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | protected function isAttack() |
221 | 221 | { |
222 | - return $this->enabledItems->filter(function ($index, $type) { |
|
222 | + return $this->enabledItems->filter(function($index, $type) { |
|
223 | 223 | if (!$this->isWhitelisted($type) && $this->record[$type]['requestCount'] > $this->getMaxRequestCountForType($type)) { |
224 | 224 | $this->takeAction($this->record[$type]); |
225 | 225 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | */ |
277 | 277 | private function loadConfig() |
278 | 278 | { |
279 | - $this->enabledItems = collect($this->config()->get('attack_blocker.enabled'))->filter(function ($item) { |
|
279 | + $this->enabledItems = collect($this->config()->get('attack_blocker.enabled'))->filter(function($item) { |
|
280 | 280 | return $item === true; |
281 | 281 | }); |
282 | 282 | } |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | */ |
307 | 307 | protected function loadRecordItems() |
308 | 308 | { |
309 | - $this->enabledItems->each(function ($index, $type) { |
|
309 | + $this->enabledItems->each(function($index, $type) { |
|
310 | 310 | if (is_null($this->record[$type] = $this->cache()->get($key = $this->makeKeyForType($type, $this->ipAddress)))) { |
311 | 311 | $this->record[$type] = $this->getEmptyRecord($key, $type); |
312 | 312 | } |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | if (!$record['wasNotified'] && $this->config()->get('notifications.enabled')) { |
460 | 460 | $this->save($record['type'], ['wasNotified' => true]); |
461 | 461 | |
462 | - collect($this->config()->get('notifications.channels'))->filter(function ($value, $channel) use ($record) { |
|
462 | + collect($this->config()->get('notifications.channels'))->filter(function($value, $channel) use ($record) { |
|
463 | 463 | event(new AttackDetected($record, $channel)); |
464 | 464 | }); |
465 | 465 | } |
@@ -5,7 +5,6 @@ |
||
5 | 5 | use Carbon\Carbon; |
6 | 6 | use PragmaRX\Firewall\Events\AttackDetected; |
7 | 7 | use PragmaRX\Firewall\Firewall; |
8 | -use PragmaRX\Firewall\Repositories\Cache\Cache; |
|
9 | 8 | |
10 | 9 | class AttackBlocker |
11 | 10 | { |