sbomcache

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package sbomcache is a filesystem-backed, content-addressed cache of generated SBOMs. It implements the analyzer-version cache-invalidation idea (learned from Trivy): the cache key folds together a cheap digest of the workspace CONTENT and the SBOM producer VERSION, so an unchanged tree re-scanned with the same producer reuses the cataloged SBOM, and a producer bump makes every prior entry a miss.

The workspace digest is metadata-based (path + size + mtime), which is deliberately CHEAPER than reading and hashing every byte – the whole point is to be faster than the Syft cataloging pass it replaces. That matches Trivy's filesystem-cache posture: a content edit that preserves BOTH size and mtime (pathological; editors and git checkouts always bump mtime) is the only stale case, and it is bounded by the fact that a producer version bump always invalidates. The cache is opt-in.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache stores generated SBOMs under a root directory, one JSON file per key.

func New

func New(dir string) *Cache

New returns a cache rooted at dir. The directory is created lazily on the first Store.

func (*Cache) Load

func (c *Cache) Load(ctx context.Context, dir, producerVersion string) (*sbom.SBOM, bool, error)

Load returns the cached SBOM for (dir, producerVersion) when present. Any miss reason (no version, uncomputable digest, absent/corrupt file) returns ok=false with no error, so the caller just regenerates.

func (*Cache) Store

func (c *Cache) Store(ctx context.Context, dir, producerVersion string, doc *sbom.SBOM) error

Store caches doc for (dir, producerVersion). Best-effort: an uncomputable key or a write error is returned but the caller ignores it (the scan already has its SBOM).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL