1 | <?php |
||
2 | |||
3 | namespace Jorijn\LaravelSecurityChecker\Console; |
||
4 | |||
5 | use Illuminate\Console\Command; |
||
6 | use Illuminate\Support\Facades\Mail; |
||
7 | use Jorijn\LaravelSecurityChecker\Mailables\SecurityMail; |
||
8 | use SensioLabs\Security\SecurityChecker; |
||
9 | |||
10 | class SecurityMailCommand extends Command |
||
11 | { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $name = 'security-check:email'; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $description = 'Emails any vulnerabilities for packages you have in your composer.lock file.'; |
||
21 | |||
22 | /** |
||
23 | * @var SecurityChecker |
||
24 | */ |
||
25 | protected $checker; |
||
26 | |||
27 | /** |
||
28 | * SecurityCommand constructor. |
||
29 | * |
||
30 | * @param SecurityChecker $checker |
||
31 | */ |
||
32 | public function __construct(SecurityChecker $checker) |
||
33 | { |
||
34 | parent::__construct(); |
||
35 | |||
36 | $this->checker = $checker; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * |
||
41 | */ |
||
42 | public function fire() |
||
43 | { |
||
44 | // get the path to composer.lock |
||
45 | $composerLock = base_path('composer.lock'); |
||
46 | |||
47 | // and feed it into the SecurityChecker |
||
48 | $checkResult = $this->checker->check($composerLock); |
||
49 | |||
50 | $recipients = config('laravel-security-checker.recipients', []); |
||
51 | if (count($recipients) === 0) { |
||
52 | $this->error(__('No recipients has been configured yet!')); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
53 | return 1; |
||
54 | } |
||
55 | |||
56 | Mail::to($recipients)->send(new SecurityMail($checkResult)); |
||
57 | } |
||
58 | } |
||
59 |