Documentation
¶
Overview ¶
Package sbom is what is inside a container image: every component, resolvable by digest or image ref.
CI posts a CycloneDX software bill of materials keyed by image digest, and /v1/sbom resolves that component set back.
GLOBAL BY DESIGN. Unlike the analytics lens (which is strictly per-org), an SBOM belongs to an image DIGEST, not a tenant — the digest is content-addressed, so any tenant deploying that image resolves the SAME component set. The store is therefore cross-tenant on purpose: ingest is gated to super-admin/CI (the build fleet), and resolve exposes only the immutable bill-of-materials of an image, no tenant data. This is why there is no org predicate here.
ONE datastore client. Like clients/analytics, this package rides the SAME datastore-go client the ai subsystem opens in the shared Bootstrap (ai/object.DatastoreExec/DatastoreQuery). It never opens a second connection.
Surface (/v1 only):
POST /v1/sbom ingest a CycloneDX SBOM (super-admin / CI only)
GET /v1/sbom/{ref} resolve by image digest OR image ref (for the console)
GET /v1/sbom/health liveness + datastore connectivity (not JWT-gated)
Registered as id "sbom" with cloud.HealthOwner + order 137: it serves its own /v1/sbom/health, so serve.go skips the generic liveness route. Order 137 binds /v1/sbom/* before the ai subsystem's /v1/* catch-all (150).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Prefetch ¶
Prefetch materializes the SBOM for a deployed image ref if it is not already in the datastore, on a deploy-digest signal from the platform. It is the deploy-time trigger: idempotent (a hit is a no-op), best-effort (a miss/pull-failure logs and returns, never blocks a deploy), and safe to call from a goroutine. Exported so clients/platform can fire it after a deployment goes live WITHOUT this package importing platform (dependency points platform → sbom, one direction).
Types ¶
type SbomComponent ¶
type SbomComponent struct {
// Name is the dependency's package name as CycloneDX records it.
Name string `json:"name"`
// Version is the resolved version of that package.
Version string `json:"version"`
// Type is the CycloneDX component type: library, application, framework, …
Type string `json:"type"`
// Purl is the package URL — the ecosystem-qualified identity a vulnerability
// feed can be joined on.
Purl string `json:"purl"`
// License is the FIRST license fact found for the component: its SPDX id, else
// its name, else the expression. Empty when the document declares none.
License string `json:"license"`
}
SbomComponent is one flattened dependency: name/version/type/purl + a single license string (first id | name | expression found, else "").
type SbomHealth ¶ added in v1.801.350
type SbomHealth struct {
// Datastore reports whether the shared datastore connection this subsystem reads
// and writes through is established. False means the data endpoints answer 503.
Datastore bool `json:"datastore"`
// Service names the subsystem answering: always "sbom".
Service string `json:"service"`
// Status is the liveness verdict: always "ok" here, because the process answering
// at all IS the liveness fact.
Status string `json:"status"`
// Table is the fully-qualified datastore table the components live in.
Table string `json:"table"`
}
SbomHealth is the GET /v1/sbom/health probe result.
Field order is the order encoding/json emits a map's sorted keys in, which is what this response was before it had a type — so the probe's BYTES did not move.
type SbomIngest ¶
type SbomIngest struct {
// ImageDigest is the content-addressed digest (sha256:…) the components are
// keyed under. Required — it, not a tenant, is what an SBOM belongs to.
ImageDigest string `json:"imageDigest"`
// ImageRef is the human-readable image reference the digest was published as.
// A resolve matches on either this or the digest.
ImageRef string `json:"imageRef"`
// SourceRepo is the repository the image was built from.
SourceRepo string `json:"sourceRepo"`
// GitSha is the commit the image was built from.
GitSha string `json:"gitSha"`
// Format names the document format; "cyclonedx" is the only one parsed.
Format string `json:"format"`
// Document is the raw CycloneDX bill of materials, any JSON. Its components[]
// are flattened and persisted; nothing else is read or stored.
Document json.RawMessage `json:"document"`
}
SbomIngest is the POST /v1/sbom body from CI: the image identity + a raw CycloneDX document whose components[] we flatten and persist.
type SbomIngested ¶ added in v1.801.350
type SbomIngested struct {
// ComponentCount is how many components the CycloneDX document yielded and this
// call persisted.
ComponentCount int `json:"componentCount"`
// ImageDigest is the content-addressed digest the components were keyed under.
ImageDigest string `json:"imageDigest"`
}
SbomIngested is the POST /v1/sbom receipt: which image was ingested and how many components were flattened out of its CycloneDX document.
Field order is the order encoding/json emits a map's sorted keys in, which is what this response was before it had a type — so the receipt's BYTES did not move.
type SbomView ¶
type SbomView struct {
// ImageDigest is the content-addressed digest the components are keyed under.
ImageDigest string `json:"imageDigest"`
// ImageRef is the image reference recorded alongside the digest.
ImageRef string `json:"imageRef"`
// SourceRepo is the repository the image was built from.
SourceRepo string `json:"sourceRepo"`
// GitSha is the commit the image was built from.
GitSha string `json:"gitSha"`
// IngestedAt is when the bill of materials was recorded, RFC 3339.
IngestedAt string `json:"ingestedAt"`
// ComponentCount is how many components this response carries — after the cap,
// so it matches components exactly rather than the image's true total.
ComponentCount int `json:"componentCount"`
// Truncated is true when the image has MORE components than the cap returns.
Truncated bool `json:"truncated,omitempty"`
// Components is the flattened dependency set, ordered by type then name.
Components []SbomComponent `json:"components"`
}
SbomView is the GET /v1/sbom/{ref} response the console renders.