You are here

public function SecurityReviewController::runSecurityReview in Acquia Connector 8

Same name and namespace in other branches
  1. 8.2 src/Controller/SecurityReviewController.php \Drupal\acquia_connector\Controller\SecurityReviewController::runSecurityReview()
  2. 3.x src/Controller/SecurityReviewController.php \Drupal\acquia_connector\Controller\SecurityReviewController::runSecurityReview()

Run some checks from the Security Review module.

File

src/Controller/SecurityReviewController.php, line 23

Class

SecurityReviewController
Acquia Security Review page.

Namespace

Drupal\acquia_connector\Controller

Code

public function runSecurityReview() {

  // Collect the checklist.
  $checklist = $this
    ->securityReviewGetChecks();

  // Run only specific checks.
  $to_check = [
    'views_access',
    'temporary_files',
    'executable_php',
    'input_formats',
    'admin_permissions',
    'untrusted_php',
    'private_files',
    'upload_extensions',
  ];
  foreach ($checklist as $module => $checks) {
    foreach ($checks as $check_name => $args) {
      if (!in_array($check_name, $to_check)) {
        unset($checklist[$module][$check_name]);
      }
    }
    if (empty($checklist[$module])) {
      unset($checklist[$module]);
    }
  }
  $checklist_results = $this
    ->securityReviewRun($checklist);
  foreach ($checklist_results as $module => $checks) {
    foreach ($checks as $check_name => $check) {

      // Unset data that does not need to be sent.
      if (is_null($check['result'])) {
        unset($checklist_results[$module][$check_name]);
      }
      else {
        unset($check['success']);
        unset($check['failure']);
        $checklist_results[$module][$check_name] = $check;
      }
    }
    if (empty($checklist_results[$module])) {
      unset($checklist_results[$module]);
    }
  }
  return $checklist_results;
}