admin/people/permissions. Be sure to grant permissions to trusted users only as this module can show sensitive site information.',
[':url' => Url::fromRoute('user.admin_permissions')->toString()]
)
);
}
/**
* Implements hook_requirements().
*/
function security_review_requirements($phase) {
$requirements = [];
// Provides a Status Report entry.
if ($phase == 'runtime') {
/** @var \Drupal\security_review\Checklist $checklist */
$checklist = Drupal::service('security_review.checklist');
$failed_checks = FALSE;
$no_results = TRUE;
// Looks for failed checks.
foreach ($checklist->getEnabledChecks() as $check) {
$result = $check->lastResult();
if ($result instanceof CheckResult) {
$no_results = FALSE;
if ($result->result() === CheckResult::FAIL) {
$failed_checks = TRUE;
break;
}
}
}
$module_url = Url::fromRoute('security_review')->toString();
if ($no_results) {
$severity = REQUIREMENT_WARNING;
$value = t(
'The Security Review checklist has not been run. Run the checklist',
[':url' => $module_url]
);
}
elseif ($failed_checks) {
$severity = REQUIREMENT_WARNING;
$value = t(
'There are failed Security Review checks. Review the checklist',
[':url' => $module_url]
);
}
else {
$severity = REQUIREMENT_OK;
$value = t(
'Passing all non-ignored Security Review checks. Review the checklist',
[':url' => $module_url]
);
}
$requirements['security_review'] = [
'title' => t('Security Review'),
'severity' => $severity,
'value' => $value,
];
}
return $requirements;
}