Skip to content

Commit

Permalink
Fix root aliases causing problems when auditing locked dependencies, f…
Browse files Browse the repository at this point in the history
…ixes #11771
  • Loading branch information
Seldaek committed Feb 7, 2024
1 parent fa04013 commit 0c99bfc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Composer/Repository/RepositorySet.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Composer\Semver\Constraint\ConstraintInterface;
use Composer\Package\Version\StabilityFilter;
use Composer\Semver\Constraint\MatchAllConstraint;
use Composer\Semver\Constraint\MultiConstraint;

/**
* @author Nils Adermann <naderman@naderman.de>
Expand Down Expand Up @@ -245,7 +246,15 @@ public function getMatchingSecurityAdvisories(array $packages, bool $allowPartia
{
$map = [];
foreach ($packages as $package) {
$map[$package->getName()] = new Constraint('=', $package->getVersion());
// ignore root alias versions as they are not actual package versions and should not matter when it comes to vulnerabilities
if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
continue;
}
if (isset($map[$package->getName()])) {
$map[$package->getName()] = new MultiConstraint([new Constraint('=', $package->getVersion()), $map[$package->getName()]], false);
} else {
$map[$package->getName()] = new Constraint('=', $package->getVersion());
}
}

return $this->getSecurityAdvisoriesForConstraints($map, $allowPartialAdvisories);
Expand Down

0 comments on commit 0c99bfc

Please sign in to comment.