Skip to content

Commit

Permalink
v0.9.11
Browse files Browse the repository at this point in the history
**Changed**
-   **fixed** strict type exceptions (v0.9.10 is broken)
-   **fixed** empty json in blacklist
  • Loading branch information
kristuff authored Jan 30, 2021
2 parents afece83 + 45a36c1 commit 87147b9
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion bin/abuseipdb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.9.10
* @version 0.9.11
* @copyright 2020-2021 Kristuff
*/

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "kristuff/abuseipdb-cli",
"description": "A CLI tool to check/report IP addresses with AbuseIPDB API V2",
"keywords": ["abuseIPDB", "API", "Client"],
"type": "library",
"license": "MIT",
"authors": [
Expand Down
4 changes: 2 additions & 2 deletions src/AbstractClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.9.10
* @version 0.9.11
* @copyright 2020-2021 Kristuff
*/
namespace Kristuff\AbuseIPDB;
Expand Down Expand Up @@ -42,7 +42,7 @@ abstract class AbstractClient extends ShellErrorHandler
/**
* @var string
*/
const VERSION = 'v0.9.10';
const VERSION = 'v0.9.11';

/**
* @var QuietApiHandler
Expand Down
10 changes: 5 additions & 5 deletions src/AbuseIPDBClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.9.10
* @version 0.9.11
* @copyright 2020-2021 Kristuff
*/
namespace Kristuff\AbuseIPDB;
Expand Down Expand Up @@ -170,7 +170,7 @@ protected static function printHelp(): void
Console::log(Console::text(' -C, --check ', 'white') . Console::text('IP', 'yellow', 'underline'));
Console::log(' Performs a check request for the given IP address. A valid IPv4 or IPv6 address is required.', 'lightgray');
Console::log();
Console::log(Console::text(' -K, --check-block ', 'white') . Console::text('network', 'yellow', 'underline'));
Console::log(Console::text(' -K, --check-block ', 'white') . Console::text('NETWORK', 'yellow', 'underline'));
Console::log(' Performs a check-block request for the given network. A valid subnet (v4 or v6) denoted with ', 'lightgray');
Console::log(' CIDR notation is required.', 'lightgray');
Console::log();
Expand Down Expand Up @@ -223,7 +223,7 @@ protected static function printHelp(): void
Console::log(' Prints the current version. If given, all next arguments are ignored.', 'lightgray');
Console::log();
Console::log(Console::text(' -S, --save-key ', 'white') . Console::text('KEY', 'yellow', 'underline'));
Console::log(' Save the given API key in the configuration file. Required writing permissions on the config directory. ', 'lightgray');
Console::log(' Save the given API key in the configuration file. Requires writing permissions on the config directory. ', 'lightgray');
Console::log();
}

