5 * Install, update and uninstall functions for the security_review module.
9 use Drupal\security_review\CheckResult;
12 * Implements hook_install().
14 function security_review_install() {
15 // Remind the user to set the permissions.
18 'Security Review module enabled. You should first set the module access permissions at <a href=":url">admin/people/permissions</a>. Be sure to grant permissions to trusted users only as this module can show sensitive site information.',
19 [':url' => Url::fromRoute('user.admin_permissions')->toString()]
25 * Implements hook_requirements().
27 function security_review_requirements($phase) {
30 // Provides a Status Report entry.
31 if ($phase == 'runtime') {
32 /** @var \Drupal\security_review\Checklist $checklist */
33 $checklist = Drupal::service('security_review.checklist');
35 $failed_checks = FALSE;
38 // Looks for failed checks.
39 foreach ($checklist->getEnabledChecks() as $check) {
40 $result = $check->lastResult();
41 if ($result instanceof CheckResult) {
43 if ($result->result() === CheckResult::FAIL) {
44 $failed_checks = TRUE;
50 $module_url = Url::fromRoute('security_review')->toString();
52 $severity = REQUIREMENT_WARNING;
54 'The Security Review checklist has not been run. <a href=":url">Run the checklist</a>',
55 [':url' => $module_url]
58 elseif ($failed_checks) {
59 $severity = REQUIREMENT_WARNING;
61 'There are failed Security Review checks. <a href=":url">Review the checklist</a>',
62 [':url' => $module_url]
66 $severity = REQUIREMENT_OK;
68 'Passing all non-ignored Security Review checks. <a href=":url">Review the checklist</a>',
69 [':url' => $module_url]
72 $requirements['security_review'] = [
73 'title' => t('Security Review'),
74 'severity' => $severity,