Conditions | 8 |
Paths | 14 |
Total Lines | 35 |
Code Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 25.755 |
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('<%s>[%s] %d %s known vulnerabilities</>', $style, $status, $count, |
|
29 | 3 | 1 === $count ? 'package has' : 'packages have')); |
|
30 | |||
31 | 3 | if (0 !== $count) { |
|
32 | $output->write("\n"); |
||
33 | |||
34 | foreach ($vulnerabilities as $dependency => $issues) { |
||
35 | $dependencyFullName = $dependency.' ('.$issues['version'].')'; |
||
36 | $output->writeln('<info>'.$dependencyFullName."\n".str_repeat('-', |
||
37 | strlen($dependencyFullName))."</>\n"); |
||
38 | |||
39 | foreach ($issues['advisories'] as $issue => $details) { |
||
40 | $output->write(' * '); |
||
41 | if ($details['cve']) { |
||
42 | $output->write('<comment>'.$details['cve'].': </comment>'); |
||
43 | } |
||
44 | $output->writeln($details['title']); |
||
45 | |||
46 | if ('' !== $details['link']) { |
||
47 | $output->writeln(' '.$details['link']); |
||
48 | } |
||
49 | |||
50 | $output->writeln(''); |
||
51 | } |
||
56 |