fix(sbom): .NET assemblies from DLL metadata mapped to NuGet ids (#460) #474

Merged
sharang merged 1 commits from fix/460-nuget-assembly-mapping into main 2026-10-05 22:54:45 +00:00
Owner

Closes #460.

Problem

Syft names a DLL without a .deps.json by its version resource (product name, file version). pkg:nuget/DotNetZip%20Library@1.9.1.5 matches nothing in OSV; pkg:nuget/DotNetZip@1.9.1.5 matches GHSA-7378-6268-4278.

Change

  • syft.rs reads the CycloneDX properties; components with syft:package:metadataType = dotnet-portable-executable-entry carry their DLL paths.
  • New sbom/nuget_assembly.rs maps each such assembly, in this order:
    1. DLL inside packages/<Id>.<Version>/ → that package
    2. curated alias table, by assembly name and then by product name, with a version rule per package (Package, ThreeParts for Newtonsoft.Json's build counter, Unrelated for EntityFramework's 6.400.420.x file versions: the DLL only confirms a manifest entry)
    3. assembly name (file name), if it is a valid NuGet id and not a project of the tree (project name / <AssemblyName>)
    4. otherwise no purl; recorded as a CveLookupIncomplete gap ("NuGet: …") and cve_complete = false, like the other gaps OSV can't check
  • Versions use nuget_license::normalise_version (#467): 4.1.0.0 → 4.1.0, +build stripped. A non-zero 4th part is kept, because 1.9.1.5 is a real NuGet version.
  • Dedupe per (id, normalised version). SbomEntry gets evidence: Vec<String> (serde default, skipped when empty), and merge_nuget merges evidence instead of dropping the duplicate.
  • SbomScanner::generate now returns GeneratedSbom { entries, syft_failure, unmapped_assemblies }.

Decisions to review

  • Alias before file name. The brief said to prefer the AssemblyName over the product name. But DotNetZip 1.9.1.x ships lib/net20/Ionic.Zip.dll (checked on nuget.org), and Ionic.Zip is a different package. With the file name first, the fixture would become pkg:nuget/Ionic.Zip@…. The file name still wins over the raw product name.
  • Own assemblies excluded (added beyond the issue): if the file name fallback ran on them, the tree's own build output would go to OSV and, since #467, to nuget.org as package ids. They keep their entry, get no purl, and are not reported as unmapped.
  • Native pe-binary components (the unknown ecosystem ones) are left alone. Mapping native DLLs to NuGet would be guesswork.

Tests

nuget_assembly::tests: the DotNetZip fixture (DotNetZip Library 1.9.1.5 from Ionic.Zip.dll becomes pkg:nuget/DotNetZip@1.9.1.5), the Json.NET / log4net / Helix +build / Xceed / MigraDoc examples, DLL+manifest dedupe with evidence (EF unrelated version), the restored folder, own and unmapped assemblies, and non-.NET components passing through unchanged. Ran cargo fmt, cargo clippy -p compliance-agent --all-targets -D warnings, cargo test -p compliance-agent --lib (625 pass) and -p compliance-core --lib.

Docs: docs/guide/dotnet.md / dotnet-en.md have a new "Packages from DLLs" section.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB

Closes #460. ## Problem Syft names a DLL without a `.deps.json` by its version resource (product name, file version). `pkg:nuget/DotNetZip%20Library@1.9.1.5` matches nothing in OSV; `pkg:nuget/DotNetZip@1.9.1.5` matches GHSA-7378-6268-4278. ## Change - `syft.rs` reads the CycloneDX `properties`; components with `syft:package:metadataType = dotnet-portable-executable-entry` carry their DLL paths. - New `sbom/nuget_assembly.rs` maps each such assembly, in this order: 1. DLL inside `packages/<Id>.<Version>/` → that package 2. curated alias table, by assembly name and then by product name, with a version rule per package (`Package`, `ThreeParts` for Newtonsoft.Json's build counter, `Unrelated` for EntityFramework's `6.400.420.x` file versions: the DLL only confirms a manifest entry) 3. assembly name (file name), if it is a valid NuGet id and **not** a project of the tree (project name / `<AssemblyName>`) 4. otherwise no purl; recorded as a `CveLookupIncomplete` gap ("NuGet: …") and `cve_complete = false`, like the other gaps OSV can't check - Versions use `nuget_license::normalise_version` (#467): `4.1.0.0` → `4.1.0`, `+build` stripped. A non-zero 4th part is kept, because `1.9.1.5` is a real NuGet version. - Dedupe per (id, normalised version). `SbomEntry` gets `evidence: Vec<String>` (serde default, skipped when empty), and `merge_nuget` merges evidence instead of dropping the duplicate. - `SbomScanner::generate` now returns `GeneratedSbom { entries, syft_failure, unmapped_assemblies }`. ## Decisions to review - **Alias before file name.** The brief said to prefer the AssemblyName over the product name. But DotNetZip 1.9.1.x ships `lib/net20/Ionic.Zip.dll` (checked on nuget.org), and `Ionic.Zip` is a different package. With the file name first, the fixture would become `pkg:nuget/Ionic.Zip@…`. The file name still wins over the raw product name. - **Own assemblies excluded** (added beyond the issue): if the file name fallback ran on them, the tree's own build output would go to OSV and, since #467, to nuget.org as package ids. They keep their entry, get no purl, and are not reported as unmapped. - Native `pe-binary` components (the `unknown` ecosystem ones) are left alone. Mapping native DLLs to NuGet would be guesswork. ## Tests `nuget_assembly::tests`: the DotNetZip fixture (`DotNetZip Library 1.9.1.5` from `Ionic.Zip.dll` becomes `pkg:nuget/DotNetZip@1.9.1.5`), the Json.NET / log4net / Helix `+build` / Xceed / MigraDoc examples, DLL+manifest dedupe with evidence (EF unrelated version), the restored folder, own and unmapped assemblies, and non-.NET components passing through unchanged. Ran `cargo fmt`, `cargo clippy -p compliance-agent --all-targets -D warnings`, `cargo test -p compliance-agent --lib` (625 pass) and `-p compliance-core --lib`. Docs: `docs/guide/dotnet.md` / `dotnet-en.md` have a new "Packages from DLLs" section. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang added 1 commit 2026-10-05 22:43:21 +00:00
fix(sbom): .NET assemblies from DLL metadata mapped to NuGet ids (#460)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 10m39s
306b46b500
Syft names a DLL without a .deps.json by its version resource: product
name and file version. As a purl that is no NuGet package, so OSV
matched nothing: pkg:nuget/DotNetZip%20Library@1.9.1.5 has no advisory,
pkg:nuget/DotNetZip@1.9.1.5 has GHSA-7378-6268-4278.

Syft's dotnet-portable-executable-entry components are now mapped, in
this order:

- a DLL inside packages/<Id>.<Version>/ is that package
- a curated alias table, by assembly name (file name) and then product
  name (DotNetZip Library -> DotNetZip, Json.NET -> Newtonsoft.Json,
  Apache log4net -> log4net, Xceed Toolkit for WPF ->
  Extended.Wpf.Toolkit, empira MigraDoc -> PDFsharp-MigraDoc), with how
  the package's file versions relate to its versions (Newtonsoft.Json:
  first three parts; EntityFramework: unrelated, so the DLL only
  confirms a manifest entry)
- the assembly name, when it is a valid NuGet id and not one of the
  tree's own projects (project name or <AssemblyName>), whose names are
  not sent to OSV or nuget.org
- otherwise no purl, and the scan records the assembly as not matched
  against OSV

Alias before file name: DotNetZip ships Ionic.Zip.dll, and Ionic.Zip is
a different package. Versions go through nuget_license's
normalise_version (4.1.0.0 -> 4.1.0, +build dropped); a non-zero fourth
part stays (1.9.1.5 is a real NuGet version).

One package found in several DLLs, or in a DLL and a manifest, is one
entry: SbomEntry gains `evidence` (the manifests and DLLs it was read
from), and merge_nuget compares normalised versions and merges the
evidence instead of dropping it. Native pe-binary components are left
as they are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang force-pushed fix/460-nuget-assembly-mapping from 8571b660a2 to 306b46b500 2026-10-05 22:43:21 +00:00 Compare
sharang merged commit d8c52192d9 into main 2026-10-05 22:54:45 +00:00
Sign in to join this conversation.