You are here

public function ExecutablePhp::evaluatePlain in Security Review 8

Evaluates a CheckResult and returns a plaintext output.

Parameters

\Drupal\security_review\CheckResult $result: The check result to evaluate.

Return value

string The evaluation string.

Overrides Check::evaluatePlain

File

src/Checks/ExecutablePhp.php, line 180

Class

ExecutablePhp
Checks if PHP files written to the files directory can be executed.

Namespace

Drupal\security_review\Checks

Code

public function evaluatePlain(CheckResult $result) {
  $paragraphs = [];
  $directory = PublicStream::basePath();
  foreach ($result
    ->findings() as $label) {
    switch ($label) {
      case 'executable_php':
        $paragraphs[] = $this
          ->t('PHP file executed in @path', [
          '@path' => $directory,
        ]);
        break;
      case 'missing_htaccess':
        $paragraphs[] = $this
          ->t('.htaccess is missing from @path', [
          '@path' => $directory,
        ]);
        break;
      case 'incorrect_htaccess':
        $paragraphs[] = $this
          ->t('.htaccess wrong content');
        break;
      case 'writable_htaccess':
        $paragraphs[] = $this
          ->t('.htaccess writable');
        break;
    }
  }
  return implode("\n", $paragraphs);
}