You are here

public function UploadExtensions::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/UploadExtensions.php, line 143

Class

UploadExtensions
Checks for unsafe extensions in the allowed extensions settings of fields.

Namespace

Drupal\security_review\Checks

Code

public function evaluatePlain(CheckResult $result) {
  $findings = $result
    ->findings();
  if (empty($findings)) {
    return '';
  }
  $output = '';
  foreach ($findings as $entity_id => $unsafe_extensions) {
    $entity = FieldConfig::load($entity_id);

    /** @var FieldConfig $entity */
    $output .= $this
      ->t('@bundle: field @field', [
      '@bundle' => $entity
        ->getTargetBundle(),
      '@field' => $entity
        ->label(),
    ]);
    $output .= "\n\t" . implode(', ', $unsafe_extensions) . "\n";
  }
  return $output;
}