SecurityReview.php in DRD Agent 4.0.x
File
src/Agent/Remote/SecurityReview.php
View source
<?php
namespace Drupal\drd_agent\Agent\Remote;
use Drupal\security_review\Controller\ChecklistController;
use Drupal\Core\Session\UserSession;
class SecurityReview extends Base {
public function collect() : array {
$review = [];
if ($this->moduleHandler
->moduleExists('security_review')) {
$security_review = $this->container
->get('security_review');
if ($this->time
->getRequestTime() - $security_review
->getLastRun() > 86400) {
$switcher = $this->container
->get('account_switcher');
$switcher
->switchTo(new UserSession([
'uid' => 1,
]));
$checklist = $this->container
->get('security_review.checklist');
$checklist
->runChecklist();
$switcher
->switchBack();
}
$clc = ChecklistController::create($this->container);
$review['security_review'] = [
'title' => t('Security Review'),
'result' => $clc
->results(),
];
}
return $review;
}
}