Skip to content

Generate NuGet PURL's#642

Open
KendallHarterAtWork wants to merge 11 commits into
mainfrom
nuget-package-url
Open

Generate NuGet PURL's#642
KendallHarterAtWork wants to merge 11 commits into
mainfrom
nuget-package-url

Conversation

@KendallHarterAtWork

Copy link
Copy Markdown
Collaborator

Summary

If merged this pull request will generate PURL's for NuGet packages as an additional name in the SBOM.

Proposed changes

This also runs init_hook for hooks implementing establish_relationships during the generate command, which was not done previously.

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown

✅ No SBOM Changes Detected

For commit 0ac6122 (Run 29793029091)
Compared against commit fb56cd8 (Run 29785707536)

@nightlark nightlark 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.

  • Some extra guards/checks against potential exceptions, stylistic single/double underscore naming change.
  • Add a user config option to opt-in to network requests to nuget.
  • Add caching for results from NuGet API requests to eliminate repeated requests for the same info, and a network timeout to avoid hanging if the server is unresponsive.

I'm thinking in the future maybe this could also leverage any results from dapper that might be in the metadata, which could allow for an "offline" fallback, or reduce the number of NuGet API requests that are needed.

For a future change outside of this PR, we might want to add a new hook type that this could later be updated to use along the lines of
enrich_software(sbom: SBOM, software: Software) -> None that would be called once per software entry (perhaps after establishing relationships) rather than once for each metadata entry, and would be intended for plugins that are looking at potentially many metadata entries and relationships at the same time.

Comment thread surfactant/relationships/nuget_purl.py Outdated
Comment thread surfactant/relationships/nuget_purl.py Outdated
Comment thread surfactant/relationships/nuget_purl.py Outdated
Comment thread surfactant/relationships/nuget_purl.py Outdated
Comment thread surfactant/relationships/nuget_purl.py Outdated
Comment thread surfactant/relationships/nuget_purl.py
Comment thread surfactant/relationships/nuget_purl.py
Comment thread surfactant/relationships/nuget_purl.py Outdated
Comment thread surfactant/relationships/nuget_purl.py
Comment thread surfactant/relationships/nuget_purl.py Outdated
@nightlark
nightlark force-pushed the nuget-package-url branch from 5880bdf to 7b4e49b Compare July 21, 2026 01:21
@nightlark

nightlark commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Fixed a small regression that prevented the version check from working, and noticed that the metadata["FileInfo"]["ProductVersion"] is often better for lookups than the assembly version (or any of the other version fields in file info.

Quite a few frequently used packages will add fourth version number components that make the NuGet lookup not find a matching version. "ProductVersion" on the other hand appears to always match the version numbers that appear on NuGet including pre-release components (after removing any trailing +<hash> from it). I suspect "ProductName" might be the best option for looking up a matching package (possibly even in cases where the file name != package name), if we had some way to map it to the package name to search for on NuGet.

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