Passed
Push — master ( 1a882c...cd4834 )
by Kris
01:22
created
lib/ApiDefintion.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
         // Open proxy, open relay, or Tor exit node.
71 71
         ['openproxy'       , '9', 'Open Proxy', true],        
72 72
 
73
-         // Comment/forum spam, HTTP referer spam, or other CMS spam.
74
-         ['webspam'         , '10', 'Web Spam', true],        
73
+            // Comment/forum spam, HTTP referer spam, or other CMS spam.
74
+            ['webspam'         , '10', 'Web Spam', true],        
75 75
 
76 76
         // Spam email content, infected attachments, and phishing emails. Note: Limit comments to only relevent
77 77
         // information (instead of log dumps) and be sure to remove PII if you want to remain anonymous.
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
             if ($cat[0] === $categoryName) {
148 148
                 return $cat;
149 149
             }
150
-         }
150
+            }
151 151
 
152 152
         // not found
153 153
         return false;
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
     public function getCategoryNameById(string $categoryId)
165 165
     {
166 166
         foreach ($this->aipdbApiCategories as $cat){
167
-           if ($cat[1] === $categoryId) {
168
-               return $cat;
169
-           }
167
+            if ($cat[1] === $categoryId) {
168
+                return $cat;
169
+            }
170 170
         }
171 171
 
172 172
         // not found
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
                 return $i;
191 191
             }
192 192
             $i++;
193
-         }
193
+            }
194 194
 
195 195
         // not found
196 196
         return false;
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -44,82 +44,82 @@  discard block
 block discarded – undo
