Skip to content

Commit

Permalink
Added exception handling
Browse files Browse the repository at this point in the history
This exception handling will handle timeouts in the service.
  • Loading branch information
lowerends committed Aug 27, 2015
1 parent 90456b6 commit b945939
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions src/Console/CheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Illuminate\Console\Command;
use SensioLabs\Security\SecurityChecker;
use SensioLabs\Security\Exception\RuntimeException;

class CheckCommand extends Command
{
Expand All @@ -18,37 +19,44 @@ public function fire()
{
$checker = new SecurityChecker();

$alerts = $checker->check(base_path() . '/composer.lock');

if (!empty($alerts))
try
{
foreach ($alerts as $package => $alert)
$alerts = $checker->check(base_path() . '/composer.lock');

if (!empty($alerts))
{
$this->error('Security advisories found!');
foreach ($alerts as $package => $alert)
{
$this->error('Security advisories found!');

$this->info('======================');
$this->info('======================');

$this->info('Package: ' . $package);
$this->info('Package: ' . $package);

foreach ($alert['advisories'] as $advisory)
{
$this->info('Version: ' . $alert['version']);
foreach ($alert['advisories'] as $advisory)
{
$this->info('Version: ' . $alert['version']);

$this->info('Title: ' . $advisory['title']);
$this->info('Title: ' . $advisory['title']);

$this->info('Link: ' . $advisory['link']);
$this->info('Link: ' . $advisory['link']);

if($advisory['cve'] != "")
{
$this->info('CVE: ' . $advisory['cve']);
if($advisory['cve'] != "")
{
$this->info('CVE: ' . $advisory['cve']);
}
}
}
}

}
else
{
$this->info('No security advisories found!');
}
}
else
catch (RuntimeException $e)
{
$this->info('No security advisories found!');
$this->error('Security check failed: ' . $e->getMessage());
}
}
}

0 comments on commit b945939

Please sign in to comment.