rebase on oct-10-2023
This commit is contained in:
@@ -12,6 +12,9 @@ if (!defined('WFWAF_AUTO_PREPEND')) {
|
||||
if (!defined('WF_IS_WP_ENGINE')) {
|
||||
define('WF_IS_WP_ENGINE', isset($_SERVER['IS_WPE']));
|
||||
}
|
||||
if (!defined('WF_IS_FLYWHEEL')) {
|
||||
define('WF_IS_FLYWHEEL', isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Flywheel/') === 0);
|
||||
}
|
||||
if (!defined('WF_IS_PRESSABLE')) {
|
||||
define('WF_IS_PRESSABLE', (defined('IS_ATOMIC') && IS_ATOMIC) || (defined('IS_PRESSABLE') && IS_PRESSABLE));
|
||||
}
|
||||
@@ -834,8 +837,10 @@ if (!is_dir(WFWAF_LOG_PATH)) {
|
||||
|
||||
|
||||
try {
|
||||
|
||||
if (!defined('WFWAF_STORAGE_ENGINE') && WF_IS_WP_ENGINE) {
|
||||
if (!defined('WFWAF_STORAGE_ENGINE') && isset($_SERVER['WFWAF_STORAGE_ENGINE'])) {
|
||||
define('WFWAF_STORAGE_ENGINE', $_SERVER['WFWAF_STORAGE_ENGINE']);
|
||||
}
|
||||
else if (!defined('WFWAF_STORAGE_ENGINE') && (WF_IS_WP_ENGINE || WF_IS_FLYWHEEL)) {
|
||||
define('WFWAF_STORAGE_ENGINE', 'mysqli');
|
||||
}
|
||||
|
||||
@@ -1016,10 +1021,15 @@ catch (Exception $e) { // In PHP 5, Throwable does not exist
|
||||
);
|
||||
}
|
||||
catch (Throwable $t) {
|
||||
error_log("An unexpected error occurred during WAF execution: {$t}");
|
||||
$wf_waf_failure = array(
|
||||
'throwable' => $t
|
||||
);
|
||||
error_log("An unexpected exception occurred during WAF execution: {$t}");
|
||||
if (class_exists('ParseError') && $t instanceof ParseError) {
|
||||
//Do nothing
|
||||
}
|
||||
else {
|
||||
$wf_waf_failure = array(
|
||||
'throwable' => $t
|
||||
);
|
||||
}
|
||||
}
|
||||
if (wfWAF::getInstance() === null) {
|
||||
require_once __DIR__ . '/dummy.php';
|
||||
|
||||
@@ -58,6 +58,9 @@ class wfWAFIPBlocksController
|
||||
}
|
||||
$isSynchronizing = true;
|
||||
|
||||
global $wpdb;
|
||||
$suppressed = $wpdb->suppress_errors(!(defined('WFWAF_DEBUG') && WFWAF_DEBUG));
|
||||
|
||||
// Pattern Blocks
|
||||
$blocks = wfBlock::patternBlocks(true);
|
||||
$patternBlocks = array();
|
||||
@@ -138,6 +141,8 @@ class wfWAFIPBlocksController
|
||||
// Do nothing
|
||||
}
|
||||
$isSynchronizing = false;
|
||||
|
||||
$wpdb->suppress_errors($suppressed);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -118,6 +118,12 @@ class wfWAFUserIPRange {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function repeatString($string, $count) {
|
||||
if ($count <= 0)
|
||||
return '';
|
||||
return str_repeat($string, $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand a compressed printable range representation of an IPv6 address.
|
||||
*
|
||||
@@ -134,7 +140,7 @@ class wfWAFUserIPRange {
|
||||
}
|
||||
$dbl_colon_pos = strpos($ip_range, '::');
|
||||
if ($dbl_colon_pos !== false) {
|
||||
$ip_range = str_replace('::', str_repeat(':0000',
|
||||
$ip_range = str_replace('::', self::repeatString(':0000',
|
||||
(($dbl_colon_pos === 0 || $dbl_colon_pos === strlen($ip_range) - 2) ? 9 : 8) - $colon_count) . ':', $ip_range);
|
||||
$ip_range = trim($ip_range, ':');
|
||||
}
|
||||
@@ -257,4 +263,4 @@ class wfWAFUserIPRange {
|
||||
$this->ip_string = $this->_sanitizeIPRange($ip_string);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user