44 44
     protected $aipdbApiCategories = [
45 45
         
46 46
         // Altering DNS records resulting in improper redirection.        
47
-        ['dns-c'           , '1', 'DNS Compromise', true],    
47
+        [ 'dns-c', '1', 'DNS Compromise', true ],    
48 48
         
49 49
         // Falsifying domain server cache (cache poisoning).
50
-        ['dns-p'           , '2', 'DNS Poisoning', true],     
50
+        [ 'dns-p', '2', 'DNS Poisoning', true ],     
51 51
         
52 52
         // Fraudulent orders.
53
-        ['fraud-orders'    , '3', 'Fraud Orders', true],      
53
+        [ 'fraud-orders', '3', 'Fraud Orders', true ],      
54 54
 
55 55
         // Participating in distributed denial-of-service (usually part of botnet).        
56
-        ['ddos'            , '4', 'DDoS Attack', true],       
56
+        [ 'ddos', '4', 'DDoS Attack', true ],       
57 57
         
58 58
         // 
59
-        ['ftp-bf'          , '5', 'FTP Brute-Force', true],   
59
+        [ 'ftp-bf', '5', 'FTP Brute-Force', true ],   
60 60
         
61 61
         // Oversized IP packet.
62
-        ['pingdeath'       , '6', 'Ping of Death', true],     
62
+        [ 'pingdeath', '6', 'Ping of Death', true ],     
63 63
 
64 64
         // Phishing websites and/or email.
65
-        ['phishing'        , '7', 'Phishing', true],          
65
+        [ 'phishing', '7', 'Phishing', true ],          
66 66
         
67 67
         //
68
-        ['fraudvoip'       , '8', 'Fraud VoIP', true],        
68
+        [ 'fraudvoip', '8', 'Fraud VoIP', true ],        
69 69
 
70 70
         // Open proxy, open relay, or Tor exit node.
71
-        ['openproxy'       , '9', 'Open Proxy', true],        
71
+        [ 'openproxy', '9', 'Open Proxy', true ],        
72 72
 
73 73
          // Comment/forum spam, HTTP referer spam, or other CMS spam.
74
-         ['webspam'         , '10', 'Web Spam', true],        
74
+         [ 'webspam', '10', 'Web Spam', true ],        
75 75
 
76 76
         // Spam email content, infected attachments, and phishing emails. Note: Limit comments to only relevent
77 77
         // information (instead of log dumps) and be sure to remove PII if you want to remain anonymous.
78
-        ['emailspam'       , '11', 'Email Spam', true],                                                   
78
+        [ 'emailspam', '11', 'Email Spam', true ],                                                   
79 79
              
80 80
         // CMS blog comment spam.
81
-        ['blogspam'        , '12', 'Blog Spam', true],      
81
+        [ 'blogspam', '12', 'Blog Spam', true ],      
82 82
         
83 83
         // Conjunctive category.
84
-        ['vpnip'           , '13', 'VPN IP', false], // to check alone ??           
84
+        [ 'vpnip', '13', 'VPN IP', false ], // to check alone ??           
85 85
 
86 86
         // Scanning for open ports and vulnerable services.
87
-        ['scan'            , '14', 'Port Scan', true],        
87
+        [ 'scan', '14', 'Port Scan', true ],        
88 88
        
89 89
         // 
90
-        ['hack'            , '15', 'Hacking', true],           
90
+        [ 'hack', '15', 'Hacking', true ],           
91 91
 
92 92
         // Attempts at SQL injection.
93
-        ['sql'             , '16', 'SQL Injection', true],     
93
+        [ 'sql', '16', 'SQL Injection', true ],     
94 94
         
95 95
         // Email sender spoofing.
96
-        ['spoof'           , '17', 'Spoofing', true],         
96
+        [ 'spoof', '17', 'Spoofing', true ],         
97 97
 
98 98
         // Credential brute-force attacks on webpage logins and services like SSH, FTP, SIP, SMTP, RDP, etc. 
99 99
         // This category is seperate from DDoS attacks.
100
-        ['brute'           , '18', 'Brute-Force', true],     
100
+        [ 'brute', '18', 'Brute-Force', true ],     
101 101
 
102 102
         // Webpage scraping (for email addresses, content, etc) and crawlers that do not honor robots.txt.                                  
103 103
         // Excessive requests and user agent spoofing can also be reported here.                        
104
-        ['badbot'          , '19', 'Bad Web Bot', true],      
104
+        [ 'badbot', '19', 'Bad Web Bot', true ],      
105 105
                                                          
106 106
         // Host is likely infected with malware and being used for other attacks or to host malicious content. 
107 107
         // The host owner may not be aware of the compromise. This category is often used in combination 
108 108
         // with other attack categories.
109
-        ['explhost'        , '20', 'Exploited Host', true],
109
+        [ 'explhost', '20', 'Exploited Host', true ],
110 110
         
111 111
         // Attempts to probe for or exploit installed web applications such as a CMS 
112 112
         // like WordPress/Drupal, e-commerce solutions, forum software, phpMyAdmin and 
113 113
         // various other software plugins/solutions.                                                         
114
-        ['webattack'       , '21', 'Web App Attack', true ],   
114
+        [ 'webattack', '21', 'Web App Attack', true ],   
115 115
         
116 116
         // Secure Shell (SSH) abuse. Use this category in combination 
117 117
         // with more specific categories.
118
-        ['ssh'             , '22', 'SSH', false],              
118
+        [ 'ssh', '22', 'SSH', false ],              
119 119
 
120 120
         // Abuse was targeted at an "Internet of Things" type device. Include 
121 121
         // information about what type of device was targeted in the comments.         
122
-        ['oit'             , '23', 'IoT Targeted', true],     
122
+        [ 'oit', '23', 'IoT Targeted', true ],     
123 123
     ];
124 124
 
125 125
     /**
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
      */
144 144
     public function getCategoryIdbyName(string $categoryName)
