From 8ddcc85f07707cad4693a68054e86a923745559d Mon Sep 17 00:00:00 2001 From: Marco Cesarato Date: Wed, 11 Mar 2020 09:37:08 +0100 Subject: [PATCH] fix: directory with phar host prefix issue Fix directory with phar host prefix issue Update Copyright year Updated bin files permissions New version 0.5.0.70 Closes 4 --- README.md | 2 +- bin/build | 0 bin/composer | Bin bin/fix-cs | 0 bin/fix-cs-all | 0 bin/lint | 0 bin/pre-commit | 0 bin/run | 0 dist/scanner | Bin 642808 -> 643085 bytes dist/version | 2 +- src/Application.php | 20 +++++++++++++++----- src/Argument.php | 2 +- src/Argv.php | 2 +- src/CSV.php | 2 +- src/Console.php | 4 ++-- src/Definitions.php | 2 +- src/Deobfuscator.php | 2 +- src/Flag.php | 2 +- src/index.php | 16 ++++++++-------- 19 files changed, 33 insertions(+), 23 deletions(-) mode change 100644 => 100755 bin/build mode change 100644 => 100755 bin/composer mode change 100644 => 100755 bin/fix-cs mode change 100644 => 100755 bin/fix-cs-all mode change 100644 => 100755 bin/lint mode change 100644 => 100755 bin/pre-commit mode change 100644 => 100755 bin/run diff --git a/README.md b/README.md index f1f3fd9..f853337 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # AMWSCAN - PHP Antimalware Scanner -**Version:** 0.5.0.69 beta +**Version:** 0.5.0.70 beta **Github:** https://github.com/marcocesarato/PHP-Antimalware-Scanner diff --git a/bin/build b/bin/build old mode 100644 new mode 100755 diff --git a/bin/composer b/bin/composer old mode 100644 new mode 100755 diff --git a/bin/fix-cs b/bin/fix-cs old mode 100644 new mode 100755 diff --git a/bin/fix-cs-all b/bin/fix-cs-all old mode 100644 new mode 100755 diff --git a/bin/lint b/bin/lint old mode 100644 new mode 100755 diff --git a/bin/pre-commit b/bin/pre-commit old mode 100644 new mode 100755 diff --git a/bin/run b/bin/run old mode 100644 new mode 100755 diff --git a/dist/scanner b/dist/scanner index caf34aee47c90eccb50b5de6c8e3223c76cb224a..7240764aef22d7455d204dc1f842fb920f4da551 100644 GIT binary patch delta 821 zcmew{SG{+E`UY7kfi)``7!np`#DVCZ$D6e$>q<#*g9Oak7#MD3Uzr>rC0h^T>#{O1 zeB@`lzKxLq3^;+Lo=b3ia7lhqDvJcf6cBCgGUpMpqRhOM)C#?Vi~?UKh$0Z}AIKUC zQ^XB4$vHo-I6o&9q%6P*q6|cHZfEr0#yI(nl$-&`4Pu@Q45@L)X2EoF0ChSRrI&%U zeUX7^1JTh}-`t&SB`vQH(zMN#gCTZ9mN85dJIK1=Fp!=PKtF<%fas08n<6K7NOv+B z8BAZV!?=C(DVZ2XCUb+$8gl*2EDAudd55AKn^#;W>IP~FaRni zC;CfImea7oCEfU2Y;&oGW2yvp?HZb!_x4UOQ{m#&*V5wRRM1igN-ZfZ%2OyxP0Ue% zTBcBtSdziTIo;HrQGttI zF*6Xe05K~NvjH(X5OZv=pUnBr1Y`)%-dr{rYhTA@5eL$)v>M+2zhiyUsU-^xTY<@y J!QIK%2>{mm40Heh delta 663 zcmeBOp#Ed7`UY7kf&D8O7(6!^#ewK2kEh<6tScqK4H7VCV_?|(P-1d`lx#hSugl87 zP*vBra~mTA7;pkfJ(uA4;FA2JR2B({DInU~WzHjHMVWaisTFz!83ndX5Jez5&FYma zOc6KGBZiV5nviu7m010P1usN-qOx z`yvC;2BO{XGDl6el9o3IY1(GW!LT-Jk^xK;JIK1=Fp!=PKtF<%fasr7&ToV%nf&op zBa@-!afrfP|Ol0%t-U()tt&TPW&D^~Is3{x7>?50Zosp4o26~`0H#M&WYobB5umNQz*KxNt|O<@FLCLm@8Viq7~1!6WJ zW(Q)9?USZ(elUR<<8g{}C96#O))ObT@JyTg^^~$DLq}Tm#8U4~zy!hI?&RwP06@Fn AKmY&$ diff --git a/dist/version b/dist/version index 9c6991c..0c991ac 100644 --- a/dist/version +++ b/dist/version @@ -1 +1 @@ -0.5.0.69 \ No newline at end of file +0.5.0.70 \ No newline at end of file diff --git a/src/Application.php b/src/Application.php index 7b60f38..858087d 100644 --- a/src/Application.php +++ b/src/Application.php @@ -4,7 +4,7 @@ * PHP Antimalware Scanner. * * @author Marco Cesarato - * @copyright Copyright (c) 2019 + * @copyright Copyright (c) 2020 * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License * * @see https://github.com/marcocesarato/PHP-Antimalware-Scanner @@ -34,7 +34,7 @@ class Application * * @var string */ - public static $VERSION = '0.5.0.69'; + public static $VERSION = '0.5.0.70'; /** * Root path. @@ -195,11 +195,11 @@ public function __construct() private function init() { if (self::$ROOT === './') { - self::$ROOT = __DIR__; + self::$ROOT = self::currentDirectory(); } if (self::$SCAN_PATH === './') { - self::$SCAN_PATH = __DIR__; + self::$SCAN_PATH = self::currentDirectory(); } self::$PATH_QUARANTINE = self::$ROOT . self::$PATH_QUARANTINE; self::$PATH_LOGS = self::$ROOT . self::$PATH_LOGS; @@ -808,7 +808,7 @@ private function scan($iterator) } } elseif (in_array($confirmation, array('2'))) { // Move to quarantine - $quarantine = self::$PATH_QUARANTINE . str_replace(realpath(__DIR__), '', $_FILE_PATH); + $quarantine = self::$PATH_QUARANTINE . str_replace(realpath(self::currentDirectory()), '', $_FILE_PATH); if (!is_dir(dirname($quarantine))) { if (!mkdir($concurrentDirectory = dirname($quarantine), 0755, true) && !is_dir($concurrentDirectory)) { @@ -1073,4 +1073,14 @@ private function convertToBytes($from) return $number * pow(1024, $pow); } + + /** + * Return real current path. + * + * @return string|string[]|null + */ + public static function currentDirectory() + { + return preg_replace('/^phar:\/\//i', '', __DIR__); + } } diff --git a/src/Argument.php b/src/Argument.php index 4eb8a7a..4d44f28 100644 --- a/src/Argument.php +++ b/src/Argument.php @@ -4,7 +4,7 @@ * PHP Antimalware Scanner. * * @author Marco Cesarato - * @copyright Copyright (c) 2019 + * @copyright Copyright (c) 2020 * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License * * @see https://github.com/marcocesarato/PHP-Antimalware-Scanner diff --git a/src/Argv.php b/src/Argv.php index 9a302fa..f11a449 100644 --- a/src/Argv.php +++ b/src/Argv.php @@ -4,7 +4,7 @@ * PHP Antimalware Scanner. * * @author Marco Cesarato - * @copyright Copyright (c) 2019 + * @copyright Copyright (c) 2020 * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License * * @see https://github.com/marcocesarato/PHP-Antimalware-Scanner diff --git a/src/CSV.php b/src/CSV.php index 1d857d1..a50f045 100644 --- a/src/CSV.php +++ b/src/CSV.php @@ -4,7 +4,7 @@ * PHP Antimalware Scanner. * * @author Marco Cesarato - * @copyright Copyright (c) 2019 + * @copyright Copyright (c) 2020 * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License * * @see https://github.com/marcocesarato/PHP-Antimalware-Scanner diff --git a/src/Console.php b/src/Console.php index cc0bb72..db807f5 100644 --- a/src/Console.php +++ b/src/Console.php @@ -4,7 +4,7 @@ * PHP Antimalware Scanner. * * @author Marco Cesarato - * @copyright Copyright (c) 2019 + * @copyright Copyright (c) 2020 * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License * * @see https://github.com/marcocesarato/PHP-Antimalware-Scanner @@ -496,7 +496,7 @@ public static function helplist($type = null) public static function helper() { self::displayTitle('Help', 'black', 'cyan'); - $dir = __DIR__; + $dir = Application::currentDirectory(); $help = << - * @copyright Copyright (c) 2019 + * @copyright Copyright (c) 2020 * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License * * @see https://github.com/marcocesarato/PHP-Antimalware-Scanner diff --git a/src/Deobfuscator.php b/src/Deobfuscator.php index a11ef13..f0540c8 100644 --- a/src/Deobfuscator.php +++ b/src/Deobfuscator.php @@ -4,7 +4,7 @@ * PHP Antimalware Scanner. * * @author Marco Cesarato - * @copyright Copyright (c) 2019 + * @copyright Copyright (c) 2020 * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License * * @see https://github.com/marcocesarato/PHP-Antimalware-Scanner diff --git a/src/Flag.php b/src/Flag.php index 40455a5..40b7875 100644 --- a/src/Flag.php +++ b/src/Flag.php @@ -4,7 +4,7 @@ * PHP Antimalware Scanner. * * @author Marco Cesarato - * @copyright Copyright (c) 2019 + * @copyright Copyright (c) 2020 * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License * * @see https://github.com/marcocesarato/PHP-Antimalware-Scanner diff --git a/src/index.php b/src/index.php index 3408d24..7e95030 100644 --- a/src/index.php +++ b/src/index.php @@ -2,14 +2,14 @@ namespace marcocesarato\amwscan; -include 'Argument.php'; -include 'Argv.php'; -include 'Console.php'; -include 'CSV.php'; -include 'Definitions.php'; -include 'Flag.php'; -include 'Deobfuscator.php'; -include 'Application.php'; +include './Argument.php'; +include './Argv.php'; +include './Console.php'; +include './CSV.php'; +include './Definitions.php'; +include './Flag.php'; +include './Deobfuscator.php'; +include './Application.php'; $isCLI = (php_sapi_name() === 'cli'); if (!$isCLI) {