Skip to content

Send composer package names with "/" separator to Trivy#6055

Open
Abdelmonem-BEN-NACEUR wants to merge 1 commit intoDependencyTrack:masterfrom
Abdelmonem-BEN-NACEUR:fix/trivy-composer-separator
Open

Send composer package names with "/" separator to Trivy#6055
Abdelmonem-BEN-NACEUR wants to merge 1 commit intoDependencyTrack:masterfrom
Abdelmonem-BEN-NACEUR:fix/trivy-composer-separator

Conversation

@Abdelmonem-BEN-NACEUR
Copy link
Copy Markdown

@Abdelmonem-BEN-NACEUR Abdelmonem-BEN-NACEUR commented Apr 22, 2026

Fixes #6054.

Trivy analyzer was sending composer package coordinates as vendor:package (colon) while Packagist and the Trivy composer vulnerability database index them as vendor/package (slash). Result: every composer component silently yielded zero vulnerabilities.

This PR extends the slash-separator handling in TrivyAnalysisTask to the composer PURL type, mirroring the fix applied to npm in #5679.

Changes

  • TrivyAnalysisTask.java: add PackageURL.StandardTypes.COMPOSER to the set of PURL types that use / as the namespace/name separator when constructing the name sent to the Trivy server.
  • TrivyAnalysisTaskTest.java: add testAnalyzeComposerComponentUsesSlashSeparator, which captures the PutBlob request body and asserts that the composer coordinate is transmitted as symfony/http-foundation, not symfony:http-foundation.

Before / After

Given a single composer component pkg:composer/symfony/http-foundation@6.4.15 ingested from a CycloneDX BOM:

Name sent to Trivy Trivy result
Before symfony:http-foundation 0 vulnerabilities
After symfony/http-foundation CVE-2025-64500 matched

Verified end-to-end against a production Trivy server (v0.69.3) and Dependency-Track 4.14.1 + this patch applied.

Test plan

  • mvn test -Dtest=TrivyAnalysisTaskTest passes, including the new test.
  • Manual upload of a composer-only BOM to a patched DT instance: analyzerIdentity is now set to TRIVY_ANALYZER and the expected CVE is attached to the component.
  • Regression check on npm-only and maven-only BOMs: no change in behavior for those ecosystems.

Like npm scoped packages before DependencyTrack#5679, composer components have a
vendor/package naming convention where the vendor corresponds to the
PURL namespace. The existing TrivyAnalysisTask constructs the Trivy
package name as `namespace + ":" + name` for anything that is not
npm or go, producing coordinates like "symfony:http-foundation" that
Trivy's composer vulnerability database cannot match. Packagist
indexes the package as "symfony/http-foundation" (slash), so every
composer component silently yields zero vulnerabilities through the
Trivy analyzer.

Add COMPOSER to the set of PURL types that use "/" as the namespace
separator, mirroring the fix applied to npm in DependencyTrack#5679. An integration
test under TrivyAnalysisTaskTest asserts that the PutBlob request
carries the composer coordinate with the expected slash separator.

Signed-off-by: Abdelmonem BEN NACEUR <abdelmonemnaceur@gmail.com>
@owasp-dt-bot
Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 22, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 5 duplication

Metric Results
Duplication 5

View in Codacy

🟢 Coverage 100.00% diff coverage

Metric Results
Coverage variation Report missing for 00ea12d1
Diff coverage 100.00% diff coverage (70.00%)

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (00ea12d) Report Missing Report Missing Report Missing
Head commit (1e11dd2) 24803 20107 81.07%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#6055) 3 3 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@nscuro nscuro added defect Something isn't working integration/trivy Related to the Trivy integration backport/4.14.2 PRs to be backported to v4.14.2 labels Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/4.14.2 PRs to be backported to v4.14.2 defect Something isn't working integration/trivy Related to the Trivy integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trivy analyzer: composer components silently return zero vulnerabilities

3 participants