X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fsecurity_review%2Fsecurity_review.install;fp=web%2Fmodules%2Fcontrib%2Fsecurity_review%2Fsecurity_review.install;h=999114962a9bcef661566a880c0290b9c328ad06;hp=0000000000000000000000000000000000000000;hb=ba1b5c55c66590c41ccc9844d3e62391b0399abb;hpb=93ef30d42f68e55d11d97312531118bbcd4cf318 diff --git a/web/modules/contrib/security_review/security_review.install b/web/modules/contrib/security_review/security_review.install new file mode 100644 index 000000000..999114962 --- /dev/null +++ b/web/modules/contrib/security_review/security_review.install @@ -0,0 +1,80 @@ +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; +}