Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add audit command to check for security issues
- Loading branch information
1 parent
ad43746
commit 5300806
Showing
12 changed files
with
519 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace Composer\Command; | ||
|
||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Composer\Factory; | ||
use Composer\Util\Auditor; | ||
use Composer\Util\Filesystem; | ||
use Symfony\Component\Console\Input\InputOption; | ||
|
||
class AuditCommand extends BaseCommand | ||
{ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('audit') | ||
->setDescription('Checks for security vulnerability advisories for packages in your composer.lock.') | ||
->setDefinition(array( | ||
new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables auditing of require-dev packages.'), | ||
new InputOption('format', 'f', InputOption::VALUE_OPTIONAL, 'Output format. Must be "table" or "plain".', Auditor::FORMAT_TABLE), | ||
)) | ||
->setHelp( | ||
<<<EOT | ||
The <info>audit</info> command checks for security vulnerability advisories for packages in your composer.lock. | ||
If you do not want to include dev dependencies in the audit you can omit them with --no-dev | ||
Read more at https://getcomposer.org/doc/03-cli.md#audit | ||
EOT | ||
) | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$lockFile = Factory::getLockFile(Factory::getComposerFile()); | ||
if (!Filesystem::isReadable($lockFile)) { | ||
$this->getIO()->writeError('<error>' . $lockFile . ' is not readable.</error>'); | ||
return 1; | ||
} | ||
|
||
$composer = $this->requireComposer($input->getOption('no-plugins'), $input->getOption('no-scripts')); | ||
$locker = $composer->getLocker(); | ||
$packages = $locker->getLockedRepository(!$input->getOption('no-dev'))->getPackages(); | ||
$httpDownloader = Factory::createHttpDownloader($this->getIO(), $composer->getConfig()); | ||
|
||
$auditor = new Auditor($httpDownloader, $input->getOption('format')); | ||
return $auditor->audit($this->getIO(), $packages, false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.