The Decoration Pipeline
Beyond scanning,pkg/scanoss is the SDK for the SCANOSS decoration services, the same ones behind SCANOSS-CLI’s decoration commands. The pipeline runs a configurable set of them over the same PURLs (Package URLs, the pkg:type/namespace/name@version scheme identifying each component) in parallel, reports per-service progress, and returns one object keyed by service. Chunking and the worker pool are handled internally.
pipe.Run only returns an error when every service in the pipeline failed. A partial failure, one service down, the rest fine, comes back as a successful result with the failing service’s error recorded in res.Errors, so one bad service doesn’t discard the results you did get.
Component Version Requirements
scanoss.Components(...), used above, is a shorthand that builds a component list from bare PURLs, no version attached. That’s fine for lookups where the latest or any version will do. When a version matters, build the components directly instead:
comps works anywhere a decoration call takes one, the pipeline, a single service, or WithDecorationReporter, shown next.
Per-Service Progress
ImplementDecorationReporter and hand it to the call. Every update carries the service that produced it, so one receiver renders them all, and since services run concurrently, it must be safe for concurrent use:
A Single Service, Without the Pipeline
Each decoration service is a grouped handle on the client, useful when you only need one and the pipeline’s parallel fan-out would be overkill:Scanning from the SDK
Scan.Folder and Scan.Files take further options:
Each matched file’s
sbom.FileEvidence also carries MatchIndex: where its component stood among the candidates the scan returned for that file, after the BOM rules, with 0 being the component the file originates from. IsPrimary() reports whether it’s 0. MatchIndex is nil on declared evidence and in documents written before the field existed.
Breaking change in v0.8.2. The library now skips licence headers by
default, matching the CLI. Callers of
pkg/wfp, pkg/scanoss, and
pkg/scanpipeline that pass no fingerprint options now produce filtered
fingerprints, which don’t match fingerprints taken with headers included.
Some files can match a different component or version, or stop matching. To
keep the previous output, pass wfp.WithoutSkipHeaders(). The libscanoss
C exports GenerateWFP and GenerateWFPJSON also filter headers now, and
don’t yet offer a way to opt out.Scan.Wait on a resumed scan now applies BOM rules the same way a fresh scan does, so results from results <id> match what a fresh scan of the same source would produce.
Logging
The SDK writes nothing until you ask it to, it won’t put lines in your program’s output uninvited. One call covers every package it’s built from, not just the client:Debug this also explains file selection, which rules a collection applied, and which rule excluded each file:
Call
SetLogger during initialisation: it’s process-wide, so changing it
while calls are in flight can split a run’s output across two
destinations.Request Tuning
BeyondAPIKey, APIURL, and the proxy/TLS fields covered in Authentication, Config exposes the request behaviour itself:
All are zero-value-safe: an unset field falls back to its default, so you only need to set what you’re overriding.