Initiale Version

This commit is contained in:
Jan Unger
2016-08-16 21:20:53 +02:00
commit 88cf71d772
10930 changed files with 1708903 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
Copyright (c) 2013-2015 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,38 @@
SensioLabs Security Checker
===========================
The SensioLabs Security Checker is a command line tool that checks if your
application uses dependencies with known security vulnerabilities. It uses the
[SensioLabs Security Check Web service][1] and the [Security Advisories Database][2].
Usage
-----
Download the [security-checker.phar][3] file:
$ php security-checker.phar security:check /path/to/composer.lock
Use the code from the repository directly:
$ composer install
$ php security-checker security:check /path/to/composer.lock
Integration
-----------
The checker uses the Symfony Console component; so, you can easily integrate
the checker into your own project:
* by using the `SecurityCheckerCommand` class into your Symfony Console
application;
* by using the `SecurityChecker` class directly into your own code:
use SensioLabs\Security\SecurityChecker;
$checker = new SecurityChecker();
$alerts = $checker->check('/path/to/composer.lock');
[1]: http://security.sensiolabs.org/
[2]: https://github.com/FriendsOfPHP/security-advisories
[3]: http://get.sensiolabs.org/security-checker.phar

View File

@@ -0,0 +1,108 @@
<?php
/*
* This file is part of the SensioLabs Security Checker.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SensioLabs\Security\Command;
use SensioLabs\Security\SecurityChecker;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use SensioLabs\Security\Exception\ExceptionInterface;
use SensioLabs\Security\Formatters\JsonFormatter;
use SensioLabs\Security\Formatters\SimpleFormatter;
use SensioLabs\Security\Formatters\TextFormatter;
class SecurityCheckerCommand extends Command
{
private $checker;
public function __construct(SecurityChecker $checker)
{
$this->checker = $checker;
parent::__construct();
}
/**
* @see Command
*/
protected function configure()
{
$this
->setName('security:check')
->setDefinition(array(
new InputArgument('lockfile', 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 in seconds'),
))
->setDescription('Checks security issues in your project dependencies')
->setHelp(<<<EOF
The <info>%command.name%</info> command looks for security issues in the
project dependencies:
<info>php %command.full_name%</info>
You can also pass the path to a <info>composer.lock</info> file as an argument:
<info>php %command.full_name% /path/to/composer.lock</info>
By default, the command displays the result in plain text, but you can also
configure it to output JSON instead by using the <info>--format</info> option:
<info>php %command.full_name% /path/to/composer.lock --format=json</info>
EOF
);
}
/**
* @see Command
* @see SecurityChecker
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($endPoint = $input->getOption('end-point')) {
$this->checker->getCrawler()->setEndPoint($endPoint);
}
if ($timeout = $input->getOption('timeout')) {
$this->checker->getCrawler()->setTimeout($timeout);
}
try {
$vulnerabilities = $this->checker->check($input->getArgument('lockfile'));
} catch (ExceptionInterface $e) {
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($e->getMessage(), 'error', true));
return 1;
}
switch ($input->getOption('format')) {
case 'json':
$formatter = new JsonFormatter();
break;
case 'simple':
$formatter = new SimpleFormatter($this->getHelperSet()->get('formatter'));
break;
case 'text':
default:
$formatter = new TextFormatter($this->getHelperSet()->get('formatter'));
}
$formatter->displayResults($output, $input->getArgument('lockfile'), $vulnerabilities);
if ($this->checker->getLastVulnerabilityCount() > 0) {
return 1;
}
}
}

View File

@@ -0,0 +1,83 @@
<?php
/*
* This file is part of the SensioLabs Security Checker.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SensioLabs\Security\Crawler;
use SensioLabs\Security\Exception\RuntimeException;
/**
* @internal
*/
abstract class BaseCrawler implements CrawlerInterface
{
protected $endPoint = 'https://security.sensiolabs.org/check_lock';
protected $timeout = 20;
/**
* {@inheritdoc}
*/
public function setTimeout($timeout)
{
$this->timeout = $timeout;
}
/**
* {@inheritdoc}
*/
public function setEndPoint($endPoint)
{
$this->endPoint = $endPoint;
}
/**
* {@inheritdoc}
*/
public function check($lock)
{
$certFile = $this->getCertFile();
try {
list($headers, $body) = $this->doCheck($lock, $certFile);
} catch (\Exception $e) {
if (__DIR__.'/../Resources/security.sensiolabs.org.crt' !== $certFile) {
unlink($certFile);
}
throw $e;
}
if (!(preg_match('/X-Alerts: (\d+)/', $headers, $matches) || 2 == count($matches))) {
throw new RuntimeException('The web service did not return alerts count.');
}
return array(intval($matches[1]), json_decode($body, true));
}
/**
* @return array An array where the first element is a headers string and second one the response body
*/
abstract protected function doCheck($lock, $certFile);
private function getCertFile()
{
$certFile = __DIR__.'/../Resources/security.sensiolabs.org.crt';
if ('phar://' !== substr(__FILE__, 0, 7)) {
return $certFile;
}
$tmpFile = tempnam(sys_get_temp_dir(), 'sls');
if (false === @copy($certFile, $tmpFile)) {
throw new RuntimeException(sprintf('Unable to copy the certificate in "%s".', $tmpFile));
}
return $tmpFile;
}
}

View File

@@ -0,0 +1,31 @@
<?php
/*
* This file is part of the SensioLabs Security Checker.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SensioLabs\Security\Crawler;
/**
* @internal
*/
interface CrawlerInterface
{
/**
* Checks a Composer lock file.
*
* @param string $lock The path to the composer.lock file
*
* @return An array of two items: the number of vulnerabilities and an array of vulnerabilities
*/
public function check($lock);
public function setTimeout($timeout);
public function setEndPoint($endPoint);
}

View File

@@ -0,0 +1,82 @@
<?php
/*
* This file is part of the SensioLabs Security Checker.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SensioLabs\Security\Crawler;
use SensioLabs\Security\Exception\RuntimeException;
/**
* @internal
*/
class CurlCrawler extends BaseCrawler
{
public function __construct()
{
if (!function_exists('curl_init')) {
throw new RuntimeException('cURL is required to use the cURL crawler.');
}
}
/**
* {@inheritdoc}
*/
protected function doCheck($lock, $certFile)
{
if (false === $curl = curl_init()) {
throw new RuntimeException('Unable to create a cURL handle.');
}
$postFields = array('lock' => PHP_VERSION_ID >= 50500 ? new \CurlFile($lock) : '@'.$lock);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_URL, $this->endPoint);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/json'));
curl_setopt($curl, CURLOPT_POSTFIELDS, $postFields);
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);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl, CURLOPT_CAINFO, $certFile);
$response = curl_exec($curl);
if (false === $response) {
$error = curl_error($curl);
curl_close($curl);
throw new RuntimeException(sprintf('An error occurred: %s.', $error));
}
$headersSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$headers = substr($response, 0, $headersSize);
$body = substr($response, $headersSize);
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if (400 == $statusCode) {
$data = json_decode($body, true);
$error = $data['error'];
throw new RuntimeException($error);
}
if (200 != $statusCode) {
throw new RuntimeException(sprintf('The web service failed for an unknown reason (HTTP %s).', $statusCode));
}
return array($headers, $body);
}
}

