private function SecurityReviewController::checkTemporaryFiles in Acquia Connector 8
Same name and namespace in other branches
- 8.2 src/Controller/SecurityReviewController.php \Drupal\acquia_connector\Controller\SecurityReviewController::checkTemporaryFiles()
- 3.x src/Controller/SecurityReviewController.php \Drupal\acquia_connector\Controller\SecurityReviewController::checkTemporaryFiles()
Check for sensitive temporary files like settings.php~.
Parameters
int|null $last_check: Timestamp.
Return value
array Result.
File
- src/
Controller/ SecurityReviewController.php, line 251
Class
- SecurityReviewController
- Acquia Security Review page.
Namespace
Drupal\acquia_connector\ControllerCode
private function checkTemporaryFiles($last_check = NULL) {
$result = TRUE;
$check_result_value = [];
$files = [];
$site_path = \Drupal::service('site.path');
$dir = scandir(DRUPAL_ROOT . '/' . $site_path . '/');
foreach ($dir as $file) {
// Set full path to only files.
if (!is_dir($file)) {
$files[] = DRUPAL_ROOT . '/' . $site_path . '/' . $file;
}
}
$this
->moduleHandler()
->alter('security_review_temporary_files', $files);
foreach ($files as $path) {
$matches = [];
if (file_exists($path) && preg_match('/.*(~|\\.sw[op]|\\.bak|\\.orig|\\.save)$/', $path, $matches) !== FALSE && !empty($matches)) {
$result = FALSE;
$check_result_value[] = $path;
}
}
return [
'result' => $result,
'value' => $check_result_value,
];
}