Visitar URL original
fix(php): keep dependency edges to packages named like PHP extensions by sueun-dev · Pull Request #11051 · aquasecurity/trivy · GitHub
Skip to content

fix(php): keep dependency edges to packages named like PHP extensions - #11051

Merged
DmitriyLewen merged 2 commits into
aquasecurity:mainfrom
sueun-dev:fix-composer-ext-prefix
Oct 14, 2026
Merged

DmitriyLewen merged 2 commits into
aquasecurity:mainfrom
sueun-dev:fix-composer-ext-prefix

Conversation

@sueun-dev

@sueun-dev sueun-dev commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

The composer.lock parser skips every require key whose name starts with ext to keep PHP platform extensions out of the dependency graph. Platform extensions are named with an ext- prefix (ext-json, ext-gd, ...), so the bare ext prefix also matches regular packages whose name starts with ext and drops their dependsOn edges.

pkg/dependency/parser/php/composer/parse.go:

if depName == "php" || strings.HasPrefix(depName, "ext") {
    continue
}

For a lock where acme/app requires extension/foo, the acme/app -> extension/foo edge is dropped, so the dependency graph no longer shows how extension/foo was pulled in. Packagist currently lists over 180 published packages whose name starts with ext but not ext-, for example extend/module-warranty and extcode/cart.

The fix skips a require entry only when its name has no vendor prefix (no /), as suggested in review. Composer platform packages (php, php-64bit, hhvm, ext-<name>, lib-<name>, ...) have no vendor, while a regular package name consists of a vendor name and the project's name (docs).

Test

Added a package name starts with ext case to the table-driven TestParse with a small lock where acme/app requires php, ext-json and extension/foo. It checks the packages and that only the edge to extension/foo is kept. On the commit before the original change the new case fails (no dependencies are returned); with this PR both TestParse cases pass.

go test ./pkg/dependency/parser/php/composer/...

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.

@DmitriyLewen DmitriyLewen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sueun-dev

Thanks for your work and your patience.
I left a couple of comments.

Regards, Dmitriy

Address review feedback:

- Skip a require entry when its name has no "/" instead of matching the
  "php" and "ext-" names. Composer platform packages (php, ext-*, lib-*,
  composer-plugin-api, ...) have no vendor prefix, while regular package
  names are "vendor/project".
- Move the ext-prefix regression into the table-driven TestParse so the
  packages are checked too.

@DmitriyLewen DmitriyLewen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work!

LGTM

@DmitriyLewen
DmitriyLewen added this pull request to the merge queue Oct 14, 2026
Merged via the queue into aquasecurity:main with commit 0900c7e Oct 14, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants