Skip to content

Acquia

AcsfDeployWorkspaceCleaned

Ensure the ACSF deploy workspace is clear. This can bloat ephemeral storage.

Class: Drutiny\Acquia\Audit\AcsfDeployWorkspaceCleaned
Extends: Drutiny\Audit
Package: drutiny/acquia

This class can remediate failed audits.

Policies

These are the policies that use this class:

Name Title
Acquia:CheckSiteFactoryWorkspace ACSF Deployment Workspace

Source

  public function audit(Sandbox $sandbox) {

    $output = $sandbox->exec('find /mnt/tmp/repo_* -maxdepth 1 -mindepth 1 -ctime +1 -type d');
    $lines = array_filter(explode(PHP_EOL, $output));

    $sandbox->setParameter('directories', $lines);

    return empty($lines);
  }

AppInfo

Ensure an environment has custom domains set.

Class: Drutiny\Acquia\Audit\AppInfo
Extends: Drutiny\Audit
Package: drutiny/acquia

Policies

These are the policies that use this class:

Name Title
Acquia:AppInfo Acquia Application Information

Source

  public function audit(Sandbox $sandbox) {

    $options = $sandbox->getTarget()->getOptions();
    $app = CloudApiDrushAdaptor::findApplication($options['ac-realm'], $options['ac-site']);
    $sandbox->setParameter('app', $app);

    return Audit::NOTICE;
  }

CustomDomains

Ensure an environment has custom domains set.

Class: Drutiny\Acquia\Audit\CustomDomains
Extends: Drutiny\Audit
Package: drutiny/acquia

Policies

These are the policies that use this class:

Name Title
Acquia:CustomDomains Custom Domains Registered

Source

  public function audit(Sandbox $sandbox) {

    $environment = CloudApiDrushAdaptor::getEnvironment($sandbox->getTarget());

    $domains = array_filter($environment['domains'], function ($domain) {
      // Do not include ELB domains or Acquia default domains.
      return !(strpos($domain, 'acquia-sites.com') || strpos($domain, 'elb.amazonaws.com'));
    });

    if (empty($domains)) {
      return FALSE;
    }

    $sandbox->setParameter('domains', array_values($domains));

    return TRUE;
  }

EnvironmentAnalysis

Check to ensure Production Mode is enabled on Acquia Cloud.

Class: Drutiny\Acquia\Audit\EnvironmentAnalysis
Extends: Drutiny\Audit\AbstractAnalysis
Package: drutiny/acquia

Policies

These are the policies that use this class:

Name Title
Acquia:ProductionMode Acquia Production Mode

Source

  final public function audit(Sandbox $sandbox)
  {
    $this->gather($sandbox);
    $expressionLanguage = new ExpressionLanguage();
    $variables  = $sandbox->getParameterTokens();
    $sandbox->logger()->info(__CLASS__ . ': ' . Yaml::dump($variables));

    $expression = $sandbox->getParameter('not_applicable', 'false');
    $sandbox->logger()->info(__CLASS__ . ': ' . $expression);
    if ($expressionLanguage->evaluate($expression, $variables)) {
      return self::NOT_APPLICABLE;
    }

    $expression = $sandbox->getParameter('expression', 'true');
    $sandbox->logger()->info(__CLASS__ . ': ' . $expression);
    return $expressionLanguage->evaluate($expression, $variables);
  }

FilesPerDirectory

Class: Drutiny\Acquia\Audit\FilesPerDirectory
Extends: Drutiny\Audit
Package: drutiny/acquia

Policies

These are the policies that use this class:

Name Title
Acquia:FilesPerDirectory Less than 2,500 files per directory

Parameters

Name Type Description Default
limit integer The limit of files per directory. 2500

Tokens

Name Type Description Default
limit integer The limit of files per directory. 2500
directories array A multidimensional array containing directory data breaching the limit. { }

Source

  public function audit(Sandbox $sandbox) {
    // Build a count of files in every directory in the public filesystem.
    $stat = $sandbox->drush(['format' => 'json'])->status();
    $files = implode('/', [$stat['root'], $stat['files']]);
    $limit = $sandbox->getParameter('limit');

    // Note the trailing slash at the end of $files to ensure find works over
    // symlinks.
    $command = "find $files/ -type f -exec dirname {} \; | uniq -c | awk '\$1 > $limit'";

    // Execute and clean the output into usable data.
    $output = $sandbox->exec($command);
    $lines = array_filter(explode(PHP_EOL, $output));
    $directories = [];
    foreach ($lines as $line) {
      list($count, $directory) = explode(' ', trim($line));
      $directories[] = [
        'directory' => str_replace($stat['root'] . '/', '', $directory),
        'file_count' => $count,
      ];
    }

    // No limits breached, return as pass.
    if (empty($directories)) {
      return TRUE;
    }

    $sandbox->setParameter('directories', $directories);

    return FALSE;
  }

SearchDB

Ensure there is no use of search indexes in the database.

Class: Drutiny\Acquia\Audit\SearchDB
Extends: Drutiny\Plugin\Drupal7\Audit\ModuleDisabled
Package: drutiny/acquia

This class can remediate failed audits.

Policies

These are the policies that use this class:

Name Title
Acquia:Drupal7:NoDbSearch No Database Search Indexes for Drupal 7

Parameters

Name Type Description Default
module string The module to check is enabled. search_api_db

Tokens

Name Type Description Default
module string The module to check is enabled. search_api_db
indexes array An array of index names found in the database. Only available on failure. null
items integer The number of indexed items in the database. Only available on failure. null

Source

  public function audit(Sandbox $sandbox) {

    $sandbox->setParameter('module', 'search_api_db');
    if (parent::audit($sandbox)) {
      return TRUE;
    }

    // Find out if there are active indexes using the db service class.
    $output = $sandbox->drush()->sqlq("SELECT COUNT(i.machine_name) as count FROM {search_api_index} i LEFT JOIN {search_api_server} s ON i.server = s.machine_name WHERE i.status > 0 AND s.class = 'search_api_db_service';");
    if (empty($output)) {
      return TRUE;
    }
    elseif (count($output) == 1) {
      $number_of_db_indexes = (int) $output[0];
    }
    else {
      $number_of_db_indexes = (int) $output[1];
    }

    $sandbox->setParameter('indexes', $number_of_db_indexes);

    $output = $sandbox->drush()->sqlq('SELECT COUNT(item_id) FROM {search_api_db_default_node_index};');

    $sandbox->setParameter('items', $output);

    return FALSE;
  }