You are here

protected function FilePermissions::getIgnoreList in Security Review 8

Returns an array of relative and canonical paths to ignore.

Return value

string[] List of relative and canonical file paths to ignore.

1 call to FilePermissions::getIgnoreList()
FilePermissions::getFileList in src/Checks/FilePermissions.php
Scans a directory recursively and returns the files and directories inside.

File

src/Checks/FilePermissions.php, line 218

Class

FilePermissions
Check that files aren't writeable by the server.

Namespace

Drupal\security_review\Checks

Code

protected function getIgnoreList() {
  $file_path = PublicStream::basePath();
  $ignore = [
    '..',
    'CVS',
    '.git',
    '.svn',
    '.bzr',
    realpath($file_path),
  ];

  // Add temporary files directory if it's set.
  $temp_path = \Drupal::service('file_system')
    ->getTempDirectory();
  if (!empty($temp_path)) {
    $ignore[] = realpath('./' . rtrim($temp_path, '/'));
  }

  // Add private files directory if it's set.
  $private_files = PrivateStream::basePath();
  if (!empty($private_files)) {

    // Remove leading slash if set.
    if (strrpos($private_files, '/') !== FALSE) {
      $private_files = substr($private_files, strrpos($private_files, '/') + 1);
    }
    $ignore[] = $private_files;
  }
  $this
    ->moduleHandler()
    ->alter('security_review_file_ignore', $ignore);
  return $ignore;
}