rebase code on oct-10-2023

This commit is contained in:
Rachit Bhargava
2023-10-10 17:51:46 -04:00
parent b16ad94b69
commit 8f1a2c3a66
2197 changed files with 184921 additions and 35568 deletions

View File

@@ -17,7 +17,8 @@ class wfWAFStorageFile implements wfWAFStorageInterface {
return true;
}
if (wfWAFUtils::isCli()) {
$sapi = @php_sapi_name();
if ($sapi == "cli") {
return false;
}
return true;

View File

@@ -1229,9 +1229,6 @@ class wfWAFUtils {
public static function isVersionBelow($target, $compared) {
return $compared === null || version_compare($compared, $target, '<');
}
public static function isCli() {
return (@php_sapi_name()==='cli') || !array_key_exists('REQUEST_METHOD', $_SERVER);
}
}
}

View File

@@ -328,11 +328,6 @@ auEa+7b+FGTKs7dUo2BNGR7OVifK4GZ8w/ajS0TelhrSRi3BBQCGXLzUO/UURUAh
public function loadRules() {
$storageEngine = $this->getStorageEngine();
if ($storageEngine instanceof wfWAFStorageFile) {
$logLevel = error_reporting();
if (wfWAFUtils::isCli()) { //Done to suppress errors from WP-CLI when the WAF is run on environments that have a server level constant to use the MySQLi storage engine that is not in place when running from the CLI
error_reporting(0);
}
// Acquire lock on this file so we're not including it while it's being written in another process.
$handle = fopen($storageEngine->getRulesFile(), 'r');
$locked = $handle !== false && flock($handle, LOCK_SH);
@@ -342,10 +337,6 @@ auEa+7b+FGTKs7dUo2BNGR7OVifK4GZ8w/ajS0TelhrSRi3BBQCGXLzUO/UURUAh
flock($handle, LOCK_UN);
if ($handle !== false)
fclose($handle);
if (wfWAFUtils::isCli()) {
error_reporting($logLevel);
}
} else {
$wafRules = $storageEngine->getRules();
if (is_array($wafRules)) {