SBOM: licenses for NuGet packages (local .nuspec, then nuget.org) #467

Closed
opened 2026-10-05 21:22:56 +00:00 by sharang · 0 comments
Owner

Every NuGet SBOM entry of a pilot scan has an empty license (126/126). Licenses are only filled for Cargo today (enrich_cargo_licenses).

Why NuGet entries have none:

  • packages.config / <PackageReference> / lockfiles / project.assets.json carry no license
  • the packages/ folder (with <id>.nuspec) is often not committed (and stripped by our import)
  • DLL-metadata entries never carry one

Tasks

  1. enrich_nuget_licenses after the NuGet components are collected:
    • local first: packages/<Id>.<Version>/<Id>.nuspec (and any *.nuspec beside a restored package) → <license type="expression"> → SPDX; <license type="file"> → LicenseRef-file; old <licenseUrl> → mapped to SPDX for well-known URLs, else kept as URL
    • then nuget.org: registration API https://api.nuget.org/v3/registration5-gz-semver2/<id-lower>/<version-lower>.json → catalogEntry.licenseExpression / licenseUrl
    • only for entries with a real NuGet id and exact version (purl pkg:nuget/…); skip ranges and DLL-metadata names (#460)
  2. Bounded: concurrency limit, per-request timeout, total time budget; failures leave the license empty and are logged once per run (no stage failure)
  3. Cache per (id, version) in Mongo (global, not per tenant: public data), TTL long (licenses of a published version do not change)
  4. net_guard: allow api.nuget.org like api.osv.dev
  5. Tests: nuspec expression / file / licenseUrl, registration JSON fixture, network failure → empty, cache hit
  6. Later, same pattern: npm (license in registry), Maven/Gradle (POM <licenses>)

Follow-up value: commercial components (e.g. UI toolkits under proprietary EULAs) become visible in the SBOM, relevant for CRA and licence compliance.

Source: first pilot scans on prod (2026-10-05). Target: in the next prod promotion.

Every NuGet SBOM entry of a pilot scan has an empty license (126/126). Licenses are only filled for Cargo today (`enrich_cargo_licenses`). Why NuGet entries have none: - `packages.config` / `<PackageReference>` / lockfiles / `project.assets.json` carry no license - the `packages/` folder (with `<id>.nuspec`) is often not committed (and stripped by our import) - DLL-metadata entries never carry one ## Tasks 1. `enrich_nuget_licenses` after the NuGet components are collected: - local first: `packages/<Id>.<Version>/<Id>.nuspec` (and any `*.nuspec` beside a restored package) → `<license type="expression">` → SPDX; `<license type="file">` → `LicenseRef-file`; old `<licenseUrl>` → mapped to SPDX for well-known URLs, else kept as URL - then nuget.org: registration API `https://api.nuget.org/v3/registration5-gz-semver2/<id-lower>/<version-lower>.json` → `catalogEntry.licenseExpression` / `licenseUrl` - only for entries with a real NuGet id and exact version (purl `pkg:nuget/…`); skip ranges and DLL-metadata names (#460) 2. Bounded: concurrency limit, per-request timeout, total time budget; failures leave the license empty and are logged once per run (no stage failure) 3. Cache per (id, version) in Mongo (global, not per tenant: public data), TTL long (licenses of a published version do not change) 4. `net_guard`: allow api.nuget.org like api.osv.dev 5. Tests: nuspec expression / file / licenseUrl, registration JSON fixture, network failure → empty, cache hit 6. Later, same pattern: npm (`license` in registry), Maven/Gradle (POM `<licenses>`) Follow-up value: commercial components (e.g. UI toolkits under proprietary EULAs) become visible in the SBOM, relevant for CRA and licence compliance. _Source: first pilot scans on prod (2026-10-05). Target: in the next prod promotion._
sharang added the highenhancement labels 2026-10-05 21:22:56 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: platform/pruefwerk#467