/
ComposerChecker.php
47 lines (37 loc) · 1.02 KB
/
ComposerChecker.php
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
42
43
44
45
46
47
<?php
namespace Hipay\PHPCI\Plugin;
use PHPCI\Plugin;
use PHPCI\Builder;
use PHPCI\Model\Build;
use SensioLabs\Security\SecurityChecker;
class ComposerChecker implements Plugin
{
public function __construct(Builder $phpci, Build $build, array $options = array())
{
$this->phpci = $phpci;
$this->build = $build;
$this->buildArgs($options);
}
public function buildArgs($options)
{
}
public static function canExecute($stage, Builder $builder, Build $build)
{
$path = $builder->buildPath . '/composer.lock';
if (file_exists($path)) {
return true;
}
return false;
}
public function execute()
{
$this->phpci->logExecOutput(false);
$checker = new SecurityChecker();
$alerts = $checker->check($this->phpci->buildPath . '/composer.lock');
$this->build->storeMeta('composer-security-check-errors', $alerts);
if (!$alerts) {
return true;
}
return false;
}
}