Skip to content

Commit

Permalink
Merge pull request #17 from cs278/more-debug
Browse files Browse the repository at this point in the history
Add more debugging output
  • Loading branch information
cs278 authored Jul 27, 2021
2 parents fece67f + a8ce0ac commit 6a1c261
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/AuditCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,24 @@ protected function execute(InputInterface $input, OutputInterface $output)

// Find all the advisories for installed packages.
foreach ($packages as $name => $version) {
$output->writeln(sprintf(
'Checking <info>%s</info> (<info>%s</info>) for advisories...',
$name,
$name !== 'cs278/composer-audit' ? $version : 'N/A'
), OutputInterface::VERBOSITY_DEBUG);

foreach ($advisoriesManager->findByPackageNameAndVersion($name, $version) as $advisory) {
$advisories[$name][] = $advisory;
}

if (\count($advisories[$name] ?? []) > 0) {
$output->writeln(sprintf(
'Found %u advisories for <info>%s</info> (<info>%s</info>)',
\count($advisories[$name]),
$name,
$name !== 'cs278/composer-audit' ? $version : 'N/A'
), OutputInterface::VERBOSITY_VERY_VERBOSE);
}
}

self::clearLine(
Expand Down
1 change: 1 addition & 0 deletions tests/integration/ignore--broken-show-warnings.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ true
Ignoring invalid ignore rule: `{"type":"package","value":"foo\/bar"}`
Ignoring invalid ignore rule: `{"type":"cve","value":""}`
Ignoring invalid ignore rule: `{"type":"","value":"test"}`
Found 9 advisories for symfony/http-foundation (2.0.4)
Found 9 advisories affecting 1 package(s).

composer://symfony/http-foundation (2.0.4)
Expand Down
17 changes: 17 additions & 0 deletions tests/integration/verbose_debug_no_errors.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
No packages results in no errors (debug level messages)
--CONDITION--
true
--COMPOSER--
{}
--ARGS--
-vvv
--EXPECT-EXIT--
0
--EXPECT-OUTPUT--
Checking cs278/composer-audit (N/A) for advisories...
Checking symfony/deprecation-contracts (v2.4.0) for advisories...
Checking symfony/polyfill-ctype (v1.23.0) for advisories...
Checking symfony/polyfill-php80 (v1.23.0) for advisories...
Checking symfony/yaml (v5.3.4) for advisories...
No advisories found for any packages.

0 comments on commit 6a1c261

Please sign in to comment.