Skip to content

feat: include package purls in JSON output - #2885

Merged
another-rex merged 13 commits into
google:mainfrom
gotgolem:feat/json-package-purls
Oct 9, 2026
Merged

another-rex merged 13 commits into
google:mainfrom
gotgolem:feat/json-package-purls

Conversation

@gotgolem

Copy link
Copy Markdown
Contributor

Overview

Fixes #2874.

JSON output currently includes each scanned package's name, version, and ecosystem, but not its package URL.

This PR includes the package URL when scalibr provides one.

Details

I added an optional purl field to PackageInfo and populate it from scalibr's package URL in buildVulnerabilityResults.

The field is omitted (omitempty) when no PURL is available.

Testing

  • go test ./pkg/osvscanner
  • go test ./internal/output
  • go test ./pkg/models
  • ./scripts/run_lints.sh

Checklist

@another-rex another-rex left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Apologies for the late review!

Im happy with the change overall, though I think the test that's added is a bit too complicated for what we're actually doing. I would say try to simplify the test or just remove it entirely.

We're currently a bit busy recently, so might be a little while before we can get this merge in, but I will try to make sure this change is in the next osv-scanner release.

@gotgolem

Copy link
Copy Markdown
Contributor Author

@another-rex
Updated, thanks. I dropped the extra PURL-specific test since the existing snapshots already cover the JSON output.

@another-rex
another-rex enabled auto-merge (squash) September 11, 2026 00:37
@codecov-commenter

codecov-commenter commented Sep 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.16%. Comparing base (eb6f0e1) to head (cbd738c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2885   +/-   ##
=======================================
  Coverage   82.15%   82.16%           
=======================================
  Files         118      118           
  Lines        7690     7692    +2     
=======================================
+ Hits         6318     6320    +2     
  Misses       1372     1372           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@another-rex
another-rex enabled auto-merge (squash) September 18, 2026 01:33
@another-rex
another-rex disabled auto-merge October 2, 2026 04:25
# Conflicts:
#	cmd/osv-scanner/fix/__snapshots__/command_test.snap
#	cmd/osv-scanner/scan/source/__snapshots__/command_test.snap
@another-rex
another-rex merged commit 85c61ee into google:main Oct 9, 2026
24 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.

JSON output doesn't include purls for scanned packages

3 participants