View File

@@ -0,0 +1,49 @@
<?php
/*
* This file is part of the SensioLabs Security Checker.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SensioLabs\Security\Crawler;
/**
* @internal
*/
class DefaultCrawler implements CrawlerInterface
{
private $crawler;
public function __construct()
{
$this->crawler = function_exists('curl_init') ? new CurlCrawler() : new FileGetContentsCrawler();
}
/**
* {@inheritdoc}
*/
public function check($lock)
{
return $this->crawler->check($lock);
}
/**
* {@inheritdoc}
*/
public function setTimeout($timeout)
{
$this->crawler->setTimeout($timeout);
}
/**
* {@inheritdoc}
*/
public function setEndPoint($endPoint)
{
$this->crawler->setEndPoint($endPoint);
}
}

View File

@@ -0,0 +1,78 @@
<?php
/*
* This file is part of the SensioLabs Security Checker.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SensioLabs\Security\Crawler;
use SensioLabs\Security\Exception\RuntimeException;
/**
* @internal
*/
class FileGetContentsCrawler extends BaseCrawler
{
/**
* {@inheritdoc}
*/
protected function doCheck($lock, $certFile)
{
$boundary = '------------------------'.md5(microtime(true));
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => "Content-Type: multipart/form-data; boundary=$boundary\r\nAccept: application/json",
'content' => "--$boundary\r\nContent-Disposition: form-data; name=\"lock\"; filename=\"$lock\"\r\nContent-Type: application/octet-stream\r\n\r\n".file_get_contents($lock)."\r\n--$boundary\r\n--\r\n",
'ignore_errors' => true,
'follow_location' => true,
'max_redirects' => 3,
'timeout' => $this->timeout,
),
'ssl' => array(
'cafile' => $certFile,
'verify_peer' => 1,
'verify_host' => 2,
),
));
$level = error_reporting(0);
$body = file_get_contents($this->endPoint, 0, $context);
error_reporting($level);
if (false === $body) {
$error = error_get_last();
throw new RuntimeException(sprintf('An error occurred: %s.', $error['message']));
}
// status code
if (!preg_match('{HTTP/\d\.\d (\d+) }i', $http_response_header[0], $match)) {
throw new RuntimeException('An unknown error occurred.');
}
$statusCode = $match[1];
if (400 == $statusCode) {
$data = json_decode($body, true);
throw new RuntimeException($data['error']);
}
if (200 != $statusCode) {
throw new RuntimeException(sprintf('The web service failed for an unknown reason (HTTP %s).', $statusCode));
}
$headers = '';
foreach ($http_response_header as $header) {
if (false !== strpos($header, 'X-Alerts: ')) {
$headers = $header;
}
}
return array($headers, $body);
}
}

