You are here

function acquia_spi_run_security_review in Acquia Connector 7.2

Same name and namespace in other branches
  1. 6.2 acquia_spi/acquia_spi.module \acquia_spi_run_security_review()
  2. 7.3 acquia_spi/acquia_spi.module \acquia_spi_run_security_review()

Run some checks from the Security Review module.

1 call to acquia_spi_run_security_review()
acquia_spi_get in acquia_spi/acquia_spi.module
Gather site profile information about this site.

File

acquia_spi/acquia_spi.module, line 670
Send site profile information (NSPI) and system data to Acquia Insight.

Code

function acquia_spi_run_security_review() {
  if (!_acquia_spi_security_review_compatible()) {

    // Older versions of Security Review are not compatible and the results
    // cannot easily be retrieved.
    return array();
  }
  module_load_include('inc', 'acquia_spi', 'security_review');
  $checklist_results = array();
  $skips = array();

  // Collect the checklist.
  $checklist = acquia_spi_security_review_get_checks();

  // Run only specific checks.
  $to_check = array(
    'views_access',
    'temporary_files',
    'base_url_set',
    '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 = acquia_spi_security_review_run($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;
}