-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement SecurityChecker * Remove unused class; Load advisories only when var is empty
- Loading branch information
Showing
25 changed files
with
3,247 additions
and
23 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ coverage: | |
project: | ||
default: | ||
informational: true | ||
path: | ||
patch: | ||
default: | ||
informational: true |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buddy\Repman\Command; | ||
|
||
use Buddy\Repman\Service\Security\SecurityChecker; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class UpdateAdvisoriesDbCommand extends Command | ||
{ | ||
private SecurityChecker $checker; | ||
|
||
public function __construct(SecurityChecker $checker) | ||
{ | ||
parent::__construct(); | ||
|
||
$this->checker = $checker; | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('repman:security:update-db') | ||
->setDescription('Update security advisories database') | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$this->checker->update(); | ||
$output->writeln(sprintf('Database successfully updated')); | ||
|
||
return 0; | ||
} | ||
} |
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,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buddy\Repman\Service\Security\SecurityChecker; | ||
|
||
final class Advisory | ||
{ | ||
private string $title; | ||
private string $cve; | ||
private string $link; | ||
/** | ||
* @var Versions[] | ||
*/ | ||
private array $branches; | ||
|
||
/** | ||
* @param Versions[] $branches | ||
*/ | ||
public function __construct(string $title, string $cve, string $link, array $branches) | ||
{ | ||
$this->title = $title; | ||
$this->cve = $cve; | ||
$this->link = $link; | ||
$this->branches = $branches; | ||
} | ||
|
||
/** | ||
* @return Versions[] | ||
*/ | ||
public function branches(): array | ||
{ | ||
return $this->branches; | ||
} | ||
|
||
/** | ||
* @return array<string,string> | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return [ | ||
'title' => $this->title, | ||
'cve' => $this->cve, | ||
'link' => $this->link, | ||
]; | ||
} | ||
} |
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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buddy\Repman\Service\Security\SecurityChecker; | ||
|
||
final class Package | ||
{ | ||
private string $name; | ||
private string $version; | ||
|
||
public function __construct(string $name, string $version) | ||
{ | ||
$this->name = $name; | ||
$this->version = $version; | ||
} | ||
|
||
public function name(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function version(): string | ||
{ | ||
return $this->version; | ||
} | ||
} |
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,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buddy\Repman\Service\Security\SecurityChecker; | ||
|
||
final class Result | ||
{ | ||
private string $version; | ||
/** | ||
* @var Advisory[] | ||
*/ | ||
private array $advisories; | ||
|
||
/** | ||
* @param Advisory[] $advisories | ||
*/ | ||
public function __construct(string $version, array $advisories) | ||
{ | ||
$this->version = $version; | ||
$this->advisories = $advisories; | ||
} | ||
|
||
/** | ||
* @return array<string,string|array<string,string>> | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return [ | ||
'version' => $this->version, | ||
'advisories' => array_map(fn ($advisory) => $advisory->toArray(), $this->advisories), | ||
]; | ||
} | ||
} |
Oops, something went wrong.