: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if (!defined('WORDFENCE_VERSION')) { exit; }
/** @var wfRequestModel $hit */
/** @var stdClass $hitData */
$title = sprintf('Debugging #%d as False Positive', $hit->id);
'Timestamp' => date('r', $hit->ctime),
'IP' => wfUtils::inet_ntop($hit->IP),
'Status Code' => $hit->statusCode,
'User Agent' => $hit->UA,
'Referer' => $hit->referer,
if (isset($hitData->fullRequest)) {
$requestString = base64_decode($hitData->fullRequest);
$request = wfWAFRequest::parseString($requestString);
$request = new wfWAFRequest();
$request->setAuth(array());
$request->setBody(array());
$request->setCookies(array());
$request->setFileNames(array());
$request->setFiles(array());
$request->setHeaders(array());
$request->setMethod('GET');
$request->setProtocol('http');
$request->setQueryString(array());
$request->setTimestamp('');
$urlPieces = parse_url($hit->URL);
if (array_key_exists('scheme', $urlPieces)) {
$request->setProtocol($urlPieces['scheme']);
if (array_key_exists('host', $urlPieces)) {
$request->setHost($urlPieces['host']);
$headers['Host'] = $urlPieces['host'];
if (array_key_exists('path', $urlPieces)) {
$request->setPath($urlPieces['path']);
$uri = $urlPieces['path'];
if (array_key_exists('query', $urlPieces)) {
$uri .= '?' . $urlPieces['query'];
parse_str($urlPieces['query'], $query);
$request->setQueryString($query);
$headers['User-Agent'] = $hit->UA;
$headers['Referer'] = $hit->referer;
$request->setHeaders($headers);
preg_match('/request\.([a-z]+)(?:\[(.*?)\](.*?))?/i', $hitData->paramKey, $matches);
$request->setMethod('POST');
parse_str("$matches[2]$matches[3]", $body);
$request->setBody($body);
$request->setIP(wfUtils::inet_ntop($hit->IP));
$request->setTimestamp($hit->ctime);
$waf = wfWAF::getInstance();
$waf->setRequest($request);
$result = '<strong class="ok">Passed</strong>';
} catch (wfWAFAllowException $e) {
$result = '<strong class="ok">Allowlisted</strong>';
} catch (wfWAFBlockException $e) {
$result = '<strong class="error">Blocked</strong>';
$failedRules = $waf->getFailedRules();
} catch (wfWAFBlockSQLiException $e) {
$result = '<strong class="error">Blocked For SQLi</strong>';
$failedRules = $waf->getFailedRules();
} catch (wfWAFBlockXSSException $e) {
$result = '<strong class="error">Blocked For XSS</strong>';
$failedRules = $waf->getFailedRules();
<title><?php echo esc_html($title) ?></title>
<link rel="stylesheet" href="<?php echo wfUtils::getBaseURL() . wfUtils::versionedAsset('css/main.css'); ?>">
<link rel="stylesheet" href="<?php echo wfLicense::current()->getStylesheet(); ?>">
font-family: "Open Sans", Helvetica, Arial, sans-serif;
border: 1px solid #999999;
border: 1px solid #ffb463;
background-color: #ffffe0;
pre.request-debug strong {
border: 1px solid #ff4a35;
background-color: #ffefe7;
<h1><?php echo esc_html($title) ?></h1>
<table class="wf-striped-table">
<th colspan="2">Request Details</th>
<?php foreach ($fields as $label => $value): ?>
<td><?php echo esc_html($label) ?>:</td>
<td><?php echo esc_html($value) ?></td>
<h4>HTTP Request: <?php echo $result ?></h4>
<?php if (!isset($hitData->fullRequest)): ?>
<em style="font-size: 14px;">This is a reconstruction of the request using what was flagged by the WAF.
Full requests are only stored when <code>WFWAF_DEBUG</code> is enabled.</em>
<pre class="request-debug"><?php
$paramKey = wp_hash(uniqid('param', true));
$matchKey = wp_hash(uniqid('match', true));
"[/$paramKey]" => '</em>',
"[$matchKey]" => '<strong>',
"[/$matchKey]" => '</strong>',
$highlightParamFormat = "[$paramKey]%s[/$paramKey]";
$highlightMatchFormat = "[$matchKey]%s[/$matchKey]";
$requestOut = esc_html($request->highlightFailedParams($failedRules, $highlightParamFormat, $highlightMatchFormat));
echo str_replace(array_keys($template), $template, $requestOut) ?></pre>
<?php if ($failedRules): ?>
<table class="wf-striped-table">
foreach ($failedRules as $paramKey => $categories) {
foreach ($categories as $categoryKey => $failed) {
foreach ($failed as $failedRule) {
/** @var wfWAFRule $rule */
$rule = $failedRule['rule'];
printf("<tr><td>%d</td><td>%s</td></tr>", $rule->getRuleID(), $rule->getDescription());
<button type="button" id="run-waf-rules">Run Through WAF Rules</button>
document.getElementById('run-waf-rules').onclick = function() {
document.location.href = document.location.href;