bringyourownideas /
silverstripe-composer-security-checker
| 1 | <?php |
||
| 2 | |||
| 3 | namespace BringYourOwnIdeas\SecurityChecker\Jobs; |
||
| 4 | |||
| 5 | use BringYourOwnIdeas\SecurityChecker\Tasks\SecurityAlertCheckTask; |
||
| 6 | use Symbiote\QueuedJobs\Services\QueuedJob; |
||
| 7 | use Symbiote\QueuedJobs\Services\AbstractQueuedJob; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Composer security checker job. Runs the task which does the check as a queuedjob. |
||
| 11 | * |
||
| 12 | * @author Peter Thaleikis |
||
| 13 | * @license BSD-3-Clause |
||
| 14 | */ |
||
| 15 | class SecurityAlertCheckJob extends AbstractQueuedJob implements QueuedJob |
||
| 16 | { |
||
| 17 | private static $dependencies = [ |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 18 | 'checkTask' => '%$' . SecurityAlertCheckTask::class, |
||
| 19 | ]; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var SecurityAlertCheckTask |
||
| 23 | */ |
||
| 24 | protected $checkTask; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @return SecurityAlertCheckTask |
||
| 28 | */ |
||
| 29 | public function getCheckTask() |
||
| 30 | { |
||
| 31 | return $this->checkTask; |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @param SecurityAlertCheckTask $checkTask |
||
| 36 | * @return SecurityAlertCheckJob |
||
| 37 | */ |
||
| 38 | public function setCheckTask(SecurityAlertCheckTask $checkTask) |
||
| 39 | { |
||
| 40 | $this->checkTask = $checkTask; |
||
| 41 | return $this; |
||
| 42 | } |
||
| 43 | |||
| 44 | public function getTitle() |
||
| 45 | { |
||
| 46 | return _t( |
||
| 47 | __CLASS__ . '.Title', |
||
| 48 | 'Check if any composer managed modules have known security vulnerabilities.' |
||
| 49 | ); |
||
| 50 | } |
||
| 51 | |||
| 52 | public function getJobType() |
||
| 53 | { |
||
| 54 | $this->totalSteps = 1; |
||
| 55 | |||
| 56 | return QueuedJob::QUEUED; |
||
| 57 | } |
||
| 58 | |||
| 59 | public function process() |
||
| 60 | { |
||
| 61 | // run the task |
||
| 62 | $task = $this->getCheckTask(); |
||
| 63 | $task->run(null); |
||
| 64 | |||
| 65 | // mark job as completed |
||
| 66 | $this->isComplete = true; |
||
| 67 | } |
||
| 68 | } |
||
| 69 |