fix(php): keep dependency edges to packages named like PHP extensions - #11051
Open
sueun-dev wants to merge 1 commit into
Open
fix(php): keep dependency edges to packages named like PHP extensions#11051sueun-dev wants to merge 1 commit into
sueun-dev wants to merge 1 commit into
Conversation
The composer.lock parser skipped every require key whose name starts with "ext" to drop PHP platform extensions. Platform extensions use the "ext-" prefix (ext-json, ext-curl, ...), so the bare "ext" prefix also dropped regular packages whose name happens to start with "ext", such as extension/foo. Their dependsOn edges were lost from the dependency graph. Match only the "ext-" prefix so real packages keep their edges.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
composer.lockparser skips everyrequirekey whose name starts withextto keep PHP platform extensions out of the dependency graph. Platform extensions are named with anext-prefix (ext-json,ext-curl, ...), so the bareextprefix also matches regular packages whose name starts withextand drops theirdependsOnedges.pkg/dependency/parser/php/composer/parse.go:For a lock where
acme/apprequiresextension/foo, theacme/app -> extension/fooedge is dropped, so the dependency graph (and the SBOMdependsOn/ vulnerability dependency path) no longer shows howextension/foowas pulled in. Packagist currently lists over 180 published packages whose name starts withextbut notext-, for exampleextend/module-warrantyandextcode/cart.The fix matches the
ext-prefix only.Test
Added
TestParse_ExtPrefixDependencywith a small lock whereacme/apprequiresphp,ext-jsonandextension/foo. It checks that the edge toextension/foois kept whilephpandext-jsonare skipped. It fails before the change and passes after.