@@ -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(); |
@@ -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 |
@@ -55,21 +55,21 @@ |
||
55 | 55 | }) |
56 | 56 | ->attachment(function ($attachment) use ($item) { |
57 | 57 | $attachment->title($title = config('firewall.notifications.message.uri.title')) |
58 | - ->content($item['server']['REQUEST_URI']); |
|
58 | + ->content($item['server']['REQUEST_URI']); |
|
59 | 59 | }) |
60 | 60 | ->attachment(function ($attachment) use ($item) { |
61 | 61 | $attachment->title(config('firewall.notifications.message.user_agent.title')) |
62 | - ->content($item['userAgent']); |
|
62 | + ->content($item['userAgent']); |
|
63 | 63 | }) |
64 | 64 | ->attachment(function ($attachment) use ($item) { |
65 | 65 | $attachment->title(config('firewall.notifications.message.blacklisted.title')) |
66 | - ->content($item['isBlacklisted'] ? 'YES' : 'NO'); |
|
66 | + ->content($item['isBlacklisted'] ? 'YES' : 'NO'); |
|
67 | 67 | }); |
68 | 68 | |
69 | 69 | if ($item['geoIp']) { |
70 | 70 | $message->attachment(function ($attachment) use ($item) { |
71 | 71 | $attachment->title(config('firewall.notifications.message.geolocation.title')) |
72 | - ->fields($this->makeGeolocation($item)); |
|
72 | + ->fields($this->makeGeolocation($item)); |
|
73 | 73 | }); |
74 | 74 | } |
75 | 75 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | config('firewall.notifications.from.icon_emoji') |
43 | 43 | ) |
44 | 44 | ->content($this->getMessage($item)) |
45 | - ->attachment(function ($attachment) use ($item) { |
|
45 | + ->attachment(function($attachment) use ($item) { |
|
46 | 46 | $attachment->title(config('firewall.notifications.message.request_count.title')) |
47 | 47 | ->content( |
48 | 48 | sprintf( |
@@ -53,21 +53,21 @@ discard block |
||
53 | 53 | ) |
54 | 54 | ); |
55 | 55 | }) |
56 | - ->attachment(function ($attachment) use ($item) { |
|
56 | + ->attachment(function($attachment) use ($item) { |
|
57 | 57 | $attachment->title($title = config('firewall.notifications.message.uri.title')) |
58 | 58 | ->content($item['server']['REQUEST_URI']); |
59 | 59 | }) |
60 | - ->attachment(function ($attachment) use ($item) { |
|
60 | + ->attachment(function($attachment) use ($item) { |
|
61 | 61 | $attachment->title(config('firewall.notifications.message.user_agent.title')) |
62 | 62 | ->content($item['userAgent']); |
63 | 63 | }) |
64 | - ->attachment(function ($attachment) use ($item) { |
|
64 | + ->attachment(function($attachment) use ($item) { |
|
65 | 65 | $attachment->title(config('firewall.notifications.message.blacklisted.title')) |
66 | 66 | ->content($item['isBlacklisted'] ? 'YES' : 'NO'); |
67 | 67 | }); |
68 | 68 | |
69 | 69 | if ($item['geoIp']) { |
70 | - $message->attachment(function ($attachment) use ($item) { |
|
70 | + $message->attachment(function($attachment) use ($item) { |
|
71 | 71 | $attachment->title(config('firewall.notifications.message.geolocation.title')) |
72 | 72 | ->fields($this->makeGeolocation($item)); |
73 | 73 | }); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | protected function checkExpiration() |
124 | 124 | { |
125 | - $this->enabledItems->each(function ($index, $type) { |
|
125 | + $this->enabledItems->each(function($index, $type) { |
|
126 | 126 | if (($this->record[$type]['lastRequestAt']->diffInSeconds(Carbon::now())) <= ($this->getMaxSecondsForType($type))) { |
127 | 127 | return $this->record; |
128 | 128 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | protected function increment() |
242 | 242 | { |
243 | - $this->enabledItems->each(function ($index, $type) { |
|
243 | + $this->enabledItems->each(function($index, $type) { |
|
244 | 244 | $this->save($type, ['requestCount' => $this->record[$type]['requestCount'] + 1]); |
245 | 245 | }); |
246 | 246 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | */ |
253 | 253 | protected function isAttack() |
254 | 254 | { |
255 | - return $this->enabledItems->filter(function ($index, $type) { |
|
255 | + return $this->enabledItems->filter(function($index, $type) { |
|
256 | 256 | if (!$this->isWhitelisted($type) && $this->record[$type]['requestCount'] > $this->getMaxRequestCountForType($type)) { |
257 | 257 | $this->takeAction($this->record[$type]); |
258 | 258 | |
@@ -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 | } |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | */ |
340 | 340 | protected function loadRecordItems() |
341 | 341 | { |
342 | - $this->enabledItems->each(function ($index, $type) { |
|
342 | + $this->enabledItems->each(function($index, $type) { |
|
343 | 343 | if (is_null($this->record[$type] = $this->cache()->get($key = $this->makeKeyForType($type, $this->ipAddress)))) { |
344 | 344 | $this->record[$type] = $this->getEmptyRecord($key, $type); |
345 | 345 | } |
@@ -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) { |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | private function getNonDatabaseIps() |
34 | 34 | { |
35 | 35 | return array_merge_recursive( |
36 | - array_map(function ($ip) { |
|
36 | + array_map(function($ip) { |
|
37 | 37 | $ip['whitelisted'] = true; |
38 | 38 | |
39 | 39 | return $ip; |
40 | 40 | }, $this->formatIpArray($this->config()->get('whitelist'))), |
41 | 41 | |
42 | - array_map(function ($ip) { |
|
42 | + array_map(function($ip) { |
|
43 | 43 | $ip['whitelisted'] = false; |
44 | 44 | |
45 | 45 | return $ip; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | private function formatIpArray($list) |
162 | 162 | { |
163 | - return array_map(function ($ip) { |
|
163 | + return array_map(function($ip) { |
|
164 | 164 | return ['ip_address' => $ip]; |
165 | 165 | }, $this->makeArrayOfIps($list)); |
166 | 166 | } |
@@ -429,8 +429,7 @@ discard block |
||
429 | 429 | public function addToProperList($whitelist, $ip) |
430 | 430 | { |
431 | 431 | $this->config()->get('use_database') ? |
432 | - $this->addToDatabaseList($whitelist, $ip) : |
|
433 | - $this->addToArrayList($whitelist, $ip); |
|
432 | + $this->addToDatabaseList($whitelist, $ip) : $this->addToArrayList($whitelist, $ip); |
|
434 | 433 | } |
435 | 434 | |
436 | 435 | /** |
@@ -443,8 +442,7 @@ discard block |
||
443 | 442 | public function delete($ipAddress) |
444 | 443 | { |
445 | 444 | $this->config()->get('use_database') ? |
446 | - $this->removeFromDatabaseList($ipAddress) : |
|
447 | - $this->removeFromArrayList($ipAddress); |
|
445 | + $this->removeFromDatabaseList($ipAddress) : $this->removeFromArrayList($ipAddress); |
|
448 | 446 | } |
449 | 447 | |
450 | 448 | /** |
@@ -50,7 +50,7 @@ |
||
50 | 50 | { |
51 | 51 | $country = $this->makeCountryFromString($country); |
52 | 52 | |
53 | - return $this->ipList()->all()->filter(function ($item) use ($country) { |
|
53 | + return $this->ipList()->all()->filter(function($item) use ($country) { |
|
54 | 54 | return $item['ip_address'] == $country || |
55 | 55 | $this->makeCountryFromString($this->getCountryFromIp($item['ip_address'])) == $country; |
56 | 56 | }); |
@@ -33,8 +33,8 @@ |
||
33 | 33 | */ |
34 | 34 | public function addMessage($message) |
35 | 35 | { |
36 | - collect((array) $message)->each(function ($item) { |
|
37 | - collect($item)->flatten()->each(function ($flattened) { |
|
36 | + collect((array) $message)->each(function($item) { |
|
37 | + collect($item)->flatten()->each(function($flattened) { |
|
38 | 38 | $this->messageList->push($flattened); |
39 | 39 | }); |
40 | 40 | }); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | private function registerAttackBlocker() |
144 | 144 | { |
145 | - $this->app->singleton('firewall.attackBlocker', function ($app) { |
|
145 | + $this->app->singleton('firewall.attackBlocker', function($app) { |
|
146 | 146 | return new AttackBlocker(); |
147 | 147 | }); |
148 | 148 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | */ |
154 | 154 | private function registerCountriesRepository() |
155 | 155 | { |
156 | - $this->app->singleton('firewall.countries', function ($app) { |
|
156 | + $this->app->singleton('firewall.countries', function($app) { |
|
157 | 157 | return new Countries(); |
158 | 158 | }); |
159 | 159 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | private function registerBlacklistCommand() |
167 | 167 | { |
168 | - $this->app->singleton('firewall.blacklist.command', function ($app) { |
|
168 | + $this->app->singleton('firewall.blacklist.command', function($app) { |
|
169 | 169 | return new BlacklistCommand(); |
170 | 170 | }); |
171 | 171 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | private function registerCache() |
181 | 181 | { |
182 | - $this->app->singleton('firewall.cache', function ($app) { |
|
182 | + $this->app->singleton('firewall.cache', function($app) { |
|
183 | 183 | return new Cache(app('cache')); |
184 | 184 | }); |
185 | 185 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | private function registerClearCommand() |
193 | 193 | { |
194 | - $this->app->singleton('firewall.clear.command', function ($app) { |
|
194 | + $this->app->singleton('firewall.clear.command', function($app) { |
|
195 | 195 | return new ClearCommand(); |
196 | 196 | }); |
197 | 197 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | */ |
206 | 206 | private function registerDataRepository() |
207 | 207 | { |
208 | - $this->app->singleton('firewall.datarepository', function ($app) { |
|
208 | + $this->app->singleton('firewall.datarepository', function($app) { |
|
209 | 209 | return new DataRepository(); |
210 | 210 | }); |
211 | 211 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | private function registerFileSystem() |
227 | 227 | { |
228 | - $this->app->singleton('firewall.filesystem', function ($app) { |
|
228 | + $this->app->singleton('firewall.filesystem', function($app) { |
|
229 | 229 | return new Filesystem(); |
230 | 230 | }); |
231 | 231 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | private function registerFirewall() |
240 | 240 | { |
241 | - $this->app->singleton('firewall', function ($app) { |
|
241 | + $this->app->singleton('firewall', function($app) { |
|
242 | 242 | $app['firewall.loaded'] = true; |
243 | 243 | |
244 | 244 | $this->firewall = new Firewall( |
@@ -257,14 +257,14 @@ discard block |
||
257 | 257 | |
258 | 258 | private function registerIpAddress() |
259 | 259 | { |
260 | - $this->app->singleton('firewall.ipaddress', function ($app) { |
|
260 | + $this->app->singleton('firewall.ipaddress', function($app) { |
|
261 | 261 | return new IpAddress(); |
262 | 262 | }); |
263 | 263 | } |
264 | 264 | |
265 | 265 | private function registerIpList() |
266 | 266 | { |
267 | - $this->app->singleton('firewall.iplist', function ($app) { |
|
267 | + $this->app->singleton('firewall.iplist', function($app) { |
|
268 | 268 | return new IpList($this->getFirewallModel()); |
269 | 269 | }); |
270 | 270 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | */ |
275 | 275 | private function registerMessageRepository() |
276 | 276 | { |
277 | - $this->app->singleton('firewall.messages', function ($app) { |
|
277 | + $this->app->singleton('firewall.messages', function($app) { |
|
278 | 278 | return new Message(); |
279 | 279 | }); |
280 | 280 | } |
@@ -286,11 +286,11 @@ discard block |
||
286 | 286 | */ |
287 | 287 | private function registerMiddleware() |
288 | 288 | { |
289 | - $this->app->singleton('firewall.middleware.blacklist', function ($app) { |
|
289 | + $this->app->singleton('firewall.middleware.blacklist', function($app) { |
|
290 | 290 | return new FirewallBlacklist(new Blacklist()); |
291 | 291 | }); |
292 | 292 | |
293 | - $this->app->singleton('firewall.middleware.whitelist', function ($app) { |
|
293 | + $this->app->singleton('firewall.middleware.whitelist', function($app) { |
|
294 | 294 | return new FirewallWhitelist(new Whitelist()); |
295 | 295 | }); |
296 | 296 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | private function registerGeoIp() |
304 | 304 | { |
305 | - $this->app->singleton('firewall.geoip', function () { |
|
305 | + $this->app->singleton('firewall.geoip', function() { |
|
306 | 306 | return new GeoIp($this->getConfig('geoip_database_path')); |
307 | 307 | }); |
308 | 308 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | */ |
315 | 315 | private function registerRemoveCommand() |
316 | 316 | { |
317 | - $this->app->singleton('firewall.remove.command', function ($app) { |
|
317 | + $this->app->singleton('firewall.remove.command', function($app) { |
|
318 | 318 | return new RemoveCommand(); |
319 | 319 | }); |
320 | 320 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | */ |
329 | 329 | private function registerReportCommand() |
330 | 330 | { |
331 | - $this->app->singleton('firewall.list.command', function ($app) { |
|
331 | + $this->app->singleton('firewall.list.command', function($app) { |
|
332 | 332 | return new ReportCommand(); |
333 | 333 | }); |
334 | 334 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | */ |
341 | 341 | private function registerUpdateGeoIpCommand() |
342 | 342 | { |
343 | - $this->app->singleton('firewall.updategeoip.command', function ($app) { |
|
343 | + $this->app->singleton('firewall.updategeoip.command', function($app) { |
|
344 | 344 | return new UpdateGeoIpCommand(); |
345 | 345 | }); |
346 | 346 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | */ |
355 | 355 | private function registerWhitelistCommand() |
356 | 356 | { |
357 | - $this->app->singleton('firewall.whitelist.command', function ($app) { |
|
357 | + $this->app->singleton('firewall.whitelist.command', function($app) { |
|
358 | 358 | return new WhitelistCommand(); |
359 | 359 | }); |
360 | 360 |