Completed
Push — master ( 2bd6c2...9d13eb )
by Antonio Carlos
08:09 queued 01:00
created
src/Repositories/Message.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@
 block discarded – undo
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
         });
Please login to merge, or discard this patch.
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 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -55,21 +55,21 @@
 block discarded – undo
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
 
Please login to merge, or discard this 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   +6 added lines, -8 removed lines patch added patch discarded remove patch
@@ -240,8 +240,7 @@  discard block
 block discarded – undo
240 240
     public function addToProperList($whitelist, $ip)
241 241
     {
242 242
         $this->config->get('use_database') ?
243
-            $this->addToDatabaseList($whitelist, $ip) :
244
-            $this->addToArrayList($whitelist, $ip);
243
+            $this->addToDatabaseList($whitelist, $ip) : $this->addToArrayList($whitelist, $ip);
245 244
     }
246 245
 
247 246
     /**
@@ -254,8 +253,7 @@  discard block
 block discarded – undo
254 253
     public function delete($ipAddress)
255 254
     {
256 255
         $this->config->get('use_database') ?
257
-            $this->removeFromDatabaseList($ipAddress) :
258
-            $this->removeFromArrayList($ipAddress);
256
+            $this->removeFromDatabaseList($ipAddress) : $this->removeFromArrayList($ipAddress);
259 257
     }
260 258
 
261 259
     /**
@@ -364,7 +362,7 @@  discard block
 block discarded – undo
364 362
     {
365 363
         $country = $this->makeCountryFromString($country);
366 364
 
367
-        return $this->all()->filter(function ($item) use ($country) {
365
+        return $this->all()->filter(function($item) use ($country) {
368 366
             return $item['ip_address'] == $country ||
369 367
                 $this->makeCountryFromString($this->getCountryFromIp($item['ip_address'])) == $country;
370 368
         });
@@ -430,13 +428,13 @@  discard block
 block discarded – undo
430 428
     private function getNonDatabaseIps()
431 429
     {
432 430
         return array_merge_recursive(
433
-            array_map(function ($ip) {
431
+            array_map(function($ip) {
434 432
                 $ip['whitelisted'] = true;
435 433
 
436 434
                 return $ip;
437 435
             }, $this->formatIpArray($this->config->get('whitelist'))),
438 436
 
439
-            array_map(function ($ip) {
437
+            array_map(function($ip) {
440 438
                 $ip['whitelisted'] = false;
441 439
 
442 440
                 return $ip;
@@ -555,7 +553,7 @@  discard block
 block discarded – undo
555 553
      */
556 554
     private function formatIpArray($list)
