Exemplo n.º 1
0
 /**
  * Returns the IDs of untrusted roles.
  *
  * If the module hasn't been configured yet, it returns the default untrusted
  * roles.
  *
  * @return array
  *   Untrusted roles' IDs.
  */
 public static function untrustedRoles()
 {
     // If the module hasn't been manually configured yet, return the untrusted
     // roles depending on Drupal's actual configuration.
     if (!SecurityReview::isConfigured()) {
         return static::defaultUntrustedRoles();
     }
     // Else return the stored untrusted roles.
     return SecurityReview::getUntrustedRoles();
 }
 /**
  * Creates the Run & Review page.
  *
  * @return array
  *   The 'Run & Review' page's render array.
  */
 public function index()
 {
     $run_form = array();
     // If the user has the required permissions, show the RunForm.
     if (Drupal::currentUser()->hasPermission('run security checks')) {
         // Get the Run form.
         $run_form = Drupal::formBuilder()->getForm('Drupal\\security_review\\Form\\RunForm');
         // Close the Run form if there are results.
         if (SecurityReview::getLastRun() > 0) {
             $run_form['run_form']['#open'] = FALSE;
         }
     }
     // Print the results if any.
     if (SecurityReview::getLastRun() <= 0) {
         // If they haven't configured the site, prompt them to do so.
         if (!SecurityReview::isConfigured()) {
             drupal_set_message(t('It appears this is your first time using the Security Review checklist. Before running the checklist please review the settings page at !link to set which roles are untrusted.', array('!link' => Drupal::l('admin/reports/security-review/settings', Url::fromRoute('security_review.settings')))), 'warning');
         }
     }
     return array($run_form, $this->results());
 }
 /**
  * Tests the 'configured' setting.
  */
 public function testConfigConfigured()
 {
     $this->assertFalse(SecurityReview::isConfigured(), 'Not configured by default.');
     SecurityReview::setConfigured(TRUE);
     $this->assertTrue(SecurityReview::isConfigured(), 'Set to configured.');
 }