Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

refactored the previous merge to avoid breaking BC

  • Loading branch information...
commit edb9441bc9afcd7083a644b4315582e33a80c4e3 1 parent db3b8c5
@fabpot fabpot authored
View
9 SensioLabs/Security/Command/SecurityCheckerCommand.php
@@ -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,10 +63,6 @@ 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));
@@ -75,5 +70,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
$output->write($data);
+
+ if ($this->checker->getLastVulnerabilityCount() > 0) {
+ return 1;
+ }
}
}
View
12 SensioLabs/Security/SecurityChecker.php
@@ -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;
+ }
}
View
17 SensioLabs/Security/SecurityException.php
@@ -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
-{
-
-}
Please sign in to comment.
Something went wrong with that request. Please try again.