feat(sbom): NuGet licenses from .nuspec files, then nuget.org (#468)
NuGet SBOM entries carried no license: none of the files they come from names one. Fill it in after the NuGet components are merged (#467): - local first: the .nuspec of a restored package; <license type="expression"> as SPDX, type="file" as LicenseRef-file, an old <licenseUrl> mapped to SPDX for well-known license pages, else kept - then nuget.org: registration leaf (gzip) -> catalogEntry (inline or linked on api.nuget.org) -> licenseExpression / licenseFile / licenseUrl - only real ids at exact versions (no ranges, no DLL-metadata names); versions normalised as nuget.org files them (6.2.0.0 -> 6.2.0, 2.0 -> 2.0.0) - ids a nuget.config maps to another feed are never sent; a tree whose nuget.config lists another feed without a mapping is not looked up - through guarded_net, 8 at once, 10 s per request, 60 s and 300 uncached packages per scan; failures stay empty, one warning per scan - cached across tenants in the admin database (nuget_licenses, TTL: a year for a license, a week for none) - NUGET_LICENSE_LOOKUP=false turns the nuget.org step off Closes #467 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
This commit was merged in pull request #468.
This commit is contained in:
1 parent
04b4f32807
commit
34688fa322
9 files changed
+1582
-5
No files matched your search
@@ -32,6 +32,19 @@ Every package with an exact version gets the purl `pkg:nuget/<Id>@<Version>`
|
||||
and is matched against OSV (ecosystem NuGet). A version range (`7.*`,
|
||||
`[1.0,2.0)`) is listed without a purl, with the range as its requirement.
|
||||
|
||||
**Licenses of NuGet packages.** First from the `.nuspec` of a restored package
|
||||
(`packages/<Id>.<Version>/`): `<license type="expression">` as an SPDX
|
||||
expression, `<license type="file">` as `LicenseRef-file`, an older
|
||||
`<licenseUrl>` as an SPDX id when it points at a well-known license (MIT,
|
||||
Apache-2.0, BSD, MS-PL, LGPL, …), otherwise as the URL. What is still missing
|
||||
is looked up on nuget.org (the registration API on `api.nuget.org`, package id
|
||||
and version only, no packages). Packages a `nuget.config` maps to another
|
||||
source with `<packageSourceMapping>` are never looked up; when a `nuget.config`
|
||||
lists another source without a mapping, nothing of that tree is looked up, as
|
||||
a package id may be an internal one. Answers are cached for all tenants
|
||||
(public data). `NUGET_LICENSE_LOOKUP=false` turns the lookup off for a
|
||||
deployment.
|
||||
|
||||
**Dependencies not fully resolved.** A project with `<PackageReference>` items
|
||||
and neither `packages.lock.json` nor `obj/project.assets.json` names only its
|
||||
direct packages. The scan lists it under **Nicht ausgeführt**
|
||||
|
||||
@@ -33,6 +33,20 @@ wird gegen OSV (Ökosystem NuGet) abgeglichen. Ein Versionsbereich (`7.*`,
|
||||
`[1.0,2.0)`) steht ohne purl in der Stückliste, mit dem Bereich als
|
||||
Anforderung.
|
||||
|
||||
**Lizenzen der NuGet-Pakete.** Zuerst aus der `.nuspec` eines
|
||||
wiederhergestellten Pakets (`packages/<Id>.<Version>/`): `<license
|
||||
type="expression">` als SPDX-Ausdruck, `<license type="file">` als
|
||||
`LicenseRef-file`, eine ältere `<licenseUrl>` als SPDX-Kennung, wenn sie auf
|
||||
eine bekannte Lizenz zeigt (MIT, Apache-2.0, BSD, MS-PL, LGPL, …), sonst als
|
||||
URL. Was dort fehlt, wird bei nuget.org nachgeschlagen (Registration-API auf
|
||||
`api.nuget.org`, nur Paket-Id und Version, keine Pakete). Nicht gefragt wird
|
||||
nach Paketen, die eine `nuget.config` per `<packageSourceMapping>` einer
|
||||
anderen Quelle zuordnet; nennt eine `nuget.config` eine andere Quelle ohne
|
||||
Zuordnung, wird für diesen Baum gar nicht nachgeschlagen, denn eine Paket-Id
|
||||
kann die eines internen Pakets sein. Die Antworten werden für alle Mandanten
|
||||
zwischengespeichert (öffentliche Daten). `NUGET_LICENSE_LOOKUP=false` schaltet
|
||||
die Abfrage für eine Installation ab.
|
||||
|
||||
**Unvollständig aufgelöste Abhängigkeiten.** Ein Projekt mit
|
||||
`<PackageReference>` ohne `packages.lock.json` und ohne
|
||||
`obj/project.assets.json` nennt nur seine direkten Pakete. Die Prüfung führt
|
||||
|
||||
@@ -109,6 +109,10 @@ Prüfwerk matches every SBOM component directly against two public vulnerability
|
||||
|
||||
Matches are stored as CVE alerts with CVSS scores and re-checked hourly, so newly published CVEs against an unchanged dependency still raise a notification.
|
||||
|
||||
## nuget.org -- NuGet Licenses
|
||||
|
||||
Licenses of NuGet packages that no `.nuspec` in the tree gives are read from the [nuget.org registration API](https://learn.microsoft.com/nuget/api/registration-base-url-resource) (`api.nuget.org`). Only the package id and version are sent, never for an id a `nuget.config` routes to another feed (see [.NET projects](/guide/dotnet-en)). The lookup is bounded per scan (8 requests at once, 10 s per request, 60 s and 300 uncached packages in total); answers are cached for all tenants. Set `NUGET_LICENSE_LOOKUP=false` to keep the agent from contacting nuget.org.
|
||||
|
||||
## Custom OAuth Scanner
|
||||
|
||||
A purpose-built scanner that detects OAuth and OIDC misconfigurations in your code, including:
|
||||
|
||||
Reference in new issue
Block a user