Permalink
Browse files

made the timeout configurable

  • Loading branch information...
1 parent b9de1a2 commit da1f9d19c80eac2b6ae8043bb92b7c7a16d00713 @fabpot fabpot committed Jul 8, 2014
@@ -40,6 +40,7 @@ protected function configure()
new InputArgument('lock', InputArgument::OPTIONAL, 'The path to the composer.lock file', 'composer.lock'),
new InputOption('format', '', InputOption::VALUE_REQUIRED, 'The output format', 'text'),
new InputOption('end-point', '', InputOption::VALUE_REQUIRED, 'The security checker server URL'),
+ new InputOption('timeout', '', InputOption::VALUE_REQUIRED, 'The HTTP timeout'),
))
->setDescription('Checks security issues in your project dependencies')
->setHelp(<<<EOF
@@ -66,6 +67,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->checker->setEndPoint($endPoint);
}
+ if ($timeout = $input->getOption('timeout')) {
+ $this->checker->setTimeout($timeout);
+ }
+
try {
$data = $this->checker->check($input->getArgument('lock'), $input->getOption('format'));
} catch (\Exception $e) {
@@ -15,6 +15,12 @@ class SecurityChecker
{
private $endPoint = 'https://security.sensiolabs.org/check_lock';
private $vulnerabilitiesCount;
+ private $timeout = 20;
+
+ public function setTimeout($timeout)
+ {
+ $this->timeout = $timeout;
+ }
public function setEndPoint($endPoint)
{
@@ -76,7 +82,7 @@ public function check($lock, $format = 'text')
curl_setopt($curl, CURLOPT_URL, $this->endPoint);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: '.$accept));
curl_setopt($curl, CURLOPT_POSTFIELDS, $postFields);
- curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
+ curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $this->timeout);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_MAXREDIRS, 3);

0 comments on commit da1f9d1

Please sign in to comment.