Passed
Push — master ( d1d9cf...dc3000 )
by Kris
01:34
created
lib/CurlTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@
 block discarded – undo
38 38
      */
39 39
     protected function setCurlOption($ch, int $option, $value): void
40 40
     {
41
-        if(!curl_setopt($ch,$option,$value)){
42
-            throw new \RuntimeException('curl_setopt failed! '.curl_error($ch));
41
+        if (!curl_setopt($ch, $option, $value)) {
42
+            throw new \RuntimeException('curl_setopt failed! ' . curl_error($ch));
43 43
         }
44 44
     }
45 45
 }
Please login to merge, or discard this patch.
lib/ApiHandler.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function report(string $ip, string $categories, string $message): ApiResponse
94 94
     {
95
-         // ip must be set
95
+            // ip must be set
96 96
         if (empty($ip)){
97 97
             throw new \InvalidArgumentException('Ip was empty');
98 98
         }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
         // option
233 233
         if ($verbose){
234
-           $data['verbose'] = true;
234
+            $data['verbose'] = true;
235 235
         }
236 236
 
237 237
         return $this->apiRequest('check', $data, 'GET') ;
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
      * @access public
404 404
      * @param string      $message           The original message 
405 405
      *  
406
-	 * @return string
406
+     * @return string
407 407
      */
408 408
     public function cleanMessage(string $message): string
409 409
     {
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      * @access protected
44 44
      * @var array  
45 45
      */
46
-    protected $selfIps = []; 
46
+    protected $selfIps = [ ]; 
47 47
 
48 48
     /**
49 49
      * The maximum number of milliseconds to allow cURL functions to execute. If libcurl is 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      *                            to execute. Default is 0, no timeout
66 66
      * 
67 67
      */
68
-    public function __construct(string $apiKey, array $myIps = [], int $timeout = 0)
68
+    public function __construct(string $apiKey, array $myIps = [ ], int $timeout = 0)
69 69
     {
70 70
         $this->aipdbApiKey = $apiKey;
71 71
         $this->selfIps = $myIps;
@@ -111,17 +111,17 @@  discard block
 block discarded – undo
111 111
     public function report(string $ip, string $categories, string $message): ApiResponse
112 112
     {
113 113
          // ip must be set
114
-        if (empty($ip)){
114
+        if (empty($ip)) {
115 115
             throw new \InvalidArgumentException('Ip was empty');
116 116
         }
117 117
 
118 118
         // categories must be set
119
-        if (empty($categories)){
119
+        if (empty($categories)) {
120 120
             throw new \InvalidArgumentException('Categories list was empty');
121 121
         }
122 122
 
123 123
         // message must be set
124
-        if (empty($message)){
124
+        if (empty($message)) {
125 125
             throw new \InvalidArgumentException('Report message was empty');
126 126
         }
127 127
 
@@ -178,16 +178,16 @@  discard block
 block discarded – undo
178 178
     public function bulkReport(string $filePath): ApiResponse
179 179
     {
180 180
         // check file exists
181
-        if (!file_exists($filePath) || !is_file($filePath)){
181
+        if (!file_exists($filePath) || !is_file($filePath)) {
182 182
             throw new \InvalidArgumentException('The file [' . $filePath . '] does not exist.');
183 183
         }
184 184
 
185 185
         // check file is readable
186
-        if (!is_readable($filePath)){
186
+        if (!is_readable($filePath)) {
187 187
             throw new InvalidPermissionException('The file [' . $filePath . '] is not readable.');
188 188
         }
189 189
 
190
-        return $this->apiRequest('bulk-report', [], 'POST', $filePath);
190
+        return $this->apiRequest('bulk-report', [ ], 'POST', $filePath);
191 191
     }
192 192
 
193 193
     /**
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
     public function clearAddress(string $ip): ApiResponse
212 212
     {
213 213
         // ip must be set
214
-        if (empty($ip)){
214
+        if (empty($ip)) {
215 215
             throw new \InvalidArgumentException('IP argument must be set.');
216 216
         }
217 217
 
218
-        return $this->apiRequest('clear-address',  ['ipAddress' => $ip ], "DELETE") ;
218
+        return $this->apiRequest('clear-address', [ 'ipAddress' => $ip ], "DELETE");
219 219
     }
220 220
 
221 221
     /**
@@ -233,12 +233,12 @@  discard block
 block discarded – undo
233 233
     public function check(string $ip, int $maxAgeInDays = 30, bool $verbose = false): ApiResponse
234 234
     {
235 235
         // max age must be less or equal to 365
236
-        if ( $maxAgeInDays > 365 || $maxAgeInDays < 1 ){
236
+        if ($maxAgeInDays > 365 || $maxAgeInDays < 1) {
237 237
             throw new \InvalidArgumentException('maxAgeInDays must be between 1 and 365.');
238 238
         }
239 239
 
240 240
         // ip must be set
241
-        if (empty($ip)){
241
+        if (empty($ip)) {
242 242
             throw new \InvalidArgumentException('ip argument must be set (empty value given)');
243 243
         }
244 244
 
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
         ];
250 250
 
251 251
         // option
252
-        if ($verbose){
253
-           $data['verbose'] = true;
252
+        if ($verbose) {
253
+           $data[ 'verbose' ] = true;
254 254
         }
255 255
 
256
-        return $this->apiRequest('check', $data, 'GET') ;
256
+        return $this->apiRequest('check', $data, 'GET');
257 257
     }
258 258
 
259 259
     /**
@@ -302,12 +302,12 @@  discard block
 block discarded – undo
302 302
     public function checkBlock(string $network, int $maxAgeInDays = 30): ApiResponse
303 303
     {
304 304
         // max age must be between 1 and 365
305
-        if ($maxAgeInDays > 365 || $maxAgeInDays < 1){
305
+        if ($maxAgeInDays > 365 || $maxAgeInDays < 1) {
306 306
             throw new \InvalidArgumentException('maxAgeInDays must be between 1 and 365 (' . $maxAgeInDays . ' was given)');
307 307
         }
308 308
 
309 309
         // ip must be set
310
-        if (empty($network)){
310
+        if (empty($network)) {
311 311
             throw new \InvalidArgumentException('network argument must be set (empty value given)');
312 312
         }
313 313
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
      */
337 337
     public function blacklist(int $limit = 10000, bool $plainText = false, int $confidenceMinimum = 100): ApiResponse
338 338
     {
339
-        if ($limit < 1){
339
+        if ($limit < 1) {
340 340
             throw new \InvalidArgumentException('limit must be at least 1 (' . $limit . ' was given)');
341 341
         }
342 342
 
@@ -348,8 +348,8 @@  discard block
 block discarded – undo
348 348
 
349 349
         // plaintext paremeter has no value and must be added only when true 
350 350
         // (set plaintext=false won't work)
351
-        if ($plainText){
352
-            $data['plaintext'] = $plainText;
351
+        if ($plainText) {
352
+            $data[ 'plaintext' ] = $plainText;
353 353
         }
354 354
 
355 355
         return $this->apiRequest('blacklist', $data, 'GET');
@@ -370,9 +370,9 @@  discard block
 block discarded – undo
370 370
      */
371 371
     protected function apiRequest(string $path, array $data, string $method = 'GET', string $csvFilePath = ''): ApiResponse
372 372
     {
373
-        $curlErrorNumber = -1;                   // will be used later to check curl execution
373
+        $curlErrorNumber = -1; // will be used later to check curl execution
374 374
         $curlErrorMessage = '';
375
-        $url = $this->aipdbApiEndpoint . $path;  // api url
375
+        $url = $this->aipdbApiEndpoint . $path; // api url
376 376
         
377 377
         // set the wanted format, JSON (required to prevent having full html page on error)
378 378
         // and the AbuseIPDB API Key as a header
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
         $ch = curl_init(); 
386 386
   
387 387
         // for csv
388
-        if (!empty($csvFilePath)){
389
-            $cfile = new \CurlFile($csvFilePath,  'text/csv', 'csv');
388
+        if (!empty($csvFilePath)) {
389
+            $cfile = new \CurlFile($csvFilePath, 'text/csv', 'csv');
390 390
             //curl file itself return the realpath with prefix of @
391 391
             $data = array('csv' => $cfile);
392 392
         }
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
         // close connection
427 427
         curl_close($ch);
428 428
 
429
-        if ($curlErrorNumber !== 0){
429
+        if ($curlErrorNumber !== 0) {
430 430
             throw new \RuntimeException($curlErrorMessage);
431 431
         }
432 432
 
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
         $message = str_replace('\\', '', $message);
450 450
 
451 451
         // Remove self ips
452
-        foreach ($this->selfIps as $ip){
452
+        foreach ($this->selfIps as $ip) {
453 453
             $message = str_replace($ip, '*', $message);
454 454
         }
455 455
 
Please login to merge, or discard this patch.
lib/QuietApiHandler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
     public function report(string $ip, string $categories, string $message): ApiResponse
43 43
     {
44 44
         try {
45
-            return parent::report($ip,$categories,$message);
45
+            return parent::report($ip, $categories, $message);
46 46
         } catch (\Exception $e) {
47 47
             return ApiResponse::createErrorResponse($e->getMessage());
48 48
         }
Please login to merge, or discard this patch.
lib/ApiBase.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
         // Open proxy, open relay, or Tor exit node.
80 80
         ['openproxy'       , '9', 'Open Proxy', true],        
81 81
 
82
-         // Comment/forum spam, HTTP referer spam, or other CMS spam.
83
-         ['webspam'         , '10', 'Web Spam', true],        
82
+            // Comment/forum spam, HTTP referer spam, or other CMS spam.
83
+            ['webspam'         , '10', 'Web Spam', true],        
84 84
 
85 85
         // Spam email content, infected attachments, and phishing emails. Note: Limit comments to only relevent
86 86
         // information (instead of log dumps) and be sure to remove PII if you want to remain anonymous.
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
             if ($cat[0] === $categoryName) {
160 160
                 return $cat[1];
161 161
             }
162
-         }
162
+            }
163 163
 
164 164
         // not found
165 165
         return false;
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
     public static function getCategoryNameById(string $categoryId)
178 178
     {
179 179
         foreach (self::$aipdbApiCategories as $cat){
180
-           if ($cat[1] === $categoryId) {
181
-               return $cat[0];
182
-           }
180
+            if ($cat[1] === $categoryId) {
181
+                return $cat[0];
182
+            }
183 183
         }
184 184
 
185 185
         // not found
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
                 return $i;
205 205
             }
206 206
             $i++;
207
-         }
207
+            }
208 208
 
209 209
         // not found
210 210
         return false;
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -53,82 +53,82 @@  discard block
 block discarded – undo
53 53
     protected static $aipdbApiCategories = [
54 54
         
55 55
         // Altering DNS records resulting in improper redirection.        
56
-        ['dns-c'           , '1', 'DNS Compromise', true],    
56
+        [ 'dns-c', '1', 'DNS Compromise', true ],    
57 57
         
58 58
         // Falsifying domain server cache (cache poisoning).
59
-        ['dns-p'           , '2', 'DNS Poisoning', true],     
59
+        [ 'dns-p', '2', 'DNS Poisoning', true ],     
60 60
         
61 61
         // Fraudulent orders.
62
-        ['fraud-orders'    , '3', 'Fraud Orders', true],      
62
+        [ 'fraud-orders', '3', 'Fraud Orders', true ],      
63 63
 
64 64
         // Participating in distributed denial-of-service (usually part of botnet).        
65
-        ['ddos'            , '4', 'DDoS Attack', true],       
65
+        [ 'ddos', '4', 'DDoS Attack', true ],       
66 66
         
67 67
         // 
68
-        ['ftp-bf'          , '5', 'FTP Brute-Force', true],   
68
+        [ 'ftp-bf', '5', 'FTP Brute-Force', true ],   
69 69
         
70 70
         // Oversized IP packet.
71
-        ['pingdeath'       , '6', 'Ping of Death', true],     
71
+        [ 'pingdeath', '6', 'Ping of Death', true ],     
72 72
 
73 73
         // Phishing websites and/or email.
74
-        ['phishing'        , '7', 'Phishing', true],          
74
+        [ 'phishing', '7', 'Phishing', true ],          
75 75
         
76 76
         //
77
-        ['fraudvoip'       , '8', 'Fraud VoIP', true],        
77
+        [ 'fraudvoip', '8', 'Fraud VoIP', true ],        
78 78
 
79 79
         // Open proxy, open relay, or Tor exit node.
80
-        ['openproxy'       , '9', 'Open Proxy', true],        
80
+        [ 'openproxy', '9', 'Open Proxy', true ],        
81 81
 
82 82
          // Comment/forum spam, HTTP referer spam, or other CMS spam.
83
-         ['webspam'         , '10', 'Web Spam', true],        
83
+         [ 'webspam', '10', 'Web Spam', true ],        
84 84
 
85 85
         // Spam email content, infected attachments, and phishing emails. Note: Limit comments to only relevent
86 86
         // information (instead of log dumps) and be sure to remove PII if you want to remain anonymous.
87
-        ['emailspam'       , '11', 'Email Spam', true],                                                   
87
+        [ 'emailspam', '11', 'Email Spam', true ],                                                   
88 88
              
89 89
         // CMS blog comment spam.
90
-        ['blogspam'        , '12', 'Blog Spam', true],      
90
+        [ 'blogspam', '12', 'Blog Spam', true ],      
91 91
         
92 92
         // Conjunctive category.
93
-        ['vpnip'           , '13', 'VPN IP', false], // to check alone ??           
93
+        [ 'vpnip', '13', 'VPN IP', false ], // to check alone ??           
94 94
 
95 95
         // Scanning for open ports and vulnerable services.
96
-        ['scan'            , '14', 'Port Scan', true],        
96
+        [ 'scan', '14', 'Port Scan', true ],        
97 97
        
98 98
         // 
99
-        ['hack'            , '15', 'Hacking', true],           
99
+        [ 'hack', '15', 'Hacking', true ],           
100 100
 
101 101
         // Attempts at SQL injection.
102
-        ['sql'             , '16', 'SQL Injection', true],     
102
+        [ 'sql', '16', 'SQL Injection', true ],     
103 103
         
104 104
         // Email sender spoofing.
105
-        ['spoof'           , '17', 'Spoofing', true],         
105
+        [ 'spoof', '17', 'Spoofing', true ],         
106 106
 
107 107
         // Credential brute-force attacks on webpage logins and services like SSH, FTP, SIP, SMTP, RDP, etc. 
108 108
         // This category is seperate from DDoS attacks.
109
-        ['brute'           , '18', 'Brute-Force', true],     
109
+        [ 'brute', '18', 'Brute-Force', true ],     
110 110
 
111 111
         // Webpage scraping (for email addresses, content, etc) and crawlers that do not honor robots.txt.                                  
112 112
         // Excessive requests and user agent spoofing can also be reported here.                        
113
-        ['badbot'          , '19', 'Bad Web Bot', true],      
113
+        [ 'badbot', '19', 'Bad Web Bot', true ],      
114 114
                                                          
115 115
         // Host is likely infected with malware and being used for other attacks or to host malicious content. 
116 116
         // The host owner may not be aware of the compromise. This category is often used in combination 
117 117
         // with other attack categories.
118
-        ['explhost'        , '20', 'Exploited Host', true],
118
+        [ 'explhost', '20', 'Exploited Host', true ],
119 119
         
120 120
         // Attempts to probe for or exploit installed web applications such as a CMS 
121 121
         // like WordPress/Drupal, e-commerce solutions, forum software, phpMyAdmin and 
122 122
         // various other software plugins/solutions.                                                         
123
-        ['webattack'       , '21', 'Web App Attack', true ],   
123
+        [ 'webattack', '21', 'Web App Attack', true ],   
124 124
         
125 125
         // Secure Shell (SSH) abuse. Use this category in combination 
126 126
         // with more specific categories.
127
-        ['ssh'             , '22', 'SSH', false],              
127
+        [ 'ssh', '22', 'SSH', false ],              
128 128
 
129 129
         // Abuse was targeted at an "Internet of Things" type device. Include 
130 130
         // information about what type of device was targeted in the comments.         
131
-        ['iot'             , '23', 'IoT Targeted', true],     
131
+        [ 'iot', '23', 'IoT Targeted', true ],     
132 132
     ];
133 133
 
134 134
     /**
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public static function getCategoryIdByName(string $categoryName)
157 157
     {
158
-        foreach (self::$aipdbApiCategories as $cat){
159
-            if ($cat[0] === $categoryName) {
160
-                return $cat[1];
158
+        foreach (self::$aipdbApiCategories as $cat) {
159
+            if ($cat[ 0 ] === $categoryName) {
160
+                return $cat[ 1 ];
161 161
             }
162 162
          }
163 163
 
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
      */
177 177
     public static function getCategoryNameById(string $categoryId)
178 178
     {
179
-        foreach (self::$aipdbApiCategories as $cat){
180
-           if ($cat[1] === $categoryId) {
181
-               return $cat[0];
179
+        foreach (self::$aipdbApiCategories as $cat) {
180
+           if ($cat[ 1 ] === $categoryId) {
181
+               return $cat[ 0 ];
182 182
            }
183 183
         }
184 184
 
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
     protected static function getCategoryIndex(string $value, int $index)
200 200
     {
201 201
         $i = 0;
202
-        foreach (self::$aipdbApiCategories as $cat){
203
-            if ($cat[$index] === $value) {
202
+        foreach (self::$aipdbApiCategories as $cat) {
203
+            if ($cat[ $index ] === $value) {
204 204
                 return $i;
205 205
             }
206 206
             $i++;
@@ -234,21 +234,21 @@  discard block
 block discarded – undo
234 234
         foreach ($cats as $cat) {
235 235
 
236 236
             // get index on our array of categories
237
-            $catIndex    = is_numeric($cat) ? self::getCategoryIndex($cat, 1) : self::getCategoryIndex($cat, 0);
237
+            $catIndex = is_numeric($cat) ? self::getCategoryIndex($cat, 1) : self::getCategoryIndex($cat, 0);
238 238
 
239 239
             // check if found
240
-            if ($catIndex === false ){
240
+            if ($catIndex === false) {
241 241
                 throw new \InvalidArgumentException('Invalid report category was given.');
242 242
             }
243 243
 
244 244
             // get Id
245
-            $catId = self::$aipdbApiCategories[$catIndex][1];
245
+            $catId = self::$aipdbApiCategories[ $catIndex ][ 1 ];
246 246
 
247 247
             // need another ?
248
-            if ($needAnother !== false){
248
+            if ($needAnother !== false) {
249 249
 
250 250
                 // is a standalone cat ?
251
-                if (self::$aipdbApiCategories[$catIndex][3] === false) {
251
+                if (self::$aipdbApiCategories[ $catIndex ][ 3 ] === false) {
252 252
                     $needAnother = true;
253 253
 
254 254
                 } else {
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
             }
260 260
 
261 261
             // set or add to cats list 
262
-            $catsString = ($catsString === '') ? $catId : $catsString .','.$catId;
262
+            $catsString = ($catsString === '') ? $catId : $catsString . ',' . $catId;
263 263
         }
264 264
 
265
-        if ($needAnother !== false){
265
+        if ($needAnother !== false) {
266 266
             throw new \InvalidArgumentException('Invalid report category parameter given: this category can\'t be used alone.');
267 267
         }
268 268
 
Please login to merge, or discard this patch.
lib/ApiResponse.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@
 block discarded – undo
110 110
      */
111 111
     public function errors(): array
112 112
     {
113
-        return ($this->decodedResponse && property_exists($this->decodedResponse, 'errors')) ? $this->decodedResponse->errors : [];
113
+        return ($this->decodedResponse && property_exists($this->decodedResponse, 'errors')) ? $this->decodedResponse->errors : [ ];
114 114
     }
115 115
 
116 116
     /**
Please login to merge, or discard this patch.