Passed
Push — master ( 3c5c71...77c285 )
by Kris
02:07
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   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      * @access protected
45 45
      * @var array  
46 46
      */
47
-    protected $selfIps = []; 
47
+    protected $selfIps = [ ]; 
48 48
 
49 49
     /**
50 50
      * Constructor
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @param array   $myIps      The Ips/domain name you don't want to display in report messages
55 55
      * 
56 56
      */
57
-    public function __construct(string $apiKey, array $myIps = [])
57
+    public function __construct(string $apiKey, array $myIps = [ ])
58 58
     {
59 59
         $this->aipdbApiKey = $apiKey;
60 60
         $this->selfIps = $myIps;
@@ -98,17 +98,17 @@  discard block
 block discarded – undo
98 98
     public function report(string $ip, string $categories, string $message): ApiResponse
99 99
     {
100 100
          // ip must be set
101
-        if (empty($ip)){
101
+        if (empty($ip)) {
102 102
             throw new \InvalidArgumentException('Ip was empty');
103 103
         }
104 104
 
105 105
         // categories must be set
106
-        if (empty($categories)){
106
+        if (empty($categories)) {
107 107
             throw new \InvalidArgumentException('Categories list was empty');
108 108
         }
109 109
 
110 110
         // message must be set
111
-        if (empty($message)){
111
+        if (empty($message)) {
112 112
             throw new \InvalidArgumentException('Report message was empty');
113 113
         }
114 114
 
@@ -164,16 +164,16 @@  discard block
 block discarded – undo
164 164
     public function bulkReport(string $filePath): ApiResponse
165 165
     {
166 166
         // check file exists
167
-        if (!file_exists($filePath) || !is_file($filePath)){
167
+        if (!file_exists($filePath) || !is_file($filePath)) {
168 168
             throw new \InvalidArgumentException('The file [' . $filePath . '] does not exist.');
169 169
         }
170 170
 
171 171
         // check file is readable
172
-        if (!is_readable($filePath)){
172
+        if (!is_readable($filePath)) {
173 173
             throw new InvalidPermissionException('The file [' . $filePath . '] is not readable.');
174 174
         }
175 175
 
176
-        return $this->apiRequest('bulk-report', [], 'POST', $filePath);
176
+        return $this->apiRequest('bulk-report', [ ], 'POST', $filePath);
177 177
     }
178 178
 
179 179
     /**
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
     public function clearAddress(string $ip): ApiResponse
198 198
     {
199 199
         // ip must be set
200
-        if (empty($ip)){
200
+        if (empty($ip)) {
201 201
             throw new \InvalidArgumentException('IP argument must be set.');
202 202
         }
203 203
 
204
-        return $this->apiRequest('clear-address',  ['ipAddress' => $ip ], "DELETE") ;
204
+        return $this->apiRequest('clear-address', [ 'ipAddress' => $ip ], "DELETE");
205 205
     }
206 206
 
207 207
     /**
@@ -219,12 +219,12 @@  discard block
 block discarded – undo
219 219
     public function check(string $ip, int $maxAgeInDays = 30, bool $verbose = false): ApiResponse
220 220
     {
221 221
         // max age must be less or equal to 365
222
-        if ( $maxAgeInDays > 365 || $maxAgeInDays < 1 ){
222
+        if ($maxAgeInDays > 365 || $maxAgeInDays < 1) {
223 223
             throw new \InvalidArgumentException('maxAgeInDays must be between 1 and 365.');
224 224
         }
225 225
 
226 226
         // ip must be set
227
-        if (empty($ip)){
227
+        if (empty($ip)) {
228 228
             throw new \InvalidArgumentException('ip argument must be set (empty value given)');
229 229
         }
230 230
 
@@ -235,11 +235,11 @@  discard block
 block discarded – undo
235 235
         ];
236 236
 
237 237
         // option
238
-        if ($verbose){
239
-           $data['verbose'] = true;
238
+        if ($verbose) {
239
+           $data[ 'verbose' ] = true;
240 240
         }
241 241
 
242
-        return $this->apiRequest('check', $data, 'GET') ;
242
+        return $this->apiRequest('check', $data, 'GET');
243 243
     }
244 244
 
245 245
     /**
@@ -288,12 +288,12 @@  discard block
 block discarded – undo
288 288
     public function checkBlock(string $network, int $maxAgeInDays = 30): ApiResponse
289 289
     {
290 290
         // max age must be between 1 and 365
291
-        if ($maxAgeInDays > 365 || $maxAgeInDays < 1){
291
+        if ($maxAgeInDays > 365 || $maxAgeInDays < 1) {
292 292
             throw new \InvalidArgumentException('maxAgeInDays must be between 1 and 365 (' . $maxAgeInDays . ' was given)');
293 293
         }
294 294
 
295 295
         // ip must be set
296
-        if (empty($network)){
296
+        if (empty($network)) {
297 297
             throw new \InvalidArgumentException('network argument must be set (empty value given)');
298 298
         }
299 299
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
      */
323 323
     public function blacklist(int $limit = 10000, bool $plainText = false, int $confidenceMinimum = 100): ApiResponse
324 324
     {
325
-        if ($limit < 1){
325
+        if ($limit < 1) {
326 326
             throw new \InvalidArgumentException('limit must be at least 1 (' . $limit . ' was given)');
327 327
         }
328 328
 
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
 
335 335
         // plaintext paremeter has no value and must be added only when true 
336 336
         // (set plaintext=false won't work)
337
-        if ($plainText){
338
-            $data['plaintext'] = $plainText;
337
+        if ($plainText) {
338
+            $data[ 'plaintext' ] = $plainText;
339 339
         }
340 340
 
341 341
         return $this->apiRequest('blacklist', $data, 'GET');
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
         $ch = curl_init(); 
371 371
   
372 372
         // for csv
373
-        if (!empty($csvFilePath)){
374
-            $cfile = new \CurlFile($csvFilePath,  'text/csv', 'csv');
373
+        if (!empty($csvFilePath)) {
374
+            $cfile = new \CurlFile($csvFilePath, 'text/csv', 'csv');
375 375
             //curl file itself return the realpath with prefix of @
376 376
             $data = array('csv' => $cfile);
377 377
         }
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
         $message = str_replace('\\', '', $message);
417 417
 
418 418
         // Remove self ips
419
-        foreach ($this->selfIps as $ip){
419
+        foreach ($this->selfIps as $ip) {
420 420
             $message = str_replace($ip, '*', $message);
421 421
         }
422 422
 
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;
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;
182
-           }
180
+            if ($cat[1] === $categoryId) {
181
+                return $cat;
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   +36 added lines, -36 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
-        ['oit'             , '23', 'IoT Targeted', true],     
131
+        [ 'oit', '23', 'IoT Targeted', true ],     
132 132
     ];
133 133
 
134 134
     /**
@@ -155,8 +155,8 @@  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) {
158
+        foreach (self::$aipdbApiCategories as $cat) {
159
+            if ($cat[ 0 ] === $categoryName) {
160 160
                 return $cat;
161 161
             }
162 162
          }
@@ -176,8 +176,8 @@  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) {
179
+        foreach (self::$aipdbApiCategories as $cat) {
180
+           if ($cat[ 1 ] === $categoryId) {
181 181
                return $cat;
182 182
            }
183 183
         }
@@ -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/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/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 && $this->decodedResponse->errors) ? $this->decodedResponse->errors : [];
113
+        return ($this->decodedResponse && $this->decodedResponse->errors) ? $this->decodedResponse->errors : [ ];
114 114
     }
115 115
 
116 116
     /**
Please login to merge, or discard this patch.