예제 #1
0
 public function afterRunRules()
 {
     //wfWAFLogException
     $watchedIPs = wfWAF::getInstance()->getStorageEngine()->getConfig('watchedIPs');
     if ($watchedIPs) {
         if (!is_array($watchedIPs)) {
             $watchedIPs = explode(',', $watchedIPs);
         }
         foreach ($watchedIPs as $watchedIP) {
             $ipRange = new wfWAFUserIPRange($watchedIP);
             if ($ipRange->isIPInRange(wfWAF::getInstance()->getRequest()->getIP())) {
                 throw new wfWAFLogException('Wordfence watched IP.');
             }
         }
     }
     if ($reason = wfWAF::getInstance()->getRequest()->getMetadata('finalAction')) {
         $e = new wfWAFBlockException($reason['action']);
         $e->setRequest(wfWAF::getInstance()->getRequest());
         throw $e;
     }
 }
예제 #2
0
 /**
  * @param wfWAFRule $rule
  * @param wfWAFRuleComparisonFailure $failedComparison
  * @param bool $updateFailedRules
  * @throws wfWAFBlockException
  */
 public function block($rule, $failedComparison, $updateFailedRules = true)
 {
     $paramKey = $failedComparison->getParamKey();
     $category = $rule->getCategory();
     if ($updateFailedRules) {
         $this->failedRules[$paramKey][$category][] = array('rule' => $rule, 'failedComparison' => $failedComparison, 'action' => 'block');
     }
     $e = new wfWAFBlockException();
     $e->setFailedRules(array($rule));
     $e->setParamKey($failedComparison->getParamKey());
     $e->setParamValue($failedComparison->getParamValue());
     $e->setRequest($this->getRequest());
     throw $e;
 }