-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp
More file actions
executable file
·41 lines (33 loc) · 1.18 KB
/
app
File metadata and controls
executable file
·41 lines (33 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env php
<?php
require __DIR__ . '/vendor/autoload.php';
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use SensioLabs\Security\SecurityChecker;
use Symfony\Component\Console\Application;
class SecurityCheckerCommand extends Command
{
protected static $defaultName = 'security:check';
protected function configure()
{
$this->addArgument('lock_file', InputArgument::REQUIRED);
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$vulnerabilities = (new SecurityChecker())->check($input->getArgument('lock_file'));
if (empty($vulnerabilities)) {
$io->success('Everything is OK');
} else {
$io->error('Vulnerabilities detected!');
$io->error(json_encode($vulnerabilities, JSON_PRETTY_PRINT));
exit(1);
}
}
}
$app = new Application();
$app->add(new SecurityCheckerCommand);
$app->run();