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