Permalink
Browse files

refactored the previous merge to avoid breaking BC

  • Loading branch information...
1 parent db3b8c5 commit edb9441bc9afcd7083a644b4315582e33a80c4e3 @fabpot fabpot committed Apr 25, 2013
@@ -12,7 +12,6 @@
namespace SensioLabs\Security\Command;
use SensioLabs\Security\SecurityChecker;
-use SensioLabs\Security\SecurityException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -64,16 +63,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
try {
$data = $this->checker->check($input->getArgument('lock'), $input->getOption('format'));
- } catch (SecurityException $e) {
- $output->write($e->getMessage());
-
- return 1;
} catch (\Exception $e) {
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($e->getMessage(), 'error', true));
return 1;
}
$output->write($data);
+
+ if ($this->checker->getLastVulnerabilityCount() > 0) {
+ return 1;
+ }
}
}
@@ -13,6 +13,8 @@
class SecurityChecker
{
+ private $vulnerabilitiesCount;
+
/**
* Checks a composer.lock file.
*
@@ -109,11 +111,13 @@ public function check($lock, $format = 'text')
throw new \RuntimeException('The web service did not return alerts count');
}
- $vulnerabilitiesCount = intval($matches[1]);
- if ($vulnerabilitiesCount > 0) {
- throw new SecurityException($body, $vulnerabilitiesCount);
- }
+ $this->vulnerabilitiesCount = intval($matches[1]);
return $body;
}
+
+ public function getLastVulnerabilityCount()
+ {
+ return $this->vulnerabilitiesCount;
+ }
}
@@ -1,17 +0,0 @@
-<?php
-
-/*
- * This file is part of the SensioLabs Security Checker.
- *
- * (c) 2013 Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace SensioLabs\Security;
-
-class SecurityException extends \Exception
-{
-
-}

0 comments on commit edb9441

Please sign in to comment.