Skip to content

Commit 73a3814

Browse files
authored
Merge pull request #15 from magehost/feature-composerfile-option
Feature: specify path to composer.lock
2 parents a5c8e57 + ef2389c commit 73a3814

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
/.idea/
12
/vendor/

src/Checker/HttpChecker.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ abstract class HttpChecker extends BaseChecker implements HttpCheckerInterface
88
{
99

1010
protected $endpoint = HttpCheckerInterface::DEFAULT_ENDPOINT;
11-
protected $timeout = 20;
11+
protected $timeout = HttpCheckerInterface::DEFAULT_TIMEOUT;
1212

1313
/**
1414
* {@inheritdoc}
1515
*/
16-
public function setTimeout($tiemout)
16+
public function setTimeout($timeout)
1717
{
1818
$this->timeout = $timeout;
1919
}

src/Checker/HttpCheckerInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ interface HttpCheckerInterface extends CheckerInterface
66
{
77

88
const DEFAULT_ENDPOINT = 'https://security.sensiolabs.org/check_lock';
9+
const DEFAULT_TIMEOUT = 20;
910

1011
/**
1112
* Sets the HTTP timeout in seconds

src/Command/AuditCommand.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Composer\Factory;
66
use Composer\Command\BaseCommand;
77
use FancyGuy\Composer\SecurityCheck\Checker\DefaultChecker;
8+
use FancyGuy\Composer\SecurityCheck\Checker\HttpCheckerInterface;
89
use FancyGuy\Composer\SecurityCheck\Checker\OfflineChecker;
910
use FancyGuy\Composer\SecurityCheck\Exception\ExceptionInterface;
1011
use FancyGuy\Composer\SecurityCheck\Formatter\JsonFormatter;
@@ -23,10 +24,11 @@ protected function configure()
2324
$this
2425
->setName('audit')
2526
->setDefinition(array(
26-
new InputOption('audit-db', '', InputOption::VALUE_REQUIRED, 'The path to the advisory database'),
27-
new InputOption('format', '', InputOption::VALUE_REQUIRED, 'The output format', 'text'),
28-
new InputOption('endpoint', '', InputOption::VALUE_REQUIRED, 'The security checker server URL'),
29-
new InputOption('timeout', '', InputOption::VALUE_REQUIRED, 'The HTTP timeout in seconds'),
27+
new InputOption('audit-db', '', InputOption::VALUE_REQUIRED, 'Path to the advisory database'),
28+
new InputOption('format', '', InputOption::VALUE_REQUIRED, 'Output format', 'text'),
29+
new InputOption('endpoint', '', InputOption::VALUE_REQUIRED, 'Security checker server URL', HttpCheckerInterface::DEFAULT_ENDPOINT),
30+
new InputOption('timeout', '', InputOption::VALUE_REQUIRED, 'HTTP timeout in seconds', HttpCheckerInterface::DEFAULT_TIMEOUT),
31+
new InputOption('file', '', InputOption::VALUE_REQUIRED, 'Path to composer.lock file', './composer.lock'),
3032
))
3133
->setDescription('Checks security issues in your project dependencies')
3234
->setHelp(<<<EOF
@@ -55,7 +57,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
5557
}
5658
}
5759

58-
$composerFile = Factory::getComposerFile();
60+
if (!$composerFile = $input->getOption('file')) {
61+
$composerFile = Factory::getComposerFile();
62+
}
5963

6064
try {
6165
$vulnerabilities = $checker->check($composerFile);

src/SecurityCheckPlugin.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ public function onCommandEvent(CommandEvent $event)
9191
break;
9292
case 'show':
9393
case 'validate':
94-
$this->auditDependencies();
94+
$fileArgument = $event->getInput()->getArgument('file');
95+
$this->auditDependencies($fileArgument);
9596
break;
9697
}
9798
}

0 commit comments

Comments
 (0)