Completed
Push — master ( fb5480...789cd5 )
by Antonio Carlos
02:45
created
src/migrations/2014_02_01_311070_create_firewall_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
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();
Please login to merge, or discard this patch.
src/Listeners/NotifyAdmins.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Notifications/Channels/Slack.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
             });
Please login to merge, or discard this patch.
src/Repositories/DataRepository.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
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
         });
Please login to merge, or discard this patch.
src/Repositories/Message.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,8 +33,8 @@
 block discarded – undo
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
         });
Please login to merge, or discard this patch.
src/Repositories/IpList.php 1 patch
Spacing   +5 added lines, -7 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
     private function getNonDatabaseIps()
35 35
     {
36 36
         return array_merge_recursive(
37
-            array_map(function ($ip) {
37
+            array_map(function($ip) {
38 38
                 $ip['whitelisted'] = true;
39 39
 
40 40
                 return $ip;
41 41
             }, $this->formatIpArray($this->config()->get('whitelist'))),
42 42
 
43
-            array_map(function ($ip) {
43
+            array_map(function($ip) {
44 44
                 $ip['whitelisted'] = false;
45 45
 
46 46
                 return $ip;
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      */
162 162
     private function formatIpArray($list)
163 163
     {
164
-        return array_map(function ($ip) {
164
+        return array_map(function($ip) {
165 165
             return ['ip_address' => $ip];
166 166
         }, $this->makeArrayOfIps($list));
167 167
     }
@@ -426,8 +426,7 @@  discard block
 block discarded – undo
426 426
     public function addToProperList($whitelist, $ip)
427 427
     {
428 428
         $this->config()->get('use_database') ?
429
-            $this->addToDatabaseList($whitelist, $ip) :
430
-            $this->addToArrayList($whitelist, $ip);
429
+            $this->addToDatabaseList($whitelist, $ip) : $this->addToArrayList($whitelist, $ip);
431 430
     }
432 431
 
433 432
     /**
@@ -440,8 +439,7 @@  discard block
 block discarded – undo
440 439
     public function delete($ip)
441 440
     {
442 441
         $this->config()->get('use_database') ?
443
-            $this->removeFromDatabaseList($ip) :
444
-            $this->removeFromArrayList($ip);
442
+            $this->removeFromDatabaseList($ip) : $this->removeFromArrayList($ip);
445 443
     }
446 444
 
447 445
     /**
Please login to merge, or discard this patch.
src/Support/AttackBlocker.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     protected function checkExpiration()
111 111
     {
112
-        $this->getEnabledItems()->each(function ($index, $type) {
112
+        $this->getEnabledItems()->each(function($index, $type) {
113 113
             if (($this->now()->diffInSeconds($this->record[$type]['lastRequestAt'])) <= ($this->getMaxSecondsForType($type))) {
114 114
                 return $this->record;
115 115
             }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
      */
212 212
     protected function increment()
213 213
     {
214
-        $this->getEnabledItems()->each(function ($index, $type) {
214
+        $this->getEnabledItems()->each(function($index, $type) {
215 215
             $this->save($type, ['requestCount' => $this->record[$type]['requestCount'] + 1]);
216 216
         });
217 217
     }
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      */
224 224
     protected function isAttack()
225 225
     {
226
-        return $this->getEnabledItems()->filter(function ($index, $type) {
226
+        return $this->getEnabledItems()->filter(function($index, $type) {
227 227
             if (!$this->isWhitelisted($type) && $this->record[$type]['requestCount'] > $this->getMaxRequestCountForType($type)) {
228 228
                 $this->takeAction($this->record[$type]);
229 229
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
      */
281 281
     private function loadConfig()
282 282
     {
283
-        $this->enabledItems = collect($this->config()->get('attack_blocker.enabled'))->filter(function ($item) {
283
+        $this->enabledItems = collect($this->config()->get('attack_blocker.enabled'))->filter(function($item) {
284 284
             return $item === true;
285 285
         });
286 286
     }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
      */
311 311
     protected function loadRecordItems()
312 312
     {
313
-        $this->getEnabledItems()->each(function ($index, $type) {
313
+        $this->getEnabledItems()->each(function($index, $type) {
314 314
             if (is_null($this->record[$type] = $this->cache()->get($key = $this->makeKeyForType($type, $this->ipAddress)))) {
315 315
                 $this->record[$type] = $this->getEmptyRecord($key, $type);
316 316
             }
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
         if (!$record['wasNotified'] && $this->config()->get('notifications.enabled')) {
464 464
             $this->save($record['type'], ['wasNotified' => true]);
465 465
 
466
-            collect($this->config()->get('notifications.channels'))->filter(function ($value, $channel) use ($record) {
466
+            collect($this->config()->get('notifications.channels'))->filter(function($value, $channel) use ($record) {
467 467
                 event(new AttackDetected($record, $channel));
468 468
             });
469 469
         }
Please login to merge, or discard this patch.
src/Vendor/Laravel/ServiceProvider.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     private function registerAttackBlocker()
126 126
     {
127
-        $this->app->singleton('firewall.attackBlocker', function () {
127
+        $this->app->singleton('firewall.attackBlocker', function() {
128 128
             return new AttackBlocker();
129 129
         });
130 130
     }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      */
135 135
     private function registerCountriesRepository()
136 136
     {
137
-        $this->app->singleton('firewall.countries', function () {
137
+        $this->app->singleton('firewall.countries', function() {
138 138
             return new Countries();
139 139
         });
140 140
     }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      */
147 147
     private function registerBlacklistCommand()
148 148
     {
149
-        $this->app->singleton('firewall.blacklist.command', function () {
149
+        $this->app->singleton('firewall.blacklist.command', function() {
150 150
             return new BlacklistCommand();
151 151
         });
152 152
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      */
161 161
     private function registerCache()
162 162
     {
163
-        $this->app->singleton('firewall.cache', function () {
163
+        $this->app->singleton('firewall.cache', function() {
164 164
             return new Cache(app('cache'));
165 165
         });
166 166
     }
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      */
173 173
     private function registerClearCommand()
174 174
     {
175
-        $this->app->singleton('firewall.clear.command', function () {
175
+        $this->app->singleton('firewall.clear.command', function() {
176 176
             return new ClearCommand();
177 177
         });
178 178
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
      */
187 187
     private function registerFlushCommand()
188 188
     {
189
-        $this->app->singleton('firewall.flush.command', function () {
189
+        $this->app->singleton('firewall.flush.command', function() {
190 190
             return new Flush();
191 191
         });
192 192
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
      */
201 201
     private function registerDataRepository()
202 202
     {
203
-        $this->app->singleton('firewall.datarepository', function () {
203
+        $this->app->singleton('firewall.datarepository', function() {
204 204
             return new DataRepository();
205 205
         });
206 206
     }
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
      */
221 221
     private function registerFileSystem()
222 222
     {
223
-        $this->app->singleton('firewall.filesystem', function () {
223
+        $this->app->singleton('firewall.filesystem', function() {
224 224
             return new Filesystem();
225 225
         });
226 226
     }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
      */
234 234
     private function registerFirewall()
235 235
     {
236
-        $this->app->singleton('firewall', function ($app) {
236
+        $this->app->singleton('firewall', function($app) {
237 237
             $app['firewall.loaded'] = true;
238 238
 
239 239
             $this->firewall = new Firewall(
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 
253 253
     private function registerIpAddress()
254 254
     {
255
-        $this->app->singleton('firewall.ipaddress', function () {
255
+        $this->app->singleton('firewall.ipaddress', function() {
256 256
             return new IpAddress();
257 257
         });
258 258
     }
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
      */
263 263
     private function registerIpList()
264 264
     {
265
-        $this->app->singleton('firewall.iplist', function () {
265
+        $this->app->singleton('firewall.iplist', function() {
266 266
             return new IpList($this->getFirewallModel());
267 267
         });
268 268
     }
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
      */
273 273
     private function registerMessageRepository()
274 274
     {
275
-        $this->app->singleton('firewall.messages', function () {
275
+        $this->app->singleton('firewall.messages', function() {
276 276
             return new Message();
277 277
         });
278 278
     }
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
      */
285 285
     private function registerMiddleware()
286 286
     {
287
-        $this->app->singleton('firewall.middleware.blacklist', function () {
287
+        $this->app->singleton('firewall.middleware.blacklist', function() {
288 288
             return new FirewallBlacklist(new Blacklist());
289 289
         });
290 290
 
291
-        $this->app->singleton('firewall.middleware.whitelist', function () {
291
+        $this->app->singleton('firewall.middleware.whitelist', function() {
292 292
             return new FirewallWhitelist(new Whitelist());
293 293
         });
294 294
     }
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 
301 301
     private function registerGeoIp()
302 302
     {
303
-        $this->app->singleton('firewall.geoip', function () {
303
+        $this->app->singleton('firewall.geoip', function() {
304 304
             return new GeoIp($this->getConfig('geoip_database_path'));
305 305
         });
306 306
     }
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
      */
313 313
     private function registerRemoveCommand()
314 314
     {
315
-        $this->app->singleton('firewall.remove.command', function () {
315
+        $this->app->singleton('firewall.remove.command', function() {
316 316
             return new RemoveCommand();
317 317
         });
318 318
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
      */
327 327
     private function registerReportCommand()
328 328
     {
329
-        $this->app->singleton('firewall.list.command', function () {
329
+        $this->app->singleton('firewall.list.command', function() {
330 330
             return new ReportCommand();
331 331
         });
332 332
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
      */
339 339
     private function registerUpdateGeoIpCommand()
340 340
     {
341
-        $this->app->singleton('firewall.updategeoip.command', function () {
341
+        $this->app->singleton('firewall.updategeoip.command', function() {
342 342
             return new UpdateGeoIpCommand();
343 343
         });
344 344
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
      */
353 353
     private function registerWhitelistCommand()
354 354
     {
355
-        $this->app->singleton('firewall.whitelist.command', function () {
355
+        $this->app->singleton('firewall.whitelist.command', function() {
356 356
             return new WhitelistCommand();
357 357
         });
358 358
 
Please login to merge, or discard this patch.