View File

@@ -0,0 +1,16 @@
<?php
/*
* This file is part of the SensioLabs Security Checker.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SensioLabs\Security\Exception;
interface ExceptionInterface
{
}

View File

@@ -0,0 +1,16 @@
<?php
/*
* This file is part of the SensioLabs Security Checker.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SensioLabs\Security\Exception;
class RuntimeException extends \RuntimeException implements ExceptionInterface
{
}

View File

@@ -0,0 +1,26 @@
<?php
/*
* This file is part of the SensioLabs Security Checker.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SensioLabs\Security\Formatters;
use Symfony\Component\Console\Output\OutputInterface;
interface FormatterInterface
{
/**
* Displays a security report as json.
*
* @param OutputInterface $output
* @param string $lockFilePath The file path to the checked lock file
* @param array $vulnerabilities An array of vulnerabilities
*/
public function displayResults(OutputInterface $output, $lockFilePath, array $vulnerabilities);
}

View File

@@ -0,0 +1,33 @@
<?php
/*
* This file is part of the SensioLabs Security Checker.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SensioLabs\Security\Formatters;
use Symfony\Component\Console\Output\OutputInterface;
class JsonFormatter implements FormatterInterface
{
/**
* Displays a security report as json.
*
* @param OutputInterface $output
* @param string $lockFilePath The file path to the checked lock file
* @param array $vulnerabilities An array of vulnerabilities
*/
public function displayResults(OutputInterface $output, $lockFilePath, array $vulnerabilities)
{
if (defined('JSON_PRETTY_PRINT')) {
$output->write(json_encode($vulnerabilities, JSON_PRETTY_PRINT));
} else {
$output->write(json_encode($vulnerabilities));
}
}
}

View File

