|
3 | 3 | namespace Jorijn\LaravelSecurityChecker\Console; |
4 | 4 |
|
5 | 5 | use Illuminate\Console\Command; |
| 6 | +use Illuminate\Support\Facades\Log; |
6 | 7 | use Illuminate\Support\Facades\Notification; |
7 | 8 | use Jorijn\LaravelSecurityChecker\Notifications\SecuritySlackNotification; |
8 | 9 | use SensioLabs\Security\SecurityChecker; |
@@ -43,21 +44,26 @@ public function handle() |
43 | 44 | { |
44 | 45 | // require that the user specifies a slack channel in the .env file |
45 | 46 | if (!config('laravel-security-checker.slack_webhook_url')) { |
| 47 | + Log::error('checking for vulnerabilities using slack was requested but no hook is configured'); |
46 | 48 | throw new \Exception('No Slack Webhook has been specified.'); |
47 | 49 | } |
48 | 50 |
|
49 | 51 | // get the path to composer.lock |
50 | 52 | $composerLock = base_path('composer.lock'); |
51 | 53 |
|
52 | 54 | // and feed it into the SecurityChecker |
| 55 | + Log::debug('about to check for vulnerabilities'); |
53 | 56 | $vulnerabilities = json_decode((string)$this->checker->check($composerLock), true); |
54 | 57 |
|
55 | 58 | // cancel execution here if user does not want to be notified when there are 0 vulns. |
56 | 59 | $proceed = config('laravel-security-checker.notify_even_without_vulnerabilities', false); |
57 | 60 | if (count($vulnerabilities) === 0 && $proceed !== true) { |
| 61 | + Log::info('no vulnerabilities were found, not sending a slack notification'); |
| 62 | + |
58 | 63 | return 0; |
59 | 64 | } |
60 | 65 |
|
| 66 | + Log::warning('vulnerabilities were found, sending slack notification to configured hook'); |
61 | 67 | Notification::route('slack', config('laravel-security-checker.slack_webhook_url', null)) |
62 | 68 | ->notify(new SecuritySlackNotification($vulnerabilities, realpath($composerLock))); |
63 | 69 | } |
|
0 commit comments