Skip to content

Commit 4e5be9e

Browse files
committed
Emit warning instead of crashing on invalid security advisory API response, fixes #11767
1 parent a29acbd commit 4e5be9e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Composer/Repository/ComposerRepository.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,16 @@ static function ($data) use ($name, $create) {
709709
$options['http']['content'] = http_build_query(['packages' => array_keys($packageConstraintMap)]);
710710

711711
$response = $this->httpDownloader->get($apiUrl, $options);
712+
$warned = false;
712713
/** @var string $name */
713714
foreach ($response->decodeJson()['advisories'] as $name => $list) {
715+
if (!isset($packageConstraintMap[$name])) {
716+
if (!$warned) {
717+
$this->io->writeError('<warning>'.$this->getRepoName().' returned names which were not requested in response to the security-advisories API. '.$name.' was not requested but is present in the response. Requested names were: '.implode(', ', array_keys($packageConstraintMap)).'</warning>');
718+
$warned = true;
719+
}
720+
continue;
721+
}
714722
if (count($list) > 0) {
715723
$advisories[$name] = array_filter(array_map(
716724
static function ($data) use ($name, $create) {

0 commit comments

Comments
 (0)