Expand Down Expand Up @@ -471,7 +471,7 @@ protected static function getBlacklist(array $arguments): void
{
self::printTitle(Console::text(' ► Get Blacklist ', 'darkgray'));

$plainText = self::$outputFormat === self::OUTPUT_PLAINTEXT;
$plainText = (self::$outputFormat === self::OUTPUT_PLAINTEXT);
$limit = self::getNumericParameter($arguments,'l', 'limit', 1000);
$scoreMin = self::getNumericParameter($arguments,'s', 'score', 100);

Expand All @@ -495,7 +495,7 @@ protected static function getBlacklist(array $arguments): void
// ✓ Done: print deleted report number
switch (self::$outputFormat){
case self::OUTPUT_JSON:
echo json_encode($response, JSON_PRETTY_PRINT);
echo json_encode($decodedResponse, JSON_PRETTY_PRINT);
break;

case self::OUTPUT_DEFAULT:
Expand Down
2 changes: 1 addition & 1 deletion src/BulkReportTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.9.10
* @version 0.9.11
* @copyright 2020-2021 Kristuff
*/
namespace Kristuff\AbuseIPDB;
Expand Down
2 changes: 1 addition & 1 deletion src/CheckBlockTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.9.10
* @version 0.9.11
* @copyright 2020-2021 Kristuff
*/
namespace Kristuff\AbuseIPDB;
Expand Down
2 changes: 1 addition & 1 deletion src/CheckTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.9.10
* @version 0.9.11
* @copyright 2020-2021 Kristuff
*/
namespace Kristuff\AbuseIPDB;
Expand Down
8 changes: 4 additions & 4 deletions src/ShellErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.9.10
* @version 0.9.11
* @copyright 2020-2021 Kristuff
*/
namespace Kristuff\AbuseIPDB;
Expand All @@ -39,7 +39,7 @@ abstract class ShellErrorHandler extends ShellUtils
*
* @return bool
*/
protected static function hasErrors(object $response, bool $checkForEmpty = true): bool
protected static function hasErrors(?object $response = null, bool $checkForEmpty = true): bool
{
return $checkForEmpty ? self::parseErrors($response) || self::checkForEmpty($response) : self::parseErrors($response);
}
Expand All @@ -54,7 +54,7 @@ protected static function hasErrors(object $response, bool $checkForEmpty = true
*
* @return bool
*/
private static function parseErrors(object $response): bool
private static function parseErrors(?object $response = null): bool
{
if (isset($response) && isset($response->errors)){
switch (self::$outputFormat){
Expand Down Expand Up @@ -235,7 +235,7 @@ private static function getErrorDetail(object $error, string $field, ?string $pa
*
* @return bool
*/
protected static function checkForEmpty(object $response): bool
protected static function checkForEmpty(?object $response = null): bool
{
// check for empty response ?
if ( empty($response) || empty($response->data) ){
Expand Down
14 changes: 7 additions & 7 deletions src/ShellUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.9.10
* @version 0.9.11
* @copyright 2020-2021 Kristuff
*/
namespace Kristuff\AbuseIPDB;
Expand Down Expand Up @@ -125,10 +125,6 @@ protected static function clearTempMessage(): void
protected static function printLogo(): void
{
if (self::isDefaultOuput()) {
//Console::log(" _ _ _ __ __ ", "darkgray");
//Console::log(" | |___ _(_)__| |_ _ _ / _|/ _| ", "darkgray");
//Console::log(" | / / '_| (_-< _| || | _| _| ", "darkgray");
//Console::log(" |_\_\_| |_/__/\__|\_,_|_| |_| ", "darkgray");
Console::log(" _ ___ ___ ___ ___ ", "darkgray");
Console::log(" __ _| |__ _ _ ___ ___|_ _| _ \ \| _ ) ", "darkgray");
Console::log(" / _` | '_ \ || (_-</ -_)| || _/ |) | _ \ ", "darkgray");
Expand Down Expand Up @@ -177,7 +173,11 @@ protected static function printBanner(): void
if (self::isDefaultOuput()) {
Console::log();
Console::log( Console::text(' Kristuff/AbuseIPDB-client ', 'darkgray') . Console::text(' ' . AbuseIPDBClient::VERSION . ' ', 'white', 'blue'));
Console::log(Console::text(' Made with ', 'darkgray') . Console::text('', 'red') . Console::text(' in France | © 2020-2021 Kristuff', 'darkgray'));
Console::log(Console::text(' Made with ', 'darkgray') . Console::text('', 'red') . Console::text(' in France', 'darkgray'));
Console::log(Console::text(' © 2020-2021 Kristuff (', 'darkgray').
Console::text('https://github.com/kristuff', 'darkgray', 'underlined').
Console::text(')', 'darkgray')
);
Console::log();
}
}
Expand Down Expand Up @@ -258,7 +258,7 @@ protected static function getScoreBadge(int $score, string $padding = ' '): stri
$scoreBackgroundColor = 'red';
}

$badge = str_pad($score, 3, ' ',STR_PAD_LEFT);
$badge = str_pad(strval($score), 3, ' ',STR_PAD_LEFT);
return Console::text($padding.$badge.$padding, $scoreforegroundColor, $scoreBackgroundColor);
}
}
2 changes: 1 addition & 1 deletion src/UtilsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.9.10
* @version 0.9.11
* @copyright 2020-2021 Kristuff
*/
namespace Kristuff\AbuseIPDB;
Expand Down

0 comments on commit 87147b9

Please sign in to comment.