Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
fixes #63
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbannert committed Sep 3, 2018
1 parent a266c7e commit 6dfe897
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Automatic/Automatic.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@
use Narrowspark\Automatic\Prefetcher\ParallelDownloader;
use Narrowspark\Automatic\Prefetcher\Prefetcher;
use Narrowspark\Automatic\Prefetcher\TruncatedComposerRepository;
use Narrowspark\Automatic\Security\Command\AuditCommandProvider;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use ReflectionClass;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputInterface;
use Composer\Plugin\Capable;
use Composer\Plugin\Capability\CommandProvider;

class Automatic implements PluginInterface, EventSubscriberInterface
class Automatic implements PluginInterface, EventSubscriberInterface, Capable
{
use ExpandTargetDirTrait;
use GetGenericPropertyReaderTrait;
Expand Down Expand Up @@ -141,6 +144,16 @@ public static function getSubscribedEvents(): array
];
}

/**
* {@inheritdoc}
*/
public function getCapabilities(): array
{
return [
CommandProvider::class => AuditCommandProvider::class,
];
}

/**
* {@inheritdoc}
*/
Expand Down
32 changes: 32 additions & 0 deletions src/Automatic/Contract/Crawler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace Narrowspark\Automatic\Contract;

/**
* @internal
*/
interface Crawler
{
/**
* Checks a Composer lock file.
*
* @param string $lock The path to the composer.lock file
*
* @return array An array of two items: the number of vulnerabilities and an array of vulnerabilities
*/
public function check(string $lock): array;

/**
* @param int $timeout
*
* @return void
*/
public function setTimeout(int $timeout): void;

/**
* @param string $endPoint
*
* @return void
*/
public function setEndPoint(string $endPoint): void;
}
11 changes: 11 additions & 0 deletions src/Automatic/Security/Checker/Checker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
declare(strict_types=1);
namespace Narrowspark\Automatic\Security\Checker;

class Checker
{
public function check(string $lock): array
{

}
}
41 changes: 41 additions & 0 deletions src/Automatic/Security/Command/AuditCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace Narrowspark\Automatic\Security\Command;

use Composer\Command\BaseCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class AuditCommand extends BaseCommand
{
/**
* {@inheritdoc}
*/
protected function configure(): void
{
$this
->setName('audit')
->setDefinition(array(
new InputOption('format', '', InputOption::VALUE_REQUIRED, 'The output format', 'text'),
new InputOption('endpoint', '', 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>%command.full_name%</info>
EOF
)
;
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{

}
}
16 changes: 16 additions & 0 deletions src/Automatic/Security/Command/AuditCommandProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace Narrowspark\Automatic\Security\Command;

use Composer\Plugin\Capability\CommandProvider;

class AuditCommandProvider implements CommandProvider
{
/**
* {@inheritdoc}
*/
public function getCommands(): array
{
return array(new AuditCommand());
}
}
3 changes: 3 additions & 0 deletions src/Automatic/Security/Crawler/BaseCrawler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
declare(strict_types=1);
namespace Narrowspark\Automatic\Security\Crawler;
Empty file.
Empty file.
Empty file.

0 comments on commit 6dfe897

Please sign in to comment.