@@ -38,8 +38,8 @@ |
||
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 | } |
@@ -92,7 +92,7 @@ discard block |
||
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 |
||
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 |
||
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 | { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @access protected |
40 | 40 | * @var array |
41 | 41 | */ |
42 | - protected $selfIps = []; |
|
42 | + protected $selfIps = [ ]; |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Constructor |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param array $myIps The Ips/domain name you don't want to display in report messages |
50 | 50 | * |
51 | 51 | */ |
52 | - public function __construct(string $apiKey, array $myIps = []) |
|
52 | + public function __construct(string $apiKey, array $myIps = [ ]) |
|
53 | 53 | { |
54 | 54 | $this->aipdbApiKey = $apiKey; |
55 | 55 | $this->selfIps = $myIps; |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | public function report(string $ip, string $categories, string $message): ApiResponse |
94 | 94 | { |
95 | 95 | // ip must be set |
96 | - if (empty($ip)){ |
|
96 | + if (empty($ip)) { |
|
97 | 97 | throw new \InvalidArgumentException('Ip was empty'); |
98 | 98 | } |
99 | 99 | |
100 | 100 | // categories must be set |
101 | - if (empty($categories)){ |
|
101 | + if (empty($categories)) { |
|
102 | 102 | throw new \InvalidArgumentException('Categories list was empty'); |
103 | 103 | } |
104 | 104 | |
105 | 105 | // message must be set |
106 | - if (empty($message)){ |
|
106 | + if (empty($message)) { |
|
107 | 107 | throw new \InvalidArgumentException('Report message was empty'); |
108 | 108 | } |
109 | 109 | |
@@ -159,16 +159,16 @@ discard block |
||
159 | 159 | public function bulkReport(string $filePath): ApiResponse |
160 | 160 | { |
161 | 161 | // check file exists |
162 | - if (!file_exists($filePath) || !is_file($filePath)){ |
|
162 | + if (!file_exists($filePath) || !is_file($filePath)) { |
|
163 | 163 | throw new \InvalidArgumentException('The file [' . $filePath . '] does not exist.'); |
164 | 164 | } |
165 | 165 | |
166 | 166 | // check file is readable |
167 | - if (!is_readable($filePath)){ |
|
167 | + if (!is_readable($filePath)) { |
|
168 | 168 | throw new InvalidPermissionException('The file [' . $filePath . '] is not readable.'); |
169 | 169 | } |
170 | 170 | |
171 | - return $this->apiRequest('bulk-report', [], 'POST', $filePath); |
|
171 | + return $this->apiRequest('bulk-report', [ ], 'POST', $filePath); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | public function clearAddress(string $ip): ApiResponse |
193 | 193 | { |
194 | 194 | // ip must be set |
195 | - if (empty($ip)){ |
|
195 | + if (empty($ip)) { |
|
196 | 196 | throw new \InvalidArgumentException('IP argument must be set.'); |
197 | 197 | } |
198 | 198 | |
199 | - return $this->apiRequest('clear-address', ['ipAddress' => $ip ], "DELETE") ; |
|
199 | + return $this->apiRequest('clear-address', [ 'ipAddress' => $ip ], "DELETE"); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -214,12 +214,12 @@ discard block |
||
214 | 214 | public function check(string $ip, int $maxAgeInDays = 30, bool $verbose = false): ApiResponse |
215 | 215 | { |
216 | 216 | // max age must be less or equal to 365 |
217 | - if ($maxAgeInDays > 365 || $maxAgeInDays < 1){ |
|
217 | + if ($maxAgeInDays > 365 || $maxAgeInDays < 1) { |
|
218 | 218 | throw new \InvalidArgumentException('maxAgeInDays must be between 1 and 365 (' . $maxAgeInDays . ' was given)'); |
219 | 219 | } |
220 | 220 | |
221 | 221 | // ip must be set |
222 | - if (empty($ip)){ |
|
222 | + if (empty($ip)) { |
|
223 | 223 | throw new \InvalidArgumentException('ip argument must be set (empty value given)'); |
224 | 224 | } |
225 | 225 | |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | ]; |
231 | 231 | |
232 | 232 | // option |
233 | - if ($verbose){ |
|
234 | - $data['verbose'] = true; |
|
233 | + if ($verbose) { |
|
234 | + $data[ 'verbose' ] = true; |
|
235 | 235 | } |
236 | 236 | |
237 | - return $this->apiRequest('check', $data, 'GET') ; |
|
237 | + return $this->apiRequest('check', $data, 'GET'); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -283,12 +283,12 @@ discard block |
||
283 | 283 | public function checkBlock(string $network, int $maxAgeInDays = 30): ApiResponse |
284 | 284 | { |
285 | 285 | // max age must be between 1 and 365 |
286 | - if ($maxAgeInDays > 365 || $maxAgeInDays < 1){ |
|
286 | + if ($maxAgeInDays > 365 || $maxAgeInDays < 1) { |
|
287 | 287 | throw new \InvalidArgumentException('maxAgeInDays must be between 1 and 365 (' . $maxAgeInDays . ' was given)'); |
288 | 288 | } |
289 | 289 | |
290 | 290 | // ip must be set |
291 | - if (empty($network)){ |
|
291 | + if (empty($network)) { |
|
292 | 292 | throw new \InvalidArgumentException('network argument must be set (empty value given)'); |
293 | 293 | } |
294 | 294 | |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function blacklist(int $limit = 10000, bool $plainText = false, int $confidenceMinimum = 100): ApiResponse |
319 | 319 | { |
320 | - if ($limit < 1){ |
|
320 | + if ($limit < 1) { |
|
321 | 321 | throw new \InvalidArgumentException('limit must be at least 1 (' . $limit . ' was given)'); |
322 | 322 | } |
323 | 323 | |
@@ -329,8 +329,8 @@ discard block |
||
329 | 329 | |
330 | 330 | // plaintext paremeter has no value and must be added only when true |
331 | 331 | // (set plaintext=false won't work) |
332 | - if ($plainText){ |
|
333 | - $data['plaintext'] = $plainText; |
|
332 | + if ($plainText) { |
|
333 | + $data[ 'plaintext' ] = $plainText; |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | return $this->apiRequest('blacklist', $data, 'GET'); |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | $ch = curl_init(); |
366 | 366 | |
367 | 367 | // for csv |
368 | - if (!empty($csvFilePath)){ |
|
369 | - $cfile = new \CurlFile($csvFilePath, 'text/csv', 'csv'); |
|
368 | + if (!empty($csvFilePath)) { |
|
369 | + $cfile = new \CurlFile($csvFilePath, 'text/csv', 'csv'); |
|
370 | 370 | //curl file itself return the realpath with prefix of @ |
371 | 371 | $data = array('csv' => $cfile); |
372 | 372 | } |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | $message = str_replace('\\', '', $message); |
412 | 412 | |
413 | 413 | // Remove self ips |
414 | - foreach ($this->selfIps as $ip){ |
|
414 | + foreach ($this->selfIps as $ip) { |
|
415 | 415 | $message = str_replace($ip, '*', $message); |
416 | 416 | } |
417 | 417 |
@@ -52,82 +52,82 @@ discard block |
||
52 | 52 | protected $aipdbApiCategories = [ |
53 | 53 | |
54 | 54 | // Altering DNS records resulting in improper redirection. |
55 | - ['dns-c' , '1', 'DNS Compromise', true], |
|
55 | + [ 'dns-c', '1', 'DNS Compromise', true ], |
|
56 | 56 | |
57 | 57 | // Falsifying domain server cache (cache poisoning). |
58 | - ['dns-p' , '2', 'DNS Poisoning', true], |
|
58 | + [ 'dns-p', '2', 'DNS Poisoning', true ], |
|
59 | 59 | |
60 | 60 | // Fraudulent orders. |
61 | - ['fraud-orders' , '3', 'Fraud Orders', true], |
|
61 | + [ 'fraud-orders', '3', 'Fraud Orders', true ], |
|
62 | 62 | |
63 | 63 | // Participating in distributed denial-of-service (usually part of botnet). |
64 | - ['ddos' , '4', 'DDoS Attack', true], |
|
64 | + [ 'ddos', '4', 'DDoS Attack', true ], |
|
65 | 65 | |
66 | 66 | // |
67 | - ['ftp-bf' , '5', 'FTP Brute-Force', true], |
|
67 | + [ 'ftp-bf', '5', 'FTP Brute-Force', true ], |
|
68 | 68 | |
69 | 69 | // Oversized IP packet. |
70 | - ['pingdeath' , '6', 'Ping of Death', true], |
|
70 | + [ 'pingdeath', '6', 'Ping of Death', true ], |
|
71 | 71 | |
72 | 72 | // Phishing websites and/or email. |
73 | - ['phishing' , '7', 'Phishing', true], |
|
73 | + [ 'phishing', '7', 'Phishing', true ], |
|
74 | 74 | |
75 | 75 | // |
76 | - ['fraudvoip' , '8', 'Fraud VoIP', true], |
|
76 | + [ 'fraudvoip', '8', 'Fraud VoIP', true ], |
|
77 | 77 | |
78 | 78 | // Open proxy, open relay, or Tor exit node. |
79 | - ['openproxy' , '9', 'Open Proxy', true], |
|
79 | + [ 'openproxy', '9', 'Open Proxy', true ], |
|
80 | 80 | |
81 | 81 | // Comment/forum spam, HTTP referer spam, or other CMS spam. |
82 | - ['webspam' , '10', 'Web Spam', true], |
|
82 | + [ 'webspam', '10', 'Web Spam', true ], |
|
83 | 83 | |
84 | 84 | // Spam email content, infected attachments, and phishing emails. Note: Limit comments to only relevent |
85 | 85 | // information (instead of log dumps) and be sure to remove PII if you want to remain anonymous. |
86 | - ['emailspam' , '11', 'Email Spam', true], |
|
86 | + [ 'emailspam', '11', 'Email Spam', true ], |
|
87 | 87 | |
88 | 88 | // CMS blog comment spam. |
89 | - ['blogspam' , '12', 'Blog Spam', true], |
|
89 | + [ 'blogspam', '12', 'Blog Spam', true ], |
|
90 | 90 | |
91 | 91 | // Conjunctive category. |
92 | - ['vpnip' , '13', 'VPN IP', false], // to check alone ?? |
|
92 | + [ 'vpnip', '13', 'VPN IP', false ], // to check alone ?? |
|
93 | 93 | |
94 | 94 | // Scanning for open ports and vulnerable services. |
95 | - ['scan' , '14', 'Port Scan', true], |
|
95 | + [ 'scan', '14', 'Port Scan', true ], |
|
96 | 96 | |
97 | 97 | // |
98 | - ['hack' , '15', 'Hacking', true], |
|
98 | + [ 'hack', '15', 'Hacking', true ], |
|
99 | 99 | |
100 | 100 | // Attempts at SQL injection. |
101 | - ['sql' , '16', 'SQL Injection', true], |
|
101 | + [ 'sql', '16', 'SQL Injection', true ], |
|
102 | 102 | |
103 | 103 | // Email sender spoofing. |
104 | - ['spoof' , '17', 'Spoofing', true], |
|
104 | + [ 'spoof', '17', 'Spoofing', true ], |
|
105 | 105 | |
106 | 106 | // Credential brute-force attacks on webpage logins and services like SSH, FTP, SIP, SMTP, RDP, etc. |
107 | 107 | // This category is seperate from DDoS attacks. |
108 | - ['brute' , '18', 'Brute-Force', true], |
|
108 | + [ 'brute', '18', 'Brute-Force', true ], |
|
109 | 109 | |
110 | 110 | // Webpage scraping (for email addresses, content, etc) and crawlers that do not honor robots.txt. |
111 | 111 | // Excessive requests and user agent spoofing can also be reported here. |
112 | - ['badbot' , '19', 'Bad Web Bot', true], |
|
112 | + [ 'badbot', '19', 'Bad Web Bot', true ], |
|
113 | 113 | |
114 | 114 | // Host is likely infected with malware and being used for other attacks or to host malicious content. |
115 | 115 | // The host owner may not be aware of the compromise. This category is often used in combination |
116 | 116 | // with other attack categories. |
117 | - ['explhost' , '20', 'Exploited Host', true], |
|
117 | + [ 'explhost', '20', 'Exploited Host', true ], |
|
118 | 118 | |
119 | 119 | // Attempts to probe for or exploit installed web applications such as a CMS |
120 | 120 | // like WordPress/Drupal, e-commerce solutions, forum software, phpMyAdmin and |
121 | 121 | // various other software plugins/solutions. |
122 | - ['webattack' , '21', 'Web App Attack', true ], |
|
122 | + [ 'webattack', '21', 'Web App Attack', true ], |
|
123 | 123 | |
124 | 124 | // Secure Shell (SSH) abuse. Use this category in combination |
125 | 125 | // with more specific categories. |
126 | - ['ssh' , '22', 'SSH', false], |
|
126 | + [ 'ssh', '22', 'SSH', false ], |
|
127 | 127 | |
128 | 128 | // Abuse was targeted at an "Internet of Things" type device. Include |
129 | 129 | // information about what type of device was targeted in the comments. |
130 | - ['oit' , '23', 'IoT Targeted', true], |
|
130 | + [ 'oit', '23', 'IoT Targeted', true ], |
|
131 | 131 | ]; |
132 | 132 | |
133 | 133 | /** |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function getCategoryIdbyName(string $categoryName) |
154 | 154 | { |
155 | - foreach ($this->aipdbApiCategories as $cat){ |
|
156 | - if ($cat[0] === $categoryName) { |
|
155 | + foreach ($this->aipdbApiCategories as $cat) { |
|
156 | + if ($cat[ 0 ] === $categoryName) { |
|
157 | 157 | return $cat; |
158 | 158 | } |
159 | 159 | } |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public function getCategoryNameById(string $categoryId) |
174 | 174 | { |
175 | - foreach ($this->aipdbApiCategories as $cat){ |
|
176 | - if ($cat[1] === $categoryId) { |
|
175 | + foreach ($this->aipdbApiCategories as $cat) { |
|
176 | + if ($cat[ 1 ] === $categoryId) { |
|
177 | 177 | return $cat; |
178 | 178 | } |
179 | 179 | } |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | protected function getCategoryIndex(string $value, int $index) |
195 | 195 | { |
196 | 196 | $i = 0; |
197 | - foreach ($this->aipdbApiCategories as $cat){ |
|
198 | - if ($cat[$index] === $value) { |
|
197 | + foreach ($this->aipdbApiCategories as $cat) { |
|
198 | + if ($cat[ $index ] === $value) { |
|
199 | 199 | return $i; |
200 | 200 | } |
201 | 201 | $i++; |
@@ -229,21 +229,21 @@ discard block |
||
229 | 229 | foreach ($cats as $cat) { |
230 | 230 | |
231 | 231 | // get index on our array of categories |
232 | - $catIndex = is_numeric($cat) ? $this->getCategoryIndex($cat, 1) : $this->getCategoryIndex($cat, 0); |
|
232 | + $catIndex = is_numeric($cat) ? $this->getCategoryIndex($cat, 1) : $this->getCategoryIndex($cat, 0); |
|
233 | 233 | |
234 | 234 | // check if found |
235 | - if ($catIndex === false ){ |
|
235 | + if ($catIndex === false) { |
|
236 | 236 | throw new \InvalidArgumentException('Invalid report category was given.'); |
237 | 237 | } |
238 | 238 | |
239 | 239 | // get Id |
240 | - $catId = $this->aipdbApiCategories[$catIndex][1]; |
|
240 | + $catId = $this->aipdbApiCategories[ $catIndex ][ 1 ]; |
|
241 | 241 | |
242 | 242 | // need another ? |
243 | - if ($needAnother !== false){ |
|
243 | + if ($needAnother !== false) { |
|
244 | 244 | |
245 | 245 | // is a standalone cat ? |
246 | - if ($this->aipdbApiCategories[$catIndex][3] === false) { |
|
246 | + if ($this->aipdbApiCategories[ $catIndex ][ 3 ] === false) { |
|
247 | 247 | $needAnother = true; |
248 | 248 | |
249 | 249 | } else { |
@@ -254,10 +254,10 @@ discard block |
||
254 | 254 | } |
255 | 255 | |
256 | 256 | // set or add to cats list |
257 | - $catsString = ($catsString === '') ? $catId : $catsString .','.$catId; |
|
257 | + $catsString = ($catsString === '') ? $catId : $catsString . ',' . $catId; |
|
258 | 258 | } |
259 | 259 | |
260 | - if ($needAnother !== false){ |
|
260 | + if ($needAnother !== false) { |
|
261 | 261 | throw new \InvalidArgumentException('Invalid report category parameter given: this category can\'t be used alone.'); |
262 | 262 | } |
263 | 263 |