@@ -0,0 +1,68 @@
<?php
/*
* This file is part of the SensioLabs Security Checker.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SensioLabs\Security\Formatters;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\FormatterHelper;
class SimpleFormatter implements FormatterInterface
{
public function __construct(FormatterHelper $formatter)
{
$this->formatter = $formatter;
}
/**
* Displays a security report as simple plain text.
*
* @param OutputInterface $output
* @param string $lockFilePath The file path to the checked lock file
* @param array $vulnerabilities An array of vulnerabilities
*/
public function displayResults(OutputInterface $output, $lockFilePath, array $vulnerabilities)
{
$output->writeln(sprintf('Security Check Report: <comment>%s</>', realpath($lockFilePath)));
if ($count = count($vulnerabilities)) {
$status = 'CRITICAL';
$style = 'error';
} else {
$status = 'OK';
$style = 'info';
}
$output->writeln(sprintf('<%s>[%s] %d %s known vulnerabilities</>', $style, $status, $count, 1 === $count ? 'package has' : 'packages have'));
if (0 !== $count) {
$output->write("\n");
foreach ($vulnerabilities as $dependency => $issues) {
$dependencyFullName = $dependency.' ('.$issues['version'].')';
$output->writeln('<info>'.$dependencyFullName."\n".str_repeat('-', strlen($dependencyFullName))."</>\n");
foreach ($issues['advisories'] as $issue => $details) {
$output->write(' * ');
if ($details['cve']) {
$output->write('<comment>'.$details['cve'].': </comment>');
}
$output->writeln($details['title']);
if ('' !== $details['link']) {
$output->writeln(' '.$details['link']);
}
$output->writeln('');
}
}
}
}
}

View File

@@ -0,0 +1,74 @@
<?php
/*
* This file is part of the SensioLabs Security Checker.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SensioLabs\Security\Formatters;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\FormatterHelper;
class TextFormatter implements FormatterInterface
{
public function __construct(FormatterHelper $formatter)
{
$this->formatter = $formatter;
}
/**
* Displays a security report as plain text.
*
* @param OutputInterface $output
* @param string $lockFilePath The file path to the checked lock file
* @param array $vulnerabilities An array of vulnerabilities
*/
public function displayResults(OutputInterface $output, $lockFilePath, array $vulnerabilities)
{
$output->writeln("\n<fg=blue>Security Check Report\n~~~~~~~~~~~~~~~~~~~~~</>\n");
$output->writeln(sprintf('Checked file: <comment>%s</>', realpath($lockFilePath)));
$output->write("\n");
if ($count = count($vulnerabilities)) {
$status = 'CRITICAL';
$style = 'error';
} else {
$status = 'OK';
$style = 'bg=green;fg=white';
}
$message = sprintf('%d %s known vulnerabilities', $count, 1 === $count ? 'package has' : 'packages have');
$output->writeln($this->formatter->formatBlock(array('['.$status.']', $message), $style, true));
$output->write("\n");
if (0 !== $count) {
foreach ($vulnerabilities as $dependency => $issues) {
$dependencyFullName = $dependency.' ('.$issues['version'].')';
$output->writeln('<info>'.$dependencyFullName."\n".str_repeat('-', strlen($dependencyFullName))."</>\n");
foreach ($issues['advisories'] as $issue => $details) {
$output->write(' * ');
if ($details['cve']) {
$output->write('<comment>'.$details['cve'].': </comment>');
}
$output->writeln($details['title']);
if ('' !== $details['link']) {
$output->writeln(' '.$details['link']);
}
$output->writeln('');
}
}
}
$output->writeln('<bg=yellow;fg=white> </> This checker can only detect vulnerabilities that are referenced');
$output->writeln('<bg=yellow;fg=white> Disclaimer </> in the SensioLabs security advisories database. Execute this');
$output->writeln("<bg=yellow;fg=white> </> command regularly to check the newly discovered vulnerabilities.\n");
}
}

View File

