Conditions | 8 |
Paths | 14 |
Total Lines | 42 |
Code Lines | 29 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 20.8919 |
Changes | 0 |
1 | <?php |
||
16 | 3 | public function displayResults(OutputInterface $output, $lockFilePath, array $vulnerabilities) |
|
17 | { |
||
18 | 3 | $output->writeln(sprintf('Security Check Report: <comment>%s</>', realpath($lockFilePath))); |
|
19 | |||
20 | 3 | if ($count = count($vulnerabilities)) { |
|
21 | $status = 'CRITICAL'; |
||
22 | $style = 'error'; |
||
23 | } else { |
||
24 | 3 | $status = 'OK'; |
|
25 | 3 | $style = 'info'; |
|
26 | } |
||
27 | |||
28 | 3 | $output->writeln(sprintf( |
|
29 | 3 | '<%s>[%s] %d %s known vulnerabilities</>', |
|
30 | 3 | $style, |
|
31 | 3 | $status, |
|
32 | 3 | $count, |
|
33 | 3 | 1 === $count ? 'package has' : 'packages have' |
|
34 | )); |
||
35 | |||
36 | 3 | if (0 !== $count) { |
|
37 | $output->write("\n"); |
||
38 | |||
39 | foreach ($vulnerabilities as $dependency => $issues) { |
||
40 | $dependencyFullName = $dependency.' ('.$issues['version'].')'; |
||
41 | $output->writeln('<info>'.$dependencyFullName."\n".str_repeat( |
||
42 | '-', |
||
43 | strlen($dependencyFullName) |
||
44 | )."</>\n"); |
||
45 | |||
46 | foreach ($issues['advisories'] as $issue => $details) { |
||
47 | $output->write(' * '); |
||
48 | if ($details['cve']) { |
||
49 | $output->write('<comment>'.$details['cve'].': </comment>'); |
||
50 | } |
||
51 | $output->writeln($details['title']); |
||
52 | |||
53 | if ('' !== $details['link']) { |
||
54 | $output->writeln(' '.$details['link']); |
||
55 | } |
||
56 | |||
57 | $output->writeln(''); |
||
58 | } |
||
63 |