Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function evaluate(CheckResult $result)
 {
     if ($result->result() === CheckResult::SUCCESS) {
         return array();
     }
     $output = '';
     foreach ($result->findings() as $finding) {
         $output .= '<p>';
         $output .= t($finding);
         $output .= '</p>';
     }
     return array('#type' => 'markup', '#markup' => $output);
 }
Ejemplo n.º 2
0
 /**
  * Logs a check result.
  *
  * @param \Drupal\security_review\CheckResult $result
  *   The result to log.
  */
 public static function logCheckResult(CheckResult $result = NULL)
 {
     if (SecurityReview::isLogging()) {
         if ($result == NULL) {
             $check = $result->check();
             $context = array('!reviewcheck' => $check->getTitle(), '!namespace' => $check->getNamespace());
             SecurityReview::log($check, '!reviewcheck of !namespace produced a null result', $context, RfcLogLevel::CRITICAL);
             return;
         }
         $check = $result->check();
         $level = RfcLogLevel::NOTICE;
         $message = '!name check invalid result';
         switch ($result->result()) {
             case CheckResult::SUCCESS:
                 $level = RfcLogLevel::INFO;
                 $message = '!name check success';
                 break;
             case CheckResult::FAIL:
                 $level = RfcLogLevel::ERROR;
                 $message = '!name check failure';
                 break;
             case CheckResult::WARN:
                 $level = RfcLogLevel::WARNING;
                 $message = '!name check warning';
                 break;
             case CheckResult::INFO:
                 $level = RfcLogLevel::INFO;
                 $message = '!name check info';
                 break;
         }
         $context = array('!name' => $check->getTitle());
         static::log($check, $message, $context, $level);
     }
 }
Ejemplo n.º 3
0
 /**
  * Stores a result in the state system.
  *
  * @param \Drupal\security_review\CheckResult $result
  *   The result to store.
  */
 public function storeResult(CheckResult $result = NULL)
 {
     if ($result == NULL) {
         $context = array('!reviewcheck' => $this->getTitle(), '!namespace' => $this->getNamespace());
         SecurityReview::log($this, 'Unable to store check !reviewcheck for !namespace', $context, RfcLogLevel::CRITICAL);
         return;
     }
     $findings = $this->storesFindings() ? $result->findings() : array();
     Drupal::state()->setMultiple(array($this->statePrefix . 'last_result.result' => $result->result(), $this->statePrefix . 'last_result.time' => $result->time(), $this->statePrefix . 'last_result.findings' => $findings));
 }