@@ -0,0 +1,25 @@
-----BEGIN CERTIFICATE-----
MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEU
MBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFs
IFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290
MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFowbzELMAkGA1UEBhMCU0Ux
FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5h
bCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9v
dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvt
H7xsD821+iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9
uMq/NzgtHj6RQa1wVsfwTz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzX
mk6vBbOmcZSccbNQYArHE504B4YCqOmoaSYYkKtMsE8jqzpPhNjfzp/haW+710LX
a0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy2xSoRcRdKn23tNbE7qzN
E0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv77+ldU9U0
WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYD
VR0PBAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0
Jvf6xCZU7wO94CTLVBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRU
cnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsx
IjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENBIFJvb3SCAQEwDQYJKoZIhvcN
AQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZlj7DYd7usQWxH
YINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5
6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvC
Nr4TDea9Y355e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEX
c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a
mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ=
-----END CERTIFICATE-----

View File

@@ -0,0 +1,67 @@
<?php
/*
* This file is part of the SensioLabs Security Checker.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SensioLabs\Security;
use SensioLabs\Security\Exception\RuntimeException;
use SensioLabs\Security\Crawler\CrawlerInterface;
use SensioLabs\Security\Crawler\DefaultCrawler;
class SecurityChecker
{
private $vulnerabilityCount;
private $crawler;
public function __construct(CrawlerInterface $crawler = null)
{
$this->crawler = null === $crawler ? new DefaultCrawler() : $crawler;
}
/**
* Checks a composer.lock file.
*
* @param string $lock The path to the composer.lock file
*
* @return array An array of vulnerabilities
*
* @throws RuntimeException When the lock file does not exist
* @throws RuntimeException When the certificate can not be copied
*/
public function check($lock)
{
if (is_dir($lock) && file_exists($lock.'/composer.lock')) {
$lock = $lock.'/composer.lock';
} elseif (preg_match('/composer\.json$/', $lock)) {
$lock = str_replace('composer.json', 'composer.lock', $lock);
}
if (!is_file($lock)) {
throw new RuntimeException('Lock file does not exist.');
}
list($this->vulnerabilityCount, $vulnerabilities) = $this->crawler->check($lock);
return $vulnerabilities;
}
public function getLastVulnerabilityCount()
{
return $this->vulnerabilityCount;
}
/**
* @return CrawlerInterface
*/
public function getCrawler()
{
return $this->crawler;
}
}

View File

@@ -0,0 +1,25 @@
{
"output": "security-checker.phar",
"chmod": "0755",
"compactors": [
"Herrera\\Box\\Compactor\\Php"
],
"extract": false,
"main": "security-checker",
"files": [
"LICENSE"
],
"finder": [
{
"name": "*.*",
"exclude": ["Tests"],
"in": "vendor"
},
{
"name": ["*.*", "*.crt"],
"in": "SensioLabs"
}
],
"stub": true,
"web": false
}

View File

@@ -0,0 +1,23 @@
{
"name": "sensiolabs/security-checker",
"description": "A security checker for your composer.lock",
"license": "MIT",
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien.potencier@gmail.com"
}
],
"require": {
"symfony/console": "~2.0|~3.0"
},
"bin": ["security-checker"],
"autoload": {
"psr-0": { "SensioLabs\\Security": "" }
},
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
}
}

View File

@@ -0,0 +1,32 @@
#!/usr/bin/env php
<?php
/*
* This file is part of the SensioLabs Security Checker.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
function includeIfExists($file)
{
if (file_exists($file)) {
return include $file;
}
}
if ((!$loader = includeIfExists(__DIR__.'/vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../autoload.php'))) {
die('You must set up the project dependencies, run the following commands:'.PHP_EOL.
'curl -sS https://getcomposer.org/installer | php'.PHP_EOL.
'php composer.phar install'.PHP_EOL);
}
use Symfony\Component\Console\Application;
use SensioLabs\Security\Command\SecurityCheckerCommand;
use SensioLabs\Security\SecurityChecker;
$console = new Application('SensioLabs Security Checker', '3.0');
$console->add(new SecurityCheckerCommand(new SecurityChecker()));
$console->run();