Documentation
¶
Overview ¶
Package cache stores scan results keyed by content hash so unchanged targets are not re-scanned. Keys come from plugin.ComputeCacheKey (a hex SHA, safe as a filename).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
// Get returns the cached report for key, or ok=false on miss/expiry.
Get(key string) (sarif.Report, bool)
// Put stores report under key.
Put(key string, report sarif.Report) error
}
Cache stores and retrieves scan reports by key.
func ReadOnly ¶ added in v0.61.0
ReadOnly returns a view of c that serves entries and stores none.
For a run whose results should not be trusted by the next one, a pull request from a fork being the case that matters, where the code deciding what the scan sees is not the code the cache is meant to describe. Reading stays useful: the entries already there were written by runs that were trusted.
A wrapper rather than a flag on Local so the guarantee is structural. A boolean checked inside Put is a boolean somebody can forget to check.
type Describer ¶ added in v0.125.0
type Describer interface {
Describe() Description
}
Describer is a cache that can say where it is and how long it keeps things.
Optional, and asked for with a type assertion, so a cache that cannot answer stays a valid Cache and a caller that does not care is unaffected.
type Description ¶ added in v0.125.0
Description is what a cache can say about itself, for a report that has to explain a reused finding to somebody reading it later.
The directory as it was given, not resolved and not probed. In CI it is usually an archive the platform restored under a key the pipeline chose, and whether that key still describes this tree is the pipeline's fact rather than the scan's. Naming the path is enough to tell a CI cache from a laptop's.
type Local ¶
type Local struct {
// contains filtered or unexported fields
}
Local is a filesystem-backed cache with optional TTL expiry. Safe for concurrent use.
func (*Local) Describe ¶ added in v0.125.0
func (l *Local) Describe() Description
Describe reports where this cache is and how long it keeps entries.
func (*Local) Get ¶
Get returns the cached report for key, missing on absence, unreadable data, or expiry.
func (*Local) GetStamped ¶ added in v0.125.0
GetStamped returns the cached report for key and when it was written.
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory is a process-lifetime in-memory cache (no TTL). Safe for concurrent use.
type StampedGetter ¶ added in v0.125.0
type StampedGetter interface {
GetStamped(key string) (report sarif.Report, storedAt time.Time, ok bool)
}
StampedGetter is a cache that reports when an entry was written, as well as what it holds.
Age is the difference between reusing an hour-old answer and a day-old one, and the entry knows it. Get throws it away, and widening Get would break every implementation for the one caller that wants it.