145 145
     {
146
-        foreach ($this->aipdbApiCategories as $cat){
147
-            if ($cat[0] === $categoryName) {
146
+        foreach ($this->aipdbApiCategories as $cat) {
147
+            if ($cat[ 0 ] === $categoryName) {
148 148
                 return $cat;
149 149
             }
150 150
          }
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
      */
164 164
     public function getCategoryNameById(string $categoryId)
165 165
     {
166
-        foreach ($this->aipdbApiCategories as $cat){
167
-           if ($cat[1] === $categoryId) {
166
+        foreach ($this->aipdbApiCategories as $cat) {
167
+           if ($cat[ 1 ] === $categoryId) {
168 168
                return $cat;
169 169
            }
170 170
         }
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
     protected function getCategoryIndex(string $value, int $index)
186 186
     {
187 187
         $i = 0;
188
-        foreach ($this->aipdbApiCategories as $cat){
189
-            if ($cat[$index] === $value) {
188
+        foreach ($this->aipdbApiCategories as $cat) {
189
+            if ($cat[ $index ] === $value) {
190 190
                 return $i;
191 191
             }
192 192
             $i++;
Please login to merge, or discard this patch.
lib/ApiHandler.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      */
146 146
     public function report(string $ip = '', string $categories = '', string $message = '', bool $returnArray = false)
147 147
     {
148
-         // ip must be set
148
+            // ip must be set
149 149
         if (empty($ip)){
150 150
             throw new \InvalidArgumentException('Ip was empty');
151 151
         }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         }
157 157
 
158 158
         // message must be set
159
-          if (empty($message)){
159
+            if (empty($message)){
160 160
             throw new \InvalidArgumentException('report message was empty');
161 161
         }
162 162
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
         // option
277 277
         if ($verbose){
278
-           $data['verbose'] = true;
278
+            $data['verbose'] = true;
279 279
         }
280 280
 
281 281
         $response = $this->apiRequest('check', $data, 'GET') ;
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
         return json_decode($response, $returnArray);
284 284
     }
285 285
 
286
- /**
286
+    /**
287 287
      * Perform a 'clear-address' api request
288 288
      * 
289 289
      *  Sample response:
@@ -457,14 +457,14 @@  discard block
 block discarded – undo
457 457
             'Key: ' . $this->aipdbApiKey,
458 458
         ]);
459 459
   
460
-      // execute curl call
461
-      $result = curl_exec($ch);
460
+        // execute curl call
461
+        $result = curl_exec($ch);
462 462
   
463
-      // close connection
464
-      curl_close($ch);
463
+        // close connection
464
+        curl_close($ch);
465 465
   
466
-      // return response as is (JSON or plain text)
467
-      return $result;
466
+        // return response as is (JSON or plain text)
467
+        return $result;
468 468
     }
469 469
 
470 470
     /** 
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
      * @access public
476 476
      * @param string      $message           The original message 
477 477
      *  
478
-	 * @return string
478
+     * @return string
479 479
      */
480 480
     protected function cleanMessage(string $message)
481 481
     {
@@ -500,10 +500,10 @@  discard block
 block discarded – undo
500 500
      *
501 501
      * @access public
502 502
      * @static
503
-	 * @param string    $filePath       The file's full path
504
-	 * @param bool      $throwError     Throw error on true or silent process. Default is true
503
+     * @param string    $filePath       The file's full path
504
+     * @param bool      $throwError     Throw error on true or silent process. Default is true
505 505
      *  
506
-	 * @return object|null 
506
+     * @return object|null 
507 507
      * @throws \Exception
508 508
      * @throws \LogicException
509 509
      */
@@ -511,10 +511,10 @@  discard block
 block discarded – undo
511 511
     {
512 512
         // check file exists
513 513
         if (!file_exists($filePath) || !is_file($filePath)){
514
-           if ($throwError) {
514
+            if ($throwError) {
515 515
                 throw new \Exception('Config file not found');
516
-           }
517
-           return null;  
516
+            }
517
+            return null;  
518 518
         }
519 519
 
520 520
         // get and parse content
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      * @access protected
51 51
      * @var array $selfIps  
52 52
      */
53
-    protected $selfIps = []; 
53
+    protected $selfIps = [ ]; 
54 54
 
55 55
     /**
56 56
      * Constructor
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      * @param array   $myIps      The Ips/domain name you dont want to display in report messages
62 62
      * 
63 63
      */
64
-    public function __construct(string $apiKey, string $userId, array $myIps = [])
64
+    public function __construct(string $apiKey, string $userId, array $myIps = [ ])
65 65
     {
66 66
         $this->aipdbApiKey = $apiKey;
67 67
         $this->aipdbUserId = $userId;
@@ -100,21 +100,21 @@  discard block
 block discarded – undo
100 100
     {
101 101
 
102 102
         // check file exists
103
-        if (!file_exists($configPath) || !is_file($configPath)){
103
+        if (!file_exists($configPath) || !is_file($configPath)) {
104 104
             throw new \InvalidArgumentException('The file [' . $configPath . '] does not exist.');
105 105
         }
106 106
 
107 107
         // check file is readable
108
-        if (!is_readable($configPath)){
108
+        if (!is_readable($configPath)) {
109 109
             throw new InvalidPermissionException('The file [' . $configPath . '] is not readable.');
110 110
         }
111 111
 
112 112
         $keyConfig = self::loadJsonFile($configPath);
113
-        $selfIps = [];
113
+        $selfIps = [ ];
114 114
         
115 115
         // Look for other optional config files in the same directory 
116 116
         $selfIpsConfigPath = pathinfo($configPath, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR . 'self_ips.json';
117
-        if (file_exists($selfIpsConfigPath)){
117
+        if (file_exists($selfIpsConfigPath)) {
118 118
             $selfIps = self::loadJsonFile($selfIpsConfigPath)->self_ips;
119 119
         }
120 120
 
@@ -146,17 +146,17 @@  discard block
 block discarded – undo
146 146
     public function report(string $ip = '', string $categories = '', string $message = '', bool $returnArray = false)
147 147
     {
148 148
          // ip must be set
149
-        if (empty($ip)){
149
+        if (empty($ip)) {
150 150
             throw new \InvalidArgumentException('Ip was empty');
151 151
         }
152 152
 
153 153
         // categories must be set
154
-        if (empty($categories)){
154
+        if (empty($categories)) {
155 155
             throw new \InvalidArgumentException('categories list was empty');
156 156
         }
157 157
 
158 158
         // message must be set
159
-          if (empty($message)){
159
+          if (empty($message)) {
160 160
             throw new \InvalidArgumentException('report message was empty');
161 161
         }
162 162
 
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
     public function checkBlock(string $network = null, int $maxAge = 30, bool $returnArray = false)
224 224
     {
225 225
         // max age must be less or equal to 365
226
-        if ($maxAge > 365 || $maxAge < 1){
226
+        if ($maxAge > 365 || $maxAge < 1) {
227 227
             throw new \InvalidArgumentException('maxAge must be at least 1 and less than 365 (' . $maxAge . ' was given)');
228 228
         }
229 229
 
230 230
         // ip must be set
231
-        if (empty($network)){
231
+        if (empty($network)) {
232 232
             throw new \InvalidArgumentException('network argument must be set (null given)');
233 233
         }
234 234
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
             'maxAgeInDays'  => $maxAge,  
239 239
         ];
240 240
 
241
-        $response = $this->apiRequest('check-block', $data, 'GET') ;
241
+        $response = $this->apiRequest('check-block', $data, 'GET');
242 242
 
243 243
         return json_decode($response, $returnArray);
244 244
     }
@@ -258,12 +258,12 @@  discard block
 block discarded – undo
258 258
     public function check(string $ip = null, int $maxAge = 30, bool $verbose = false, bool $returnArray = false)
259 259
     {
260 260
         // max age must be less or equal to 365
261
-        if ($maxAge > 365 || $maxAge < 1){
261
+        if ($maxAge > 365 || $maxAge < 1) {
262 262
             throw new \InvalidArgumentException('maxAge must be at least 1 and less than 365 (' . $maxAge . ' was given)');
263 263
         }
264 264
 
265 265
         // ip must be set
266
-        if (empty($ip)){
266
+        if (empty($ip)) {
267 267
             throw new \InvalidArgumentException('ip argument must be set (null given)');
268 268
         }
269 269
 
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
         ];
275 275
 
276 276
         // option
277
-        if ($verbose){
278
-           $data['verbose'] = true;
277
+        if ($verbose) {
278
+           $data[ 'verbose' ] = true;
279 279
         }
280 280
 
281
-        $response = $this->apiRequest('check', $data, 'GET') ;
281
+        $response = $this->apiRequest('check', $data, 'GET');
282 282
 
283 283
         return json_decode($response, $returnArray);
284 284
     }
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
     public function clear(string $ip = null, bool $returnArray = false)
306 306
     {
307 307
         // ip must be set
308
-        if (empty($ip)){
308
+        if (empty($ip)) {
309 309
             throw new \InvalidArgumentException('ip argument must be set (null given)');
310 310
         }
311 311
 
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             'ipAddress'     => $ip, 
315 315
         ];
316 316
 
317
-        $response = $this->apiRequest('clear-address', $data, "DELETE") ;
317
+        $response = $this->apiRequest('clear-address', $data, "DELETE");
318 318
         return json_decode($response, $returnArray);
319 319
     }
320 320
 
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
     public function getBlacklist(int $limit = 10000, bool $plainText = false, bool $returnArray = false)
334 334
     {
335 335
 
336
-        if ($limit < 1){
336
+        if ($limit < 1) {
337 337
             throw new \InvalidArgumentException('limit must be at least 1 (' . $limit . ' was given)');
338 338
         }
339 339
 
@@ -345,13 +345,13 @@  discard block
 block discarded – undo
345 345
 
346 346
         // plaintext paremeter has no value and must be added only when true 
347 347
         // (set plaintext=false won't work)
348
-        if ($plainText){
349
-            $data['plaintext'] = $plainText;
348
+        if ($plainText) {
349
+            $data[ 'plaintext' ] = $plainText;
350 350
         }
351 351
 
352 352
         $response = $this->apiRequest('blacklist', $data, 'GET');
353 353
 
354
-        if ($plainText){
354
+        if ($plainText) {
355 355
             return $response;
356 356
         } 
357 357
        
@@ -382,21 +382,21 @@  discard block
 block discarded – undo
382 382
         foreach ($cats as $cat) {
383 383
 
384 384
             // get index on our array of categories
385
-            $catIndex    = is_numeric($cat) ? $this->getCategoryIndex($cat, 1) : $this->getCategoryIndex($cat, 0);
385
+            $catIndex = is_numeric($cat) ? $this->getCategoryIndex($cat, 1) : $this->getCategoryIndex($cat, 0);
386 386
 
387 387
             // check if found
388
-            if ($catIndex === false ){
389
-                throw new \InvalidArgumentException('Invalid report category was given : ['. $cat .  ']');
388
+            if ($catIndex === false) {
389
+                throw new \InvalidArgumentException('Invalid report category was given : [' . $cat . ']');
390 390
             }
391 391
 
392 392
             // get Id
393
-            $catId = $this->aipdbApiCategories[$catIndex][1];
393
+            $catId = $this->aipdbApiCategories[ $catIndex ][ 1 ];
394 394
 
395 395
             // need another ?
396
-            if ($needAnother !== false){
396
+            if ($needAnother !== false) {
397 397
 
398 398
                 // is a standalone cat ?
399
-                if ($this->aipdbApiCategories[$catIndex][3] === false) {
399
+                if ($this->aipdbApiCategories[ $catIndex ][ 3 ] === false) {
400 400
                     $needAnother = true;
401 401
 
402 402
                 } else {
@@ -407,10 +407,10 @@  discard block
 block discarded – undo
407 407
             }
408 408
 
409 409
             // set or add to cats list 
410
-            $catsString = ($catsString === '') ? $catId : $catsString .','.$catId;
410
+            $catsString = ($catsString === '') ? $catId : $catsString . ',' . $catId;
411 411
         }
412 412
 
413
-        if ($needAnother !== false){
413
+        if ($needAnother !== false) {
414 414
             throw new \InvalidArgumentException('Invalid report category paremeter given: some categories can\'t be used alone');
415 415
         }
416 416
 
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
         $message = str_replace('\\', '', $message);
484 484
 
485 485
         // Remove self ips
486
-        foreach ($this->selfIps as $ip){
486
+        foreach ($this->selfIps as $ip) {
487 487
             $message = str_replace($ip, '*', $message);
488 488
         }
489 489
 
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
     protected static function loadJsonFile(string $filePath, bool $throwError = true)
511 511
     {
512 512
         // check file exists
513
-        if (!file_exists($filePath) || !is_file($filePath)){
513
+        if (!file_exists($filePath) || !is_file($filePath)) {
514 514
            if ($throwError) {
515 515
                 throw new \Exception('Config file not found');
516 516
            }
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
         $json    = json_decode(utf8_encode($content));
523 523
 
524 524
         // check for errors
525
-        if ($json == null && json_last_error() != JSON_ERROR_NONE){
525
+        if ($json == null && json_last_error() != JSON_ERROR_NONE) {
526 526
             if ($throwError) {
527 527
                 throw new \LogicException(sprintf("Failed to parse config file Error: '%s'", json_last_error_msg()));
528 528
             }
Please login to merge, or discard this patch.