Documentation
¶
Index ¶
- Constants
- func CompiledCachePath(cacheDir, name string) string
- func FormatIndexDownloadProgress(loaded, total int) string
- func IsMaliciousID(id string) bool
- func NormalizeEcosystem(eco string) string
- func PublishedFeedSnapshotPath(cacheDir string) string
- func SaveCompiledIndex(path string, entryCount int, idx *MaliciousIndex) error
- func VulnPageURL(id string) string
- func WithFirstRunCacheNote(msg string) string
- func WritePublishedFeedSnapshot(cacheDir, compiledPath string, idx *MaliciousIndex) error
- type Affected
- type BatchQueryRequest
- type BatchQueryResponse
- type DatabaseSpecific
- type Event
- type IndexLoadProgress
- type IndexLoadStatus
- type MalMatch
- type MaliciousIndex
- func (idx *MaliciousIndex) AddRecord(rec inventory.Record)
- func (idx *MaliciousIndex) AddVuln(vuln *Vulnerability)
- func (idx *MaliciousIndex) ListSincePublished(since time.Time, ecosystem string) []SearchHit
- func (idx *MaliciousIndex) LookupByID(id string) (SearchHit, bool)
- func (idx *MaliciousIndex) Match(ecosystem, name, version string) []MalMatch
- func (idx *MaliciousIndex) PackageCount() int
- func (idx *MaliciousIndex) QueryLocal(ecosystem, name, version string) []*Vulnerability
- func (idx *MaliciousIndex) Search(query, ecosystem string, limit int) SearchMatchResult
- func (idx *MaliciousIndex) Vuln(id string) (*Vulnerability, bool)
- type MaliciousOrigin
- type Package
- type PackageQuery
- type QueryRequest
- type QueryResponse
- type Range
- type Reference
- type SearchHit
- type SearchMatchResult
- type Vulnerability
Constants ¶
const FirstRunCacheNote = "first run only — cached locally"
FirstRunCacheNote explains that the initial corpus download is stored locally.
Variables ¶
This section is empty.
Functions ¶
func CompiledCachePath ¶
func FormatIndexDownloadProgress ¶
FormatIndexDownloadProgress formats spinner text for malicious-package index sync.
func IsMaliciousID ¶
IsMaliciousID reports whether an advisory ID denotes a malicious-package record (OpenSSF MAL-* or PD GitHub-scan GHSCAN-MAL-*).
func NormalizeEcosystem ¶
NormalizeEcosystem maps CLI/config aliases to canonical OSV ecosystem names.
func SaveCompiledIndex ¶
func SaveCompiledIndex(path string, entryCount int, idx *MaliciousIndex) error
func VulnPageURL ¶
VulnPageURL returns the public OSV advisory page for an ID.
func WithFirstRunCacheNote ¶
WithFirstRunCacheNote appends the first-run cache hint to a spinner message.
func WritePublishedFeedSnapshot ¶
func WritePublishedFeedSnapshot(cacheDir, compiledPath string, idx *MaliciousIndex) error
WritePublishedFeedSnapshot stores a compact feed cache derived from the compiled index so feed/dashboard commands avoid parsing the full compiled.json on every run.
Types ¶
type BatchQueryRequest ¶
type BatchQueryRequest struct {
Queries []QueryRequest `json:"queries"`
}
type BatchQueryResponse ¶
type BatchQueryResponse struct {
Results []QueryResponse `json:"results"`
}
type DatabaseSpecific ¶
type DatabaseSpecific struct {
MaliciousPackagesOrigins []MaliciousOrigin `json:"malicious-packages-origins"`
}
type IndexLoadProgress ¶
type IndexLoadProgress func(loaded, total int)
type IndexLoadStatus ¶
type IndexLoadStatus func(msg string)
type MaliciousIndex ¶
type MaliciousIndex struct {
// contains filtered or unexported fields
}
MaliciousIndex is an in-memory index of malicious-package advisories for local matching, lookup, and feed/search rendering.
func LoadCompiledIndex ¶
func LoadCompiledIndex(path string, entryCount int) (*MaliciousIndex, bool)
func LoadCompiledIndexIfFresh ¶
func LoadCompiledIndexIfFresh(path string) (*MaliciousIndex, bool)
func LoadCompiledIndexStale ¶
func LoadCompiledIndexStale(path string) (*MaliciousIndex, bool)
LoadCompiledIndexStale returns the on-disk compiled index even when its TTL has expired. Feed rendering prefers this over scanning the modified index.
func NewEmptyMaliciousIndex ¶
func NewEmptyMaliciousIndex() *MaliciousIndex
NewEmptyMaliciousIndex returns an empty malicious package index.
func (*MaliciousIndex) AddRecord ¶
func (idx *MaliciousIndex) AddRecord(rec inventory.Record)
AddRecord indexes a malicious package from an inventory export record. The record's primary ID anchors the entry; remaining IDs are stored as aliases and indexed for lookup. Version coverage comes from affected_versions / all_versions. A record that sets neither (all_versions=false with an empty affected_versions list) carries no usable version coverage and is indexed without matching any pinned version, so name/ID lookups still surface it but version-pinned checks do not raise false positives.
func (*MaliciousIndex) AddVuln ¶
func (idx *MaliciousIndex) AddVuln(vuln *Vulnerability)
AddVuln indexes a vulnerability record into the malicious package index.
func (*MaliciousIndex) ListSincePublished ¶
func (idx *MaliciousIndex) ListSincePublished(since time.Time, ecosystem string) []SearchHit
ListSincePublished returns advisories with published >= since, newest published first.
func (*MaliciousIndex) LookupByID ¶
func (idx *MaliciousIndex) LookupByID(id string) (SearchHit, bool)
LookupByID returns package metadata for a malicious advisory ID (primary or alias) in the compiled index.
func (*MaliciousIndex) Match ¶
func (idx *MaliciousIndex) Match(ecosystem, name, version string) []MalMatch
Match returns matching MAL advisories for a package, or nil if clean.
func (*MaliciousIndex) PackageCount ¶
func (idx *MaliciousIndex) PackageCount() int
func (*MaliciousIndex) QueryLocal ¶
func (idx *MaliciousIndex) QueryLocal(ecosystem, name, version string) []*Vulnerability
QueryLocal returns synthesized Vulnerability records matching a package (and optional version) from the local index.
func (*MaliciousIndex) Search ¶
func (idx *MaliciousIndex) Search(query, ecosystem string, limit int) SearchMatchResult
Search returns packages whose names contain query (case-insensitive). Hits are sorted by modified/published (newest first) and capped at limit. Total is the number of matches before the cap.
func (*MaliciousIndex) Vuln ¶
func (idx *MaliciousIndex) Vuln(id string) (*Vulnerability, bool)
Vuln synthesizes a Vulnerability record for an advisory ID from the local index. It returns false when the ID is not malicious or not indexed.
type MaliciousOrigin ¶
type PackageQuery ¶
type QueryRequest ¶
type QueryRequest struct {
Package *PackageQuery `json:"package,omitempty"`
Version string `json:"version,omitempty"`
}
type QueryResponse ¶
type QueryResponse struct {
Vulns []Vulnerability `json:"vulns"`
}
type SearchHit ¶
type SearchHit struct {
Ecosystem string
Name string
IDs []string
Aliases []string
Summary string
Severity string
Source string
Published time.Time
Modified time.Time
Imported time.Time
}
SearchHit is a package name match in the malicious package index.
func FilterFeedHits ¶
func LoadPublishedFeedSnapshot ¶
LoadPublishedFeedSnapshot returns recent published hits when the snapshot matches the on-disk compiled index.
type SearchMatchResult ¶
SearchMatchResult holds capped search hits and the full match count.
type Vulnerability ¶
type Vulnerability struct {
ID string `json:"id"`
Summary string `json:"summary"`
Details string `json:"details"`
Modified string `json:"modified"`
Published string `json:"published"`
Withdrawn string `json:"withdrawn"`
Aliases []string `json:"aliases"`
Affected []Affected `json:"affected"`
References []Reference `json:"references"`
DatabaseSpecific DatabaseSpecific `json:"database_specific"`
}
Vulnerability is the advisory record shape consumed across depx. It is no longer fetched from a remote OSV API: records are synthesized locally from the inventory index (see MaliciousIndex.Vuln), so only the fields depx renders are populated.
func MaliciousVulns ¶
func MaliciousVulns(vulns []Vulnerability) []Vulnerability
MaliciousVulns filters a slice down to malicious-package advisories.
func (*Vulnerability) ImportedTime ¶
func (v *Vulnerability) ImportedTime() time.Time
func (*Vulnerability) ModifiedTime ¶
func (v *Vulnerability) ModifiedTime() time.Time
func (*Vulnerability) PackageEcosystem ¶
func (v *Vulnerability) PackageEcosystem() string
func (*Vulnerability) PackageName ¶
func (v *Vulnerability) PackageName() string
func (*Vulnerability) PublishedTime ¶
func (v *Vulnerability) PublishedTime() time.Time