557 555
     {
558
-        return array_map(function ($ip) {
556
+        return array_map(function($ip) {
559 557
             return ['ip_address' => $ip];
560 558
         }, $this->makeArrayOfIps($list));
561 559
     }
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
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      */
141 141
     protected function checkExpiration()
142 142
     {
143
-        $this->enabledItems->each(function ($index, $type) {
143
+        $this->enabledItems->each(function($index, $type) {
144 144
             if (($this->record[$type]['lastRequestAt']->diffInSeconds(Carbon::now())) <= ($this->getMaxSecondsForType($type))) {
145 145
                 return $this->record;
146 146
             }
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
      */
259 259
     protected function increment()
260 260
     {
261
-        $this->enabledItems->each(function ($index, $type) {
261
+        $this->enabledItems->each(function($index, $type) {
262 262
             $this->save($type, ['requestCount' => $this->record[$type]['requestCount'] + 1]);
263 263
         });
264 264
     }
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
      */
271 271
     protected function isAttack()
272 272
     {
273
-        return $this->enabledItems->filter(function ($index, $type) {
273
+        return $this->enabledItems->filter(function($index, $type) {
274 274
             if (!$this->isWhitelisted($type) && $this->record[$type]['requestCount'] > $this->getMaxRequestCountForType($type)) {
275 275
                 $this->takeAction($this->record[$type]);
276 276
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
      */
328 328
     private function loadConfig()
329 329
     {
330
-        $this->enabledItems = collect($this->config->get('attack_blocker.enabled'))->filter(function ($item) {
330
+        $this->enabledItems = collect($this->config->get('attack_blocker.enabled'))->filter(function($item) {
331 331
             return $item === true;
332 332
         });
333 333
     }
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
      */
358 358
     protected function loadRecordItems()
359 359
     {
360
-        $this->enabledItems->each(function ($index, $type) {
360
+        $this->enabledItems->each(function($index, $type) {
361 361
             if (is_null($this->record[$type] = $this->cache->get($key = $this->makeKeyForType($type, $this->ipAddress)))) {
362 362
                 $this->record[$type] = $this->getEmptyRecord($key, $type);
363 363
             }
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
         if (!$record['wasNotified'] && $this->config->get('notifications.enabled')) {
499 499
             $this->save($record['type'], ['wasNotified' => true]);
500 500
 
501
-            collect($this->config->get('notifications.channels'))->filter(function ($value, $channel) use ($record) {
501
+            collect($this->config->get('notifications.channels'))->filter(function($value, $channel) use ($record) {
502 502
                 try {
503 503
                     event(new AttackDetected($record, $channel));
504 504
                 } catch (\Exception $exception) {
Please login to merge, or discard this patch.
src/Vendor/Laravel/ServiceProvider.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 Cache($app['firewall.config'], app('cache'));
168 168
         });
169 169
     }
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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(
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
      */
257 257
     private function registerMessageRepository()
258 258
     {
259
-        $this->app->singleton('firewall.message', function ($app) {
259
+        $this->app->singleton('firewall.message', function($app) {
260 260
             return new Message();
261 261
         });
262 262
     }
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
      */
269 269
     private function registerMiddleware()
270 270
     {
271
-        $this->app->singleton('firewall.middleware.blacklist', function ($app) {
271
+        $this->app->singleton('firewall.middleware.blacklist', function($app) {
272 272
             return new FirewallBlacklist(new Blacklist());
273 273
         });
274 274
 
275
-        $this->app->singleton('firewall.middleware.whitelist', function ($app) {
275
+        $this->app->singleton('firewall.middleware.whitelist', function($app) {
276 276
             return new FirewallWhitelist(new Whitelist());
277 277
         });
278 278
     }
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 
285 285
     private function registerGeoIp()
286 286
     {
287
-        $this->app->singleton('firewall.geoip', function () {
287
+        $this->app->singleton('firewall.geoip', function() {
288 288
             return new GeoIp($this->getConfig('geoip_database_path'));
289 289
         });
290 290
     }
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
      */
297 297
     private function registerRemoveCommand()
298 298
     {
299
-        $this->app->singleton('firewall.remove.command', function ($app) {
299
+        $this->app->singleton('firewall.remove.command', function($app) {
300 300
             return new RemoveCommand();
301 301
         });
302 302
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
      */
311 311
     private function registerReportCommand()
312 312
     {
313
-        $this->app->singleton('firewall.list.command', function ($app) {
313
+        $this->app->singleton('firewall.list.command', function($app) {
314 314
             return new ReportCommand();
315 315
         });
316 316
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
      */
323 323
     private function registerUpdateGeoIpCommand()
324 324
     {
325
-        $this->app->singleton('firewall.updategeoip.command', function ($app) {
325
+        $this->app->singleton('firewall.updategeoip.command', function($app) {
326 326
             return new UpdateGeoIpCommand();
327 327
         });
328 328
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
      */
337 337
     private function registerWhitelistCommand()
338 338
     {
339
-        $this->app->singleton('firewall.whitelist.command', function ($app) {
339
+        $this->app->singleton('firewall.whitelist.command', function($app) {
340 340
             return new WhitelistCommand();
341 341
         });
342 342
 
Please login to merge, or discard this patch.