Skip to content

Commit

Permalink
fix: disable html report when not on report mode
Browse files Browse the repository at this point in the history
Ref: #36
  • Loading branch information
marcocesarato committed Oct 3, 2021
1 parent fe59d56 commit 49a5aad
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,6 @@ public function __construct()
self::$pathBackups = Path::get(self::$root . self::$pathBackups);
self::$pathDeobfuscate = Path::get(self::$root . self::$pathDeobfuscate);

if (!self::isCli()) {
self::$settings['silent'] = true;
self::$settings['report'] = false;
self::$settings['report-mode'] = false;
self::$prompt = 'skip';
}

self::$inited = true;
}
}
Expand Down Expand Up @@ -419,6 +412,7 @@ public function run($args = null)
*/
private function arguments($args = null)
{
$isCLI = self::isCli();
self::$argv = new Argv(self::getLowerName(), self::getDescription());

// Arguments
Expand Down Expand Up @@ -446,7 +440,7 @@ private function arguments($args = null)
self::$argv->addFlag('functions', ['default' => false, 'has_value' => true, 'help' => 'Define functions to search']);
self::$argv->addFlag('whitelist-only-path', ['default' => false, 'help' => 'Check on whitelist only file path and not line number']);
self::$argv->addFlag('max-filesize', ['default' => -1, 'has_value' => true, 'value_name' => 'filesize', 'help' => 'Set max filesize to scan']);
self::$argv->addFlag('silent', ['default' => false, 'help' => 'No output and prompt']);
self::$argv->addFlag('silent', ['default' => !$isCLI, 'help' => 'No output and prompt']);
self::$argv->addFlag('ignore-paths', ['alias' => '--ignore-path', 'default' => null, 'has_value' => true, 'value_name' => 'paths', 'help' => "Ignore path/s, for multiple value separate with comma.\nWildcards are enabled ex. /path/*/cache or /path/*.log"]);
self::$argv->addFlag('filter-paths', ['alias' => '--filter-path', 'default' => null, 'has_value' => true, 'value_name' => 'paths', 'help' => "Filter path/s, for multiple value separate with comma.\nWildcards are enabled ex. /path/*/htdocs or /path/*.php"]);
self::$argv->addFlag('auto-clean', ['default' => false, 'help' => 'Auto clean code (without confirmation, use with caution)']);
Expand All @@ -464,7 +458,7 @@ private function arguments($args = null)
self::$argv->addFlag('path-report', ['default' => self::$pathReport, 'has_value' => true, 'value_name' => 'path', 'help' => "Set report log file path and name.\nNote that name will be appended with .log or .html extension."]);
self::$argv->addFlag('disable-colors', ['alias' => ['--no-colors', '--no-color'], 'default' => false, 'help' => 'Disable CLI colors']);
self::$argv->addFlag('disable-cache', ['alias' => '--no-cache', 'default' => false, 'help' => 'Disable Cache']);
self::$argv->addFlag('disable-report', ['alias' => '--no-report', 'default' => false, 'help' => 'Disable report generation']);
self::$argv->addFlag('disable-report', ['alias' => '--no-report', 'default' => !$isCLI, 'help' => 'Disable report generation']);
self::$argv->addFlag('disable-checksum', ['alias' => ['--no-checksum', '--no-verify'], 'default' => false, 'help' => 'Disable checksum verifying for platforms/frameworks']);
self::$argv->addFlag('scan-all', ['alias' => ['--all'], 'default' => false, 'help' => 'Check all files, regardless of extension']);
//self::$argv->addFlag('deobfuscate', ['default' => false, 'help' => 'Deobfuscate directory']);
Expand Down Expand Up @@ -580,14 +574,14 @@ private function arguments($args = null)
self::setPathWhitelist(self::$argv['path-whitelist']);
}

// Report mode
self::setReportMode(isset(self::$argv['report']) && self::$argv['report']);

// Report
if (isset(self::$argv['disable-report']) && self::$argv['disable-report']) {
self::setReport(!self::$argv['disable-report']);
}

// Report mode
self::setReportMode((isset(self::$argv['report']) && self::$argv['report']) || !self::isCli());

// Deobfuscate mode
if (isset(self::$argv['deobfuscate']) && self::$argv['deobfuscate']) {
self::enableDeobfuscateMode();
Expand Down Expand Up @@ -1946,7 +1940,11 @@ public static function isLiteMode()
public static function setReportMode($mode = true)
{
self::$settings['report-mode'] = $mode;
self::enableReport();
if(self::isCli()) {
self::enableReport();
} else {
self::setReport($mode);
}

return new self();
}
Expand Down

0 comments on commit 49a5aad

Please sign in to comment.