Documentation
¶
Index ¶
- Constants
- Variables
- func BulkHashlookup(ctx context.Context, sha1s []string) (map[string]*HashlookupResult, error)
- func CheckMalwareBazaarInMemory(corpus map[string]bool, sha256 string) bool
- func CheckMalwareBazaarLocal(corpusPath, sha256 string) (bool, error)
- func ComparableVersion(ecosystem, v string) string
- func ComputeEnrichedSeverities(ev *EnrichedVuln)
- func DownloadMalwareBazaarRecent(ctx context.Context, destPath string) error
- func EvaluateAffectedEntry(am map[string]interface{}, installedVer, ecosystem string) (string, versions.Status, string)
- func ExploitMeetsThreshold(ev EnrichedVuln, threshold string) bool
- func HasAnyKev(ev EnrichedVuln) bool
- func IsCIPipelineFile(info *ManifestInfo) bool
- func IsPythonGatedManifest(manifestType string) bool
- func IsResolvedVersion(v string) bool
- func IsVersionAffected(installedVersion, versionRange, ecosystem string) bool
- func IsVersionSpecPinned(spec string) bool
- func LoadMalwareBazaarCorpusFromFile(path string) (map[string]bool, error)
- func NormaliseReleaseForEOL(product, version string) string
- func NpmLockfilePresent(packageJSONPath string) bool
- func NpmWorkspaceMemberManifests(rootDir string) []string
- func ParseRemediationScores(data map[string]interface{}, ev *EnrichedVuln)
- func PopulateInstalledEdges(groups []ManifestGroup, rootPath string)
- func PyLockfilePresent(dir string) bool
- func RequirementsFullyLocked(pkgs []ScopedPackage) bool
- func SSVCToSeverity(decision string) string
- func ScopeIcon(scope string) string
- func ScoreToSeverity(scoreType string, score float64) string
- func SeverityLevel(severity string) int
- func SeverityMeetsThreshold(severity, threshold string) bool
- func StripGemPlatform(v string) string
- func SynthesiseFromCDX(cdxDoc map[string]any, packages []ScopedPackage, purls []string) (findings []VulnFinding, enriched []EnrichedVuln, stats *LookupStats)
- func ValidateAnalyzeRequest(body []byte) error
- func VerifyLocationGone(rootPath string, loc memory.Location, lineSlack int) (bool, string)
- type AffectedAnswer
- type AffectedBatchFetcher
- type AffectedFetcher
- type AffectedQuery
- type AffectedSymbols
- type BinaryAnalysis
- type BinaryHashes
- type BinaryResult
- type BinaryScanOptions
- type DepGraph
- func (g *DepGraph) DirectCount() int
- func (g *DepGraph) FindPath(targetPkg string) []string
- func (g *DepGraph) FindPathMemo(target string) []string
- func (g *DepGraph) IsDirect(pkgName string) bool
- func (g *DepGraph) PopulateBunLockEdges(lockFilePath string) error
- func (g *DepGraph) PopulateCargoLockEdges(dir string)
- func (g *DepGraph) PopulateComposerLockEdges(dir string)
- func (g *DepGraph) PopulateGemfileLockEdges(dir string)
- func (g *DepGraph) PopulateGoModGraph(dir string) error
- func (g *DepGraph) PopulateMixLockEdges(dir string)
- func (g *DepGraph) PopulateNpmLockEdges(lockFilePath string) error
- func (g *DepGraph) PopulateNugetLockEdges(dir string)
- func (g *DepGraph) PopulatePypiLockEdges(dir string)
- func (g *DepGraph) TransitiveCount() int
- type DetectedFile
- type EOLHorizon
- type EOLSeverityBuckets
- type EnrichOptions
- type EnrichedVuln
- type ExploitSummary
- type FileType
- type HashlookupParent
- type HashlookupResult
- type IDSRule
- type LookupStats
- type MalwareBazaarResult
- type ManifestGroup
- type ManifestInfo
- type NpmWorkspace
- type PackageChecksum
- type RegistryEndpoint
- type RemediationInfo
- type ResolveStats
- type ResolvedBinary
- type RuntimePin
- type ScanResult
- type ScopedPackage
- func ApplyBuildOrLockGate(eco, manifestType, manifestPath, relPath string, confident bool, ...) (resolved []ScopedPackage, dropFile bool, err error)
- func ParseManifestWithScope(filePath, manifestType string) ([]ScopedPackage, error)
- func ResolveCargoFromInstalled(manifestPath, relPath string, declared []ScopedPackage, strict bool) ([]ScopedPackage, error)
- func ResolveComposerFromInstalled(manifestPath, relPath string, declared []ScopedPackage, strict bool) ([]ScopedPackage, error)
- func ResolveGemsFromInstalled(manifestPath, relPath string, declared []ScopedPackage, strict bool) ([]ScopedPackage, error)
- func ResolveHexFromInstalled(manifestPath, relPath string, declared []ScopedPackage, strict bool) ([]ScopedPackage, error)
- func ResolveJavaFromInstalled(manifestPath, relPath string, declared []ScopedPackage, strict bool) ([]ScopedPackage, error)
- func ResolveNpmPackageJSONFromNodeModules(packageJSONPath, relPath string, direct []ScopedPackage) ([]ScopedPackage, error)
- func ResolveNugetFromInstalled(manifestPath, relPath string, declared []ScopedPackage, strict bool) ([]ScopedPackage, error)
- func ResolvePubFromInstalled(manifestPath, relPath string, declared []ScopedPackage, strict bool) ([]ScopedPackage, error)
- func ResolvePythonRequirementsFromSitePackages(manifestPath, relPath string, declared []ScopedPackage, strict bool) ([]ScopedPackage, error)
- type SemanticMatch
- type Verdict
- type VerdictResult
- type VulnFinding
- type WalkOptions
Constants ¶
const ( // ConfidenceConfident: a clear requirements file — matched by name pattern or // by content carrying requirement syntax (version specs, --hash=, pip // directives). The build-or-lock gate treats these as definitive: an // unresolvable confident file is a fatal error. ConfidenceConfident = "confident" // ConfidenceTentative: an ambiguous file that is only bare package names. It is // confirmed a requirements file only by cross-checking its names against // installed packages; if it can't be confirmed it is silently disregarded. ConfidenceTentative = "tentative" )
Detection confidence for content/name-detected pip requirements files.
const ( ScopeProduction = parse.ScopeProduction ScopeDevelopment = parse.ScopeDevelopment ScopeTest = parse.ScopeTest ScopePeer = parse.ScopePeer ScopeOptional = parse.ScopeOptional ScopeProvided = parse.ScopeProvided ScopeRuntime = parse.ScopeRuntime ScopeSystem = parse.ScopeSystem )
const ( SourceTypeManifest = parse.SourceTypeManifest SourceTypeInstalled = parse.SourceTypeInstalled SourceTypeCommand = parse.SourceTypeCommand SourceTypeBinary = parse.SourceTypeBinary SourceTypeContainer = parse.SourceTypeContainer )
const MBRecentURL = "https://mb-api.abuse.ch/v2/files/exports/3a16bf5b8b1bfb83f8cd9286b7e2b4f18257cd23f3d475bf/sha256_recent.txt"
MBRecentURL is the MalwareBazaar recent SHA-256 corpus (last 30 days).
const SeveritySkip = "skip"
SeveritySkip is the bucket value that means "do not report this horizon".
Variables ¶
var ManifestExtensions = map[string]ManifestInfo{ ".csproj": {Type: "*.csproj", Ecosystem: "nuget", Language: "c#", IsLock: false}, ".fsproj": {Type: "*.csproj", Ecosystem: "nuget", Language: "f#", IsLock: false}, ".vbproj": {Type: "*.csproj", Ecosystem: "nuget", Language: "vb", IsLock: false}, ".tf": {Type: "*.tf", Ecosystem: "terraform", Language: "hcl", IsLock: false}, ".opam": {Type: "*.opam", Ecosystem: "opam", Language: "ocaml", IsLock: false}, ".cabal": {Type: "*.cabal", Ecosystem: "cabal", Language: "haskell", IsLock: false}, ".dockerfile": {Type: "Dockerfile", Ecosystem: "docker", Language: "docker", IsLock: false}, ".containerfile": {Type: "Dockerfile", Ecosystem: "docker", Language: "docker", IsLock: false}, ".sh": {Type: "shell-script", Ecosystem: "shell", Language: "shell", IsLock: false}, ".bash": {Type: "shell-script", Ecosystem: "shell", Language: "shell", IsLock: false}, ".zsh": {Type: "shell-script", Ecosystem: "shell", Language: "shell", IsLock: false}, ".ksh": {Type: "shell-script", Ecosystem: "shell", Language: "shell", IsLock: false}, ".bats": {Type: "shell-script", Ecosystem: "shell", Language: "shell", IsLock: false}, ".ash": {Type: "shell-script", Ecosystem: "shell", Language: "shell", IsLock: false}, ".dash": {Type: "shell-script", Ecosystem: "shell", Language: "shell", IsLock: false}, ".fish": {Type: "shell-script", Ecosystem: "shell", Language: "shell", IsLock: false}, ".command": {Type: "shell-script", Ecosystem: "shell", Language: "shell", IsLock: false}, ".mk": {Type: "shell-script", Ecosystem: "shell", Language: "shell", IsLock: false}, ".ps1": {Type: "shell-script", Ecosystem: "shell", Language: "shell", IsLock: false}, ".psm1": {Type: "shell-script", Ecosystem: "shell", Language: "shell", IsLock: false}, ".cmd": {Type: "shell-script", Ecosystem: "shell", Language: "shell", IsLock: false}, ".bat": {Type: "shell-script", Ecosystem: "shell", Language: "shell", IsLock: false}, }
ManifestExtensions maps file extensions to manifest metadata. Used for files whose names include a project-specific prefix (e.g. foo.csproj, main.tf).
var ManifestFiles = map[string]ManifestInfo{}/* 165 elements not displayed */
ManifestFiles maps known manifest filenames (exact basename) to their metadata.
var SupportedManifestTypes = map[string]bool{ "package.json": true, "package-lock.json": true, "yarn.lock": true, "pnpm-lock.yaml": true, "bun.lock": true, "pyproject.toml": true, "requirements.txt": true, "requirements.in": true, "setup.py": true, "setup.cfg": true, "Pipfile": true, "Pipfile.lock": true, "poetry.lock": true, "uv.lock": true, "pylock.toml": true, "environment.yml": true, "go.sum": true, "go.mod": true, "Gemfile": true, "Gemfile.lock": true, "Cargo.toml": true, "Cargo.lock": true, "pom.xml": true, "build.gradle": true, "gradle.lockfile": true, "build.gradle.kts": true, "composer.json": true, "composer.lock": true, "packages.lock.json": true, "packages.config": true, "paket.dependencies": true, "paket.lock": true, "Directory.Packages.props": true, "*.csproj": true, "project.clj": true, "deps.edn": true, "Package.swift": true, "Package.resolved": true, "pubspec.yaml": true, "pubspec.lock": true, "mix.exs": true, "mix.lock": true, "build.sbt": true, "build.lock": true, "build.sc": true, "Dockerfile": true, "compose.yaml": true, "kubernetes.yaml": true, "Chart.yaml": true, "*.tf": true, "github-actions.yml": true, "ci-pipeline": true, "Jenkinsfile": true, "shell-script": true, "conanfile.txt": true, "conanfile.py": true, "conan.lock": true, "vcpkg.json": true, "Podfile": true, "Podfile.lock": true, "Cartfile": true, "Cartfile.resolved": true, "Project.toml": true, "Manifest.toml": true, "shard.yml": true, "shard.lock": true, "deno.json": true, "deno.lock": true, "DESCRIPTION": true, "renv.lock": true, "rebar.config": true, "rebar.lock": true, "stack.yaml": true, "package.yaml": true, "*.cabal": true, "cabal.project.freeze": true, "*.opam": true, "opam": true, "flake.nix": true, "flake.lock": true, "build.zig.zon": true, "meson.build": true, "WORKSPACE": true, "MODULE.bazel": true, "BUCK": true, "BUCK2": true, "CPM.cmake": true, "CMakeLists.txt": true, }
SupportedManifestTypes lists manifest types that have a local parser implemented. Files detected but absent from this map are shown as "[not supported]" in scan output.
var ValidExploitThresholds = []string{"poc", "active", "weaponized"}
ValidExploitThresholds lists the accepted values for the --exploits flag, in ascending order of exploit maturity (least → most dangerous).
var ValidSeverityThresholds = []string{"low", "medium", "high", "critical"}
ValidSeverityThresholds lists the accepted --severity flag values in ascending order.
Functions ¶
func BulkHashlookup ¶ added in v3.28.0
BulkHashlookup sends a batch of SHA-1 hashes to the CIRCL hashlookup API and returns results keyed by SHA-1 hex string. Errors are non-fatal — partial results are returned alongside any error.
func CheckMalwareBazaarInMemory ¶ added in v3.28.0
CheckMalwareBazaarInMemory checks whether a SHA-256 hash appears in an in-memory set of known-malicious hashes.
func CheckMalwareBazaarLocal ¶ added in v3.28.0
CheckMalwareBazaarLocal checks whether a SHA-256 hash appears in a local MalwareBazaar corpus file (one hex hash per line).
func ComparableVersion ¶ added in v3.115.0
ComparableVersion is the version to compare against advisory ranges: the installed version with anything the ecosystem appends that is not part of the release removed. Today that is a RubyGem's platform suffix; left in, it reads as a pre-release and "1.19.1-x86_64-linux-gnu" falls outside "= 1.19.1", which hid real nokogiri advisories.
func ComputeEnrichedSeverities ¶
func ComputeEnrichedSeverities(ev *EnrichedVuln)
ComputeEnrichedSeverities fills the per-source severity fields and MaxSeverity on ev after all score data has been populated.
func DownloadMalwareBazaarRecent ¶ added in v3.28.0
DownloadMalwareBazaarRecent fetches the MalwareBazaar recent corpus and saves it to destPath. Best-effort — errors are returned but should be treated as non-fatal by callers.
func EvaluateAffectedEntry ¶ added in v3.25.1
func EvaluateAffectedEntry(am map[string]interface{}, installedVer, ecosystem string) (string, versions.Status, string)
EvaluateAffectedEntry determines the version status of installedVer against one affected entry from a V2Affected response. Evaluation order:
- Structured `versions` array (+ defaultStatus) — CVE 5.1 precedence via versions.EvaluateStatus, so an exact "unaffected" match beats an affected range.
- String fields: "unaffectedVersions" (checked first), then "versionRange" / legacy string "versions".
- Neither present — StatusUnknown (caller decides the posture).
Returns the range expression used for the verdict, the status, and a match-method label for MatchMethod reporting.
func ExploitMeetsThreshold ¶
func ExploitMeetsThreshold(ev EnrichedVuln, threshold string) bool
ExploitMeetsThreshold reports whether ev's exploit signals reach the given tier.
Tiers form a strict hierarchy — each tier also captures all higher-maturity signals:
poc : any public exploit exists (ExploitCount > 0, or any KEV entry) active : known active exploitation (InCisaKev || InVulnCheckKev || InEuKev || HasWeaponized) weaponized: weaponised in-the-wild (ExploitIntel.HasWeaponized)
func HasAnyKev ¶
func HasAnyKev(ev EnrichedVuln) bool
HasAnyKev returns true if the vulnerability is listed in any KEV catalog (CISA, VulnCheck, or EU ENISA).
func IsCIPipelineFile ¶ added in v3.79.0
func IsCIPipelineFile(info *ManifestInfo) bool
IsCIPipelineFile reports whether a detected manifest is pipeline-as-code. GitHub Actions workflows are counted: they are CI files whose `run:` steps install packages, so `--no-ci` style flags must reach them too, even though their `uses:` pins are also resolved as github-actions packages.
func IsPythonGatedManifest ¶ added in v3.40.0
PyGatedManifestTypes are the Python manifest types the build-or-lock gate applies to: unpinned manifests that need a lock or an installed env to scan at exact versions. Lock files are never gated.
func IsResolvedVersion ¶ added in v3.115.0
IsResolvedVersion reports whether v names a concrete release that can be looked up. A specifier does not: "latest", "catalog:", "workspace:*", "link:../x", "${remoting.version}" and the empty string all describe a dependency nobody resolved, and querying one is worse than skipping it. A versionless query asks the database for every advisory the package has ever had, so an unresolved dependency used to be reported as carrying all of them.
func IsVersionAffected ¶
IsVersionAffected checks whether installedVersion falls within the affected version range string returned by the VDB API.
Supported range formats (full grammar in internal/versions):
">= 2.0.0, < 2.3.1" comma-separated AND constraints "1.14.1, 0.30.4" bare comma list — OR exact matches "[2.0.0, 2.3.1)" interval notation "< 3.0.0" single constraint ">= 1.0.0 < 2.0.0" space-separated AND constraints "< 2.11.2 || = 3.0.1" "||"-separated OR ranges "≥ 0.31.0 < 1.2.0" unicode operators "2.3.1" exact version match "*" all versions
Returns true if the installed version IS affected. When parsing fails the function returns true (assume affected) to err on the side of caution.
func IsVersionSpecPinned ¶
IsVersionSpecPinned reports whether spec represents an exact version pin. An empty spec (e.g. lock-file entries) is treated as pinned. Specs that begin with range operators (^, ~, >=, >, <=, <, !=) or are symbolic (*, latest, x) are considered unpinned.
func LoadMalwareBazaarCorpusFromFile ¶ added in v3.28.0
LoadMalwareBazaarCorpusFromFile reads a corpus file (one hex hash per line) into an in-memory set for fast lookups. Lines beginning with # are treated as comments and skipped.
func NormaliseReleaseForEOL ¶
NormaliseReleaseForEOL reduces a full version string to the form expected by the VDB EOL API for the given product.
go : major.minor ("1.21.3" → "1.21", "1.21" → "1.21")
nodejs : major only ("18.20.4" → "18", "18" → "18")
python : major.minor ("3.10.4" → "3.10", "3.10" → "3.10")
ruby : major.minor ("3.2.1" → "3.2", "3.2" → "3.2")
Returns "" if the version string cannot be parsed.
func NpmLockfilePresent ¶ added in v3.34.0
NpmLockfilePresent reports whether a package.json has a sibling npm-family lockfile. The no-lock installed resolver only runs when this returns false.
func NpmWorkspaceMemberManifests ¶ added in v3.152.0
NpmWorkspaceMemberManifests lists the package.json of every workspace member a root declares, in path order. node_modules and dot-directories are not searched. nil when rootDir is not a workspace root.
func ParseRemediationScores ¶
func ParseRemediationScores(data map[string]interface{}, ev *EnrichedVuln)
ParseRemediationScores extracts scores from the remediation plan response into the EnrichedVuln. These are displayed but not used for primary sorting.
func PopulateInstalledEdges ¶
func PopulateInstalledEdges(groups []ManifestGroup, rootPath string)
PopulateInstalledEdges attempts to build dependency graph edges for each manifest group by reading locally installed package manifests. This enriches both SBOM dependency trees and --paths output. Errors are silently skipped.
func PyLockfilePresent ¶ added in v3.40.0
PyLockfilePresent reports whether dir contains any Python lock file. When one exists the lock is scanned with exact versions, so an unpinned sibling manifest does not need resolving from the installed environment.
func RequirementsFullyLocked ¶ added in v3.40.0
func RequirementsFullyLocked(pkgs []ScopedPackage) bool
RequirementsFullyLocked reports whether every package is pinned enough to scan without consulting the installed environment: an exact version pin OR integrity hashes (pip freeze / pip-compile / pylock output). A bare name (no version, no hash) is not locked — its empty VersionSpec must not be mistaken for a pin.
func SSVCToSeverity ¶
SSVCToSeverity maps an SSVC decision string to an approximate severity label. SSVC decisions are: Act, Attend, Track*, Track, Defer.
func ScoreToSeverity ¶
ScoreToSeverity converts a numeric score of a given type to a severity label. Supported types: epss, coalition_ess (cess), cvss* variants. Returns "unscored" when the type is unrecognised or the score is zero.
func SeverityLevel ¶
SeverityLevel returns a numeric level for severity (higher = more severe). Used for threshold comparisons.
unscored → 0 low → 1 medium → 2 high → 3 critical → 4
func SeverityMeetsThreshold ¶
SeverityMeetsThreshold reports whether the given severity meets or exceeds the threshold severity. "unscored" never triggers the threshold. Examples:
SeverityMeetsThreshold("critical", "high") → true
SeverityMeetsThreshold("medium", "high") → false
SeverityMeetsThreshold("high", "high") → true
SeverityMeetsThreshold("unscored", "low") → false
func StripGemPlatform ¶ added in v3.115.0
StripGemPlatform removes the platform suffix of a precompiled RubyGem ("1.19.1-x86_64-linux-gnu" is nokogiri 1.19.1 built for a platform). Advisories are written against 1.19.1, so keeping the suffix matched nothing.
func SynthesiseFromCDX ¶ added in v3.6.0
func SynthesiseFromCDX(cdxDoc map[string]any, packages []ScopedPackage, purls []string) (findings []VulnFinding, enriched []EnrichedVuln, stats *LookupStats)
SynthesiseFromCDX converts an upstream CycloneDX 1.6 document into the internal finding shapes. Returns nil slices when the document is empty or malformed — callers should treat a nil result as "fall back to legacy".
packages and purls are parallel arrays — `purls[i]` is the PURL the caller computed (via cdx.BuildLocalPurl) for `packages[i]`. Empty purl entries are silently ignored. Keeping the purl derivation outside this package avoids a scan→cdx import cycle.
func ValidateAnalyzeRequest ¶ added in v3.28.0
ValidateAnalyzeRequest validates a marshalled /v2/cli.analyze request body against the embedded JSON schema. A nil error means the body is well-formed; a non-nil error describes the first schema violations. A schema-compile failure (packaging bug) is returned as an error too, so callers can decide whether to proceed.
func VerifyLocationGone ¶ added in v3.2.0
VerifyLocationGone returns true when the finding evidence at loc is no longer present on disk. "Gone" means: the file is missing, OR the original snippet is not found within a ±lineSlack window around loc.StartLine.
rootPath is prepended when loc.File is relative. When loc.Snippet is empty (older records without snippet capture) the verifier returns gone=false so the caller leaves the record untouched — we never auto-resolve on a guess.
Types ¶
type AffectedAnswer ¶ added in v3.120.11
AffectedAnswer is one AffectedQuery's answer, as AffectedFetcher would give it.
type AffectedBatchFetcher ¶ added in v3.120.11
type AffectedBatchFetcher func(ctx context.Context, queries []AffectedQuery) []AffectedAnswer
AffectedBatchFetcher answers many AffectedQuery at once, in order. An item it could not answer (any error but not-found) is asked again on its own.
type AffectedFetcher ¶ added in v3.115.0
type AffectedFetcher func(ctx context.Context, id, pkgName, ecosystem string) (map[string]any, error)
AffectedFetcher returns the structured affected-version data for one advisory (the body of GET /v2/vuln/{id}/affected), narrowed to one package so a record that names hundreds of products still returns the one that matters.
type AffectedQuery ¶ added in v3.120.11
type AffectedQuery struct {
ID, PkgName, Ecosystem string
}
AffectedQuery is one AffectedFetcher call: an advisory and a package.
type AffectedSymbols ¶ added in v3.6.0
AffectedSymbols carries the lower-efficacy symbol-level fallback shipped on every cli.sca response (all tiers). The CLI greps local source for these literal names to emit a "grep-match" reachability signal when the higher-efficacy tree-sitter path has no queries for the CVE.
func (*AffectedSymbols) HasAny ¶ added in v3.6.0
func (a *AffectedSymbols) HasAny() bool
HasAny returns true if any list is populated.
type BinaryAnalysis ¶ added in v3.28.0
type BinaryAnalysis struct {
Path string `json:"path"`
Size int64 `json:"size"`
ModTime int64 `json:"modTime,omitempty"`
ELFType string `json:"elfType,omitempty"`
ELFArch string `json:"elfArch,omitempty"`
ELFOSABI string `json:"elfOSABI,omitempty"`
Hashes BinaryHashes `json:"hashes"`
Weaknesses []string `json:"weaknesses,omitempty"`
Capabilities []string `json:"capabilities,omitempty"`
Strings []string `json:"strings,omitempty"`
Exif map[string]any `json:"exif,omitempty"`
Error string `json:"error,omitempty"`
}
BinaryAnalysis is the complete local analysis of one ELF binary.
type BinaryHashes ¶ added in v3.28.0
type BinaryHashes struct {
SHA256 string `json:"sha256"`
MD5 string `json:"md5"`
SHA1 string `json:"sha1"`
SSDEEP string `json:"ssdeep,omitempty"`
TLSH string `json:"tlsh,omitempty"`
SHA256Raw string `json:"sha256Raw,omitempty"`
MD5Raw string `json:"md5Raw,omitempty"`
SHA1Raw string `json:"sha1Raw,omitempty"`
}
BinaryHashes carries every hash computed for one ELF binary.
type BinaryResult ¶ added in v3.28.0
type BinaryResult struct {
Path string `json:"path"`
Size int64 `json:"size"`
ELFType string `json:"elfType,omitempty"`
ELFArch string `json:"elfArch,omitempty"`
ELFOSABI string `json:"elfOSABI,omitempty"`
Hashes BinaryHashes `json:"hashes"`
Weaknesses []string `json:"weaknesses,omitempty"`
Capabilities []string `json:"capabilities,omitempty"`
Strings []string `json:"strings,omitempty"`
Exif map[string]any `json:"exif,omitempty"`
Hashlookup *HashlookupResult `json:"hashlookup,omitempty"`
MalwareBazaar *MalwareBazaarResult `json:"malwareBazaar,omitempty"`
}
BinaryResult is the wire shape sent to /v2/cli.analyze — BinaryAnalysis plus external lookup results.
type BinaryScanOptions ¶ added in v3.79.0
type BinaryScanOptions struct {
// Concurrency caps how many binaries are analysed at once. Zero picks
// min(NumCPU, defaultBinaryScanWorkerCap).
Concurrency int
// ByteBudget caps the total size of the binaries held in memory at once.
// analyzeBinary reads each file whole (hashing needs every byte), so an
// unbounded pool over a directory of large release binaries would multiply
// peak RSS by the worker count. Zero picks defaultBinaryScanByteBudget. A
// file larger than the whole budget is still analysed, alone.
ByteBudget int64
}
BinaryScanOptions tunes the analysis fan-out. The zero value is the default policy, so callers that do not care can use ScanContainerFilesystem.
type DepGraph ¶
type DepGraph struct {
DirectDeps map[string]ScopedPackage // name → direct dependency
AllDeps map[string]ScopedPackage // name → any dependency (direct or transitive)
Edges map[string][]string // parent module name → child module names (from go mod graph, etc.)
EdgeRanges map[string]map[string]string // parent → child → declared range, when the lock/manifest exposes it
// contains filtered or unexported fields
}
DepGraph tracks direct vs transitive dependency relationships for a manifest group. A manifest group is a set of related files in the same directory (e.g., go.mod + go.sum).
func BuildGenericDepGraph ¶
func BuildGenericDepGraph(directPkgs, lockPkgs []ScopedPackage) *DepGraph
BuildGenericDepGraph is a generic build graph correlator for ecosystems that have a simple direct manifest + lock file relationship (e.g., Cargo.toml/Cargo.lock).
func BuildGoDepGraph ¶
func BuildGoDepGraph(goModPkgs, goSumPkgs []ScopedPackage) *DepGraph
BuildGoDepGraph correlates go.mod (direct) and go.sum (all) packages from the same directory to determine which dependencies are direct vs transitive.
func BuildNpmDepGraph ¶
func BuildNpmDepGraph(pkgJsonPkgs, lockPkgs []ScopedPackage) *DepGraph
BuildNpmDepGraph correlates package.json (direct) and package-lock.json (all) packages from the same directory.
func BuildPypiDepGraph ¶
func BuildPypiDepGraph(directPkgs, lockPkgs []ScopedPackage) *DepGraph
BuildPypiDepGraph correlates pyproject.toml (direct) and lock files (uv.lock, poetry.lock, Pipfile.lock) to classify direct vs transitive dependencies. Package name comparison is case-folded and normalises dashes/underscores to handle the common PyPI naming quirks.
func (*DepGraph) DirectCount ¶
DirectCount returns the number of direct dependencies.
func (*DepGraph) FindPath ¶
FindPath returns the shortest dependency chain from any direct dep to targetPkg. Returns nil if no path exists or edge data is unavailable. The returned slice is the chain: [direct-dep, intermediate, ..., targetPkg].
func (*DepGraph) FindPathMemo ¶ added in v3.32.1
FindPathMemo is a memoised FindPath. The shortest chain to a given package is identical no matter which vulnerability references it, yet the display path was previously recomputed per finding (and again by the pretty-printer), making the introduced-paths render O(vulns × manifests × BFS). Callers share one *DepGraph, so caching on the graph collapses that to one BFS per distinct package.
Not safe for concurrent use; FindPath is only ever called from the sequential enrichment and rendering loops, consistent with the rest of DepGraph.
func (*DepGraph) IsDirect ¶
IsDirect returns true if the package was declared directly in the manifest. For PyPI packages, name lookup is also attempted with dash/underscore/case normalisation so that e.g. "PyYAML" matches a key stored as "pyyaml".
func (*DepGraph) PopulateBunLockEdges ¶ added in v3.152.0
PopulateBunLockEdges adds the parent → child edges a bun.lock records. Each package's dependency names are resolved the way Bun installed them (the nearest key up the install path), so an edge points at the copy actually used. Edges are keyed by package name, as the other lock readers key them; a workspace contributes its declared dependencies under its own name.
func (*DepGraph) PopulateCargoLockEdges ¶ added in v3.41.0
PopulateCargoLockEdges reads Cargo.lock's per-package `dependencies = [...]`.
func (*DepGraph) PopulateComposerLockEdges ¶ added in v3.41.0
PopulateComposerLockEdges reads composer.lock per-package `require` (skipping php / ext-* / lib-* platform requirements).
func (*DepGraph) PopulateGemfileLockEdges ¶ added in v3.41.0
PopulateGemfileLockEdges reads Gemfile.lock spec→dependency indentation (4-space spec, 6-space dependency) into edges.
func (*DepGraph) PopulateGoModGraph ¶
PopulateGoModGraph runs "go mod graph" in the given directory and populates the Edges map with the dependency relationships. Strips version suffixes so edges use bare module names matching package names.
func (*DepGraph) PopulateMixLockEdges ¶ added in v3.41.0
PopulateMixLockEdges reads mix.lock per-package dependency atoms into edges.
func (*DepGraph) PopulateNpmLockEdges ¶
PopulateNpmLockEdges parses package-lock.json (v2/v3) and populates the Edges map from the nested node_modules path structure. In v3 format, the key "node_modules/foo/node_modules/bar" means foo depends on bar.
func (*DepGraph) PopulateNugetLockEdges ¶ added in v3.41.0
PopulateNugetLockEdges reads packages.lock.json per-package `dependencies`.
func (*DepGraph) PopulatePypiLockEdges ¶ added in v3.40.0
PopulatePypiLockEdges builds dependency-tree edges for a pypi manifest group from the lock files in dir. Edge keys/values are normalised (normPypi) so the lock, `# via`, and installed-METADATA sources all merge on one key form; BuildDependencies resolves SBOM component names against the same normalisation. uv.lock and pylock.toml carry an explicit dependency tree; a `pip/uv compile` requirements.txt carries it as inverted `# via` comments. All present sources are merged.
func (*DepGraph) TransitiveCount ¶
TransitiveCount returns the number of transitive (non-direct) dependencies.
type DetectedFile ¶
type DetectedFile struct {
Path string
RelPath string // relative to scan root
FileType FileType
ManifestInfo *ManifestInfo // non-nil for manifest files
SBOMVersion string // e.g. "SPDX-2.3", "1.5" for CycloneDX
Supported bool // whether the backend accepts this file type
}
DetectedFile represents a detected scannable file
func WalkForScanFiles ¶
func WalkForScanFiles(opts WalkOptions) ([]DetectedFile, error)
WalkForScanFiles walks the filesystem from root, up to maxDepth, looking for manifest files and potential SBOM documents.
type EOLHorizon ¶ added in v3.63.0
type EOLHorizon string
EOLHorizon is how far away an end-of-life date is.
const ( // EOLRetired is already past. EOLRetired EOLHorizon = "retired" // EOLWithin30Days is imminent. EOLWithin30Days EOLHorizon = "within-30-days" // EOLThisQuarter falls in the current calendar quarter. EOLThisQuarter EOLHorizon = "this-quarter" // EOLNextQuarter falls in the following calendar quarter. EOLNextQuarter EOLHorizon = "next-quarter" // EOLBeyond is further out than we grade, or has no date at all. EOLBeyond EOLHorizon = "" )
func EOLHorizonOf ¶ added in v3.63.0
func EOLHorizonOf(eolFrom string, now time.Time) EOLHorizon
EOLHorizonOf classifies an end-of-life date relative to now.
The date is whatever the VDB EOL API returned — an ISO date ("2026-04-30") or a full timestamp. An unparseable or empty date is EOLBeyond rather than an error: a scan must not fail because a third-party EOL feed printed a date oddly.
type EOLSeverityBuckets ¶ added in v3.63.0
type EOLSeverityBuckets struct {
Retired string
Within30Days string
ThisQuarter string
NextQuarter string
}
EOLSeverityBuckets maps each horizon to a severity. Zero values mean the org has not set that bucket, and the default applies.
func DefaultEOLSeverityBuckets ¶ added in v3.63.0
func DefaultEOLSeverityBuckets() EOLSeverityBuckets
DefaultEOLSeverityBuckets mirrors the column defaults in CliQualityGateConfig, so an org that has never touched the setting behaves the same whether its policy was fetched or not.
func (EOLSeverityBuckets) SeverityFor ¶ added in v3.63.0
func (b EOLSeverityBuckets) SeverityFor(h EOLHorizon) (string, bool)
SeverityFor maps a horizon to the severity the org assigned it. It reports ok=false when the horizon is not graded, or when the org set that bucket to "skip" — in both cases the item is not a finding at all.
type EnrichOptions ¶ added in v3.19.2
EnrichOptions controls optional enrichment calls. A zero value preserves the historical behavior: fetch affected ranges, exploit intel, and remediation.
type EnrichedVuln ¶
type EnrichedVuln struct {
VulnFinding
Confirmed bool // true if installed version is in affected range
IsMalicious bool // malware/malicious package — highest sort priority
AffectedRange string // e.g., ">= 2.0.0, < 2.3.1"
VersionStatus string // "affected" | "unaffected" | "unknown" — version evaluation verdict
PathCount int // number of source files / transitive paths introducing this vuln
ThreatExposure float64 // x_threatExposure from VDB — primary sort key
EPSSScore float64 // displayed
EPSSPercentile float64 // displayed
CVSSScore float64 // displayed
CoalitionESS float64 // displayed
ExploitIntel *ExploitSummary
Remediation *RemediationInfo
SSVCDecision string // "Act", "Attend", "Track*", "Track"
FixAvailability string // "available", "partial", "no_fix"
IDSRules []IDSRule
// Per-source severity ratings (coerced from numeric scores / decisions).
EPSSSeverity string // severity derived from EPSS probability
CESSeverity string // severity derived from Coalition ESS score
CVSSSeverity string // severity derived from CVSS score
SSVCSeverity string // severity derived from SSVC decision
// MaxSeverity is the highest severity across all scoring sources for this vuln.
// It is used for --severity threshold evaluation.
MaxSeverity string
// MatchMethod records how this vuln was matched to the package (e.g. "name+version", "cpe", "name-only").
MatchMethod string
// Reachability records the outcome of the local code-analysis pass
// for this vuln. Values:
// "direct" — vulnerable AST node lives inside the installed
// package's own source (highest confidence).
// "transitive" — vulnerable AST node lives in first-party code
// that calls into the affected dep.
// "semantic" — the lower-efficacy fallback: the affected
// routine / file / module name appears literally
// in your source (e.g. an import statement or
// typed usage). Indicates intent to use the
// affected element but not a proven call path.
// "unreachable" — queries ran and nothing matched.
// empty — no analysis was performed (no data to compare).
Reachability string
// ReachabilityAssessed is true when tree-sitter queries actually ran
// for this CVE (i.e. the CVE was in the evaluated set).
ReachabilityAssessed bool
// ReachabilityQueryHashes are the query hashes that ran for this CVE.
// Populated when ReachabilityAssessed is true.
ReachabilityQueryHashes []string
// AffectedSymbols is the symbol-level fallback returned by the API for
// every tier. Populated whether or not tree-sitter queries existed.
AffectedSymbols *AffectedSymbols
// SemanticMatches lists per-CVE source hits from the semantic
// reachability pass — one entry per (file, line, symbol). Empty when
// Reachability != "semantic".
SemanticMatches []SemanticMatch
}
EnrichedVuln extends VulnFinding with version-filtered, enriched data. It is populated by SynthesiseFromCDX from the /v2/cli.sca response — the server now performs version filtering, exploit-intel, and remediation enrichment in the same round-trip, so there is no separate client-side enrichment loop.
type ExploitSummary ¶
type ExploitSummary struct {
ExploitCount int
Sources []string
HasWeaponized bool
HighestMaturity string
}
ExploitSummary captures exploit intelligence for a vulnerability.
type HashlookupParent ¶ added in v3.28.0
type HashlookupParent struct {
SHA1 string `json:"SHA-1,omitempty"`
SHA256 string `json:"SHA-256,omitempty"`
MD5 string `json:"MD5,omitempty"`
PackageName string `json:"PackageName,omitempty"`
PackageVersion string `json:"PackageVersion,omitempty"`
PackageRelease string `json:"PackageRelease,omitempty"`
PackageArch string `json:"PackageArch,omitempty"`
PackageDescription string `json:"PackageDescription,omitempty"`
}
HashlookupParent is one parent entry from CIRCL (a known package that ships this binary). Only present on the single-lookup endpoint.
type HashlookupResult ¶ added in v3.28.0
type HashlookupResult struct {
FileName string `json:"FileName,omitempty"`
FileSize string `json:"FileSize,omitempty"`
MD5 string `json:"MD5,omitempty"`
SHA1 string `json:"SHA-1,omitempty"`
SHA256 string `json:"SHA-256,omitempty"`
SHA512 string `json:"SHA-512,omitempty"`
SSDEEP string `json:"SSDEEP,omitempty"`
TLSH string `json:"TLSH,omitempty"`
InsertTimestamp string `json:"insert-timestamp,omitempty"`
Source string `json:"source,omitempty"`
PackageName string `json:"-"`
PackageVersion string `json:"-"`
Parents []HashlookupParent `json:"parents,omitempty"`
}
HashlookupResult carries the CIRCL hashlookup response for one SHA-1 hash.
CIRCL returns NSRL-style PascalCase keys with hyphens ("SHA-1", "SHA-256", "MD5", "FileName", ...) — the json tags below mirror that exactly so the response unmarshals. PackageName/PackageVersion are NOT top-level CIRCL fields (they live in parents[] on the single-lookup endpoint, and are absent from the slim bulk response); they are derived in BulkHashlookup.
type IDSRule ¶
type IDSRule struct {
Type string // "snort" or "suricata"
Content string
Source string
CveID string
}
IDSRule represents a snort or suricata detection rule.
func CollectIDSRules ¶
func CollectIDSRules(vulns []EnrichedVuln) []IDSRule
CollectIDSRules gathers all IDS rules from enriched vulns.
type LookupStats ¶
type LookupStats struct {
Total int // unique packages queried (after dedup)
Succeeded int // packages resolved successfully
Failed int // packages that errored
Skipped int // packages skipped (name too short)
Cancelled int // packages not attempted
}
LookupStats summarises the outcome of a VDB lookup. /v2/cli.sca populates it via SynthesiseFromCDX so the report layer can show coverage counts.
type MalwareBazaarResult ¶ added in v3.28.0
type MalwareBazaarResult struct {
Malicious bool `json:"malicious"`
FileName string `json:"fileName,omitempty"`
}
MalwareBazaarResult is the local malware check result for one binary.
type ManifestGroup ¶
type ManifestGroup struct {
Dir string // relative directory
Ecosystem string // e.g., "golang", "npm"
Files []string // relative paths of constituent manifest files
Graph *DepGraph // direct vs transitive classification
Packages []ScopedPackage // all packages from this group
}
ManifestGroup holds related manifest files from the same directory/ecosystem.
func BuildManifestGroups ¶
func BuildManifestGroups(filePackages map[string][]ScopedPackage, fileEcosystems map[string]string) []ManifestGroup
BuildManifestGroups correlates manifest results by directory and ecosystem, building dependency graphs where possible.
type ManifestInfo ¶
type ManifestInfo struct {
Type string // canonical filename used as the manifest "type" parameter
Ecosystem string
Language string
IsLock bool
// Confidence is set only for pip requirements files detected by name pattern
// or content (ConfidenceConfident / ConfidenceTentative). Empty for every
// other manifest, including exact-name matches of non-requirements files.
Confidence string
}
ManifestInfo describes a known manifest file
func DetectManifest ¶
func DetectManifest(filename string) (*ManifestInfo, bool)
DetectManifest checks if a file is a known manifest. It checks in order: exact basename → file extension → path pattern (GitHub Actions).
type NpmWorkspace ¶ added in v3.152.0
type NpmWorkspace struct {
RootDir string // absolute directory of the workspace root
LockPath string // absolute path of the root's lockfile ("" when it has none)
}
NpmWorkspace describes the workspace root that owns a member package.json.
func FindNpmWorkspace ¶ added in v3.152.0
func FindNpmWorkspace(memberDir string) (NpmWorkspace, bool)
FindNpmWorkspace returns the workspace root that declares the package.json in memberDir as one of its members, searching ancestors nearest first. ok is false when no ancestor declares it. A root that declares the member but has no lockfile is returned with an empty LockPath: that monorepo is genuinely unlocked, and a lockfile further up belongs to some other project.
type PackageChecksum ¶ added in v3.15.0
type PackageChecksum = parse.PackageChecksum
PackageChecksum is one integrity hash extracted from a lock file.
type RegistryEndpoint ¶ added in v3.49.0
type RegistryEndpoint = parse.RegistryEndpoint
RegistryEndpoint is a package registry discovered from a registry-config file.
func ParseRegistryConfig ¶ added in v3.49.0
func ParseRegistryConfig(filePath, ecosystem string) []RegistryEndpoint
ParseRegistryConfig parses a registry-config file into its endpoints.
func SummarizeRegistryConfigs ¶ added in v3.49.0
func SummarizeRegistryConfigs(files []DetectedFile) []RegistryEndpoint
SummarizeRegistryConfigs parses every registry-config file among the detected files and returns the endpoints found. Kept here (not in the parse module) because it depends on the CLI's DetectedFile detection layer.
type RemediationInfo ¶
RemediationInfo captures remediation plan details.
type ResolveStats ¶ added in v3.115.0
type ResolveStats struct {
// Candidates is how many findings the pass tried to settle.
Candidates int
// Resolved is how many it settled either way.
Resolved int
// NotAffected is how many of those turned out not to affect the installed
// version: false positives removed at the source.
NotAffected int
// Fetches is how many advisory records were requested.
Fetches int
// Failed is how many of those requests did not produce a record (an API error
// or the time budget). Findings that depended on one keep the verdict they
// arrived with, so a non-zero count means the pass was not complete.
Failed int
}
ResolveStats reports what a resolution pass did.
func ResolveUnverified ¶ added in v3.115.0
func ResolveUnverified(ctx context.Context, vulns []EnrichedVuln, fetch AffectedFetcher, workers int) ResolveStats
ResolveUnverified settles findings whose version could not be checked from the range the scan carried. That includes findings carried by a wildcard range, which are "affected" on a source's say-so and would otherwise stay vulnerable after the fix.
The scan response surfaces a single affected range per finding, and for many advisories that is a git commit (OSV records most PYSEC advisories that way), which cannot be compared with a version. The advisory's full record usually carries the version ranges as well. PYSEC-2024-38 lists both a git range and "< 0.109.1", so a package already at 0.135.1 is plainly outside it, and without this pass it stayed an "unverified" finding forever.
The pass fetches the record for each unverified advisory, and for its aliases when the record has no entry for this package, then evaluates the installed version against every comparable range. It only ever resolves; a finding it cannot settle is left exactly as it was.
func ResolveUnverifiedBatched ¶ added in v3.120.11
func ResolveUnverifiedBatched(ctx context.Context, vulns []EnrichedVuln, fetch AffectedFetcher, batch AffectedBatchFetcher, workers int) ResolveStats
ResolveUnverifiedBatched is ResolveUnverified that sends each wave of lookups through batch, one request instead of one per advisory. Answers are used exactly as fetch's would be; an item the batch could not answer falls back to fetch, with its usual retry.
type ResolvedBinary ¶ added in v3.8.0
type ResolvedBinary struct {
Ecosystem string
Binary string
BinaryPath string
Version string
VersionCommand string
Detected bool
Authoritative bool
}
ResolvedBinary describes one package-manager binary candidate on the host.
func ResolvePackageManagerBinaries ¶ added in v3.8.0
func ResolvePackageManagerBinaries(presentFiles []string) []ResolvedBinary
ResolvePackageManagerBinaries takes the set of manifest/lockfile basenames detected in the repo and returns one ResolvedBinary per candidate binary: whether it is installed (PATH), its resolved path + version, and whether a lockfile narrowed the manifest to this specific binary (Authoritative).
type RuntimePin ¶
type RuntimePin struct {
Product string // VDB EOL product name: "go", "nodejs", "python", "ruby"
Release string // normalised for the EOL API: "1.21", "18", "3.10"
RawVersion string // raw version string from the file
SourceFile string // relative path of the pin file within the project root
}
RuntimePin records a runtime version detected from a version-pin file.
func DetectRuntimeVersionPins ¶
func DetectRuntimeVersionPins(rootPath string) []RuntimePin
DetectRuntimeVersionPins scans rootPath for common runtime version-pin files and returns the detected runtime versions. Only the project root is inspected (no recursion). Errors reading individual files are silently skipped.
Files inspected: go.mod, .nvmrc, .node-version, .python-version, .tool-versions, .ruby-version, Gemfile, Dockerfile, Containerfile. LTS aliases in .nvmrc (e.g. "lts/hydrogen") are silently skipped.
type ScanResult ¶ added in v3.28.0
type ScanResult struct {
ScannerRunUUID string `json:"scannerRunUuid,omitempty"`
Path string `json:"path"`
Total int `json:"total"`
ELFCount int `json:"elfCount"`
Binaries []BinaryResult `json:"binaries"`
Errors []string `json:"errors,omitempty"`
}
ScanResult is the top-level result of a container filesystem scan.
func ScanContainerFilesystem ¶ added in v3.28.0
func ScanContainerFilesystem(root string) *ScanResult
ScanContainerFilesystem recursively walks root looking for ELF binaries, analyzes each one, and returns the full scan result.
func ScanContainerFilesystemWithOptions ¶ added in v3.79.0
func ScanContainerFilesystemWithOptions(root string, opts BinaryScanOptions) *ScanResult
ScanContainerFilesystemWithOptions is ScanContainerFilesystem with an explicit fan-out policy.
The walk is serial (cheap: four bytes read per candidate file) and the analysis — whole-file read, five hash families, ELF parsing, string extraction — is fanned out across workers. Results are written back by index, so Binaries and Errors stay in walk order no matter which worker finishes first: two runs over the same tree produce byte-identical SARIF and SBOM output.
func (*ScanResult) SetScannerRunUUID ¶ added in v3.28.0
func (sr *ScanResult) SetScannerRunUUID(uuid string)
SetScannerRunUUID stamps the scan result with the scanner run identifier.
func (*ScanResult) ToJSON ¶ added in v3.28.0
func (sr *ScanResult) ToJSON() ([]byte, error)
ToJSON returns the indented JSON representation of the scan result.
Deliberately NOT named MarshalJSON: that magic name would make *ScanResult implement json.Marshaler, and the json.MarshalIndent(sr, ...) call below would then recurse into itself indefinitely.
type ScopedPackage ¶
type ScopedPackage = parse.ScopedPackage
ScopedPackage is a parsed dependency with scope/provenance information.
func ApplyBuildOrLockGate ¶ added in v3.41.0
func ApplyBuildOrLockGate(eco, manifestType, manifestPath, relPath string, confident bool, pkgs []ScopedPackage) (resolved []ScopedPackage, dropFile bool, err error)
ApplyBuildOrLockGate runs the build-or-lock gate for one parsed manifest. It returns the (possibly resolved) package set; dropFile=true when a tentative file could not be confirmed and the caller should skip it; and a fatal err when a confident manifest cannot be resolved (caller should return it → exit).
func ParseManifestWithScope ¶
func ParseManifestWithScope(filePath, manifestType string) ([]ScopedPackage, error)
ParseManifestWithScope reads a manifest file and returns scoped packages.
func ResolveCargoFromInstalled ¶ added in v3.41.0
func ResolveCargoFromInstalled(manifestPath, relPath string, declared []ScopedPackage, strict bool) ([]ScopedPackage, error)
ResolveCargoFromInstalled resolves Cargo.toml deps from a project `vendor/` directory (full transitive set) or, failing that, the global cargo registry cache (declared-only).
func ResolveComposerFromInstalled ¶ added in v3.41.0
func ResolveComposerFromInstalled(manifestPath, relPath string, declared []ScopedPackage, strict bool) ([]ScopedPackage, error)
ResolveComposerFromInstalled resolves composer.json deps from the project `vendor/` tree (full transitive set). Composer has no versioned global cache, so a missing `vendor/` is a build-or-lock error.
func ResolveGemsFromInstalled ¶ added in v3.41.0
func ResolveGemsFromInstalled(manifestPath, relPath string, declared []ScopedPackage, strict bool) ([]ScopedPackage, error)
ResolveGemsFromInstalled resolves Gemfile deps from a project bundle (vendor/bundle, full transitive set) or the global gem home (declared-only).
func ResolveHexFromInstalled ¶ added in v3.41.0
func ResolveHexFromInstalled(manifestPath, relPath string, declared []ScopedPackage, strict bool) ([]ScopedPackage, error)
ResolveHexFromInstalled resolves mix.exs deps from the project `deps/` tree (full transitive set; version from each dep's hex_metadata.config).
func ResolveJavaFromInstalled ¶ added in v3.41.0
func ResolveJavaFromInstalled(manifestPath, relPath string, declared []ScopedPackage, strict bool) ([]ScopedPackage, error)
ResolveJavaFromInstalled resolves declared "group:artifact" coordinates against the global Maven (~/.m2) and Gradle (~/.gradle) caches (declared-only — these caches are shared across all projects, so transitives are never enumerated).
func ResolveNpmPackageJSONFromNodeModules ¶ added in v3.34.0
func ResolveNpmPackageJSONFromNodeModules(packageJSONPath, relPath string, direct []ScopedPackage) ([]ScopedPackage, error)
ResolveNpmPackageJSONFromNodeModules replaces package.json version ranges with installed versions when no lockfile exists, and adds installed transitives by reading every package manifest found under node_modules.
func ResolveNugetFromInstalled ¶ added in v3.41.0
func ResolveNugetFromInstalled(manifestPath, relPath string, declared []ScopedPackage, strict bool) ([]ScopedPackage, error)
ResolveNugetFromInstalled resolves project deps from a local `packages/` folder (old packages.config layout, full) or the global NuGet cache (declared-only).
func ResolvePubFromInstalled ¶ added in v3.41.0
func ResolvePubFromInstalled(manifestPath, relPath string, declared []ScopedPackage, strict bool) ([]ScopedPackage, error)
ResolvePubFromInstalled resolves pubspec.yaml deps from the project's resolved set (.dart_tool/package_config.json, full) or the global pub-cache (declared-only).
func ResolvePythonRequirementsFromSitePackages ¶ added in v3.40.0
func ResolvePythonRequirementsFromSitePackages(manifestPath, relPath string, declared []ScopedPackage, strict bool) ([]ScopedPackage, error)
ResolvePythonRequirementsFromSitePackages resolves an unpinned pip manifest's declared packages to exact installed versions. It mirrors the npm node_modules resolver, including SourceType/InstalledPath provenance.
A project venv (findPythonVenv) yields a full project-scoped resolution: declared packages (SourceType=manifest) plus every installed package as a transitive (SourceType=installed, InstalledPath set). When no venv is found it falls back to the global/user site-packages purely as an install check, resolving the declared packages only (globals are never enumerated into the SBOM as project dependencies).
strict (a confident detection) requires every declared package to be present, else it errors with the build-or-lock hint. Non-strict (a tentative detection) keeps whatever resolves and errors only when nothing matches.
type SemanticMatch ¶ added in v3.6.0
type SemanticMatch struct {
File string
Line int
Symbol string
Kind string // "routine" | "file" | "module"
}
SemanticMatch is one source hit produced by the semantic reachability fallback. The CLI's pretty-printer renders these under a Semantic Reachability section so users can jump straight to file:line.
type Verdict ¶ added in v3.115.0
type Verdict string
Verdict answers the question a finding row never answered on its own: is the version installed here actually affected?
EnrichedVuln has carried VersionStatus and Confirmed for a long time, and the table printed neither. A row in a vulnerability table reads as "you are vulnerable", so a package whose installed version is already past the advisory's fix still looked like a finding, with nothing on the row to contradict it. Verdict is that missing sentence, computed once so every renderer, gate and explanation agrees.
const ( // VerdictAffected means the installed version is inside a range the advisory // supplied, or the source asserted it is affected and nothing contradicts it. VerdictAffected Verdict = "affected" // VerdictUnverified means the match was by package name and there is nothing // to compare the installed version with. Unknown is not safe, so it counts. VerdictUnverified Verdict = "unverified" // VerdictLikelyNotAffected means the evidence points away from the installed // version without proving it: no usable range, but installed is not older // than the fix, or a range excludes it while the source still flagged it. VerdictLikelyNotAffected Verdict = "likely_not_affected" // VerdictNotAffected means the installed version is outside every range the // advisory supplied, or the source said so explicitly. VerdictNotAffected Verdict = "not_affected" )
type VerdictResult ¶ added in v3.115.0
type VerdictResult struct {
Verdict Verdict
// Confidence is "high", "medium" or "low".
Confidence string
// Basis names the evidence: "range", "source", "recommended-fix", "none" or
// "unparseable-version".
Basis string
// Installed is the version that was checked.
Installed string
// Range is the advisory's affected range, when it supplied one.
Range string
// FixedIn is the version the advisory (or, failing that, the recommendation)
// names as the first safe one. FixedInSource says which.
FixedIn string
FixedInSource string // "advisory" | "recommended"
// AnyUpgradeClears is set when the range names only the installed version
// itself ("= 2.19.1"), so moving to any other version clears the advisory.
AnyUpgradeClears bool
// MatchedBy is a plain-language statement of how the finding was matched.
MatchedBy string
// Detail is one sentence describing the comparison.
Detail string
}
VerdictResult is a verdict together with the working that produced it, so a reader can check the arithmetic rather than trust the word.
func EvaluateVerdict ¶ added in v3.115.0
func EvaluateVerdict(ev EnrichedVuln) VerdictResult
EvaluateVerdict derives the verdict for one enriched finding. It is pure: no network, no settings, no mutation of its input.
type VulnFinding ¶
type VulnFinding struct {
CveID string
PackageName string
PackageVer string
Ecosystem string
Scope string
Severity string
Score float64
MetricType string
VectorString string
SourceFile string
Source string // upstream vulnerability source name (empty = vulnetix)
InCisaKev bool
InVulnCheckKev bool
InEuKev bool
ExploitCount int
// Aliases are the other identifiers the server knows this advisory by.
Aliases []string
}
VulnFinding represents a vulnerability found during a local scan. It is populated from the CycloneDX document returned by /v2/cli.sca (see SynthesiseFromCDX) and consumed throughout the scan/report pipeline.
type WalkOptions ¶
type WalkOptions struct {
RootPath string
MaxDepth int
Excludes []string // glob patterns to exclude
// RespectGitignore, when true, prunes files and directories matched by
// .gitignore files (accumulated top-down). The sca path leaves this false
// because dependency manifests routinely live in gitignored install dirs.
RespectGitignore bool
}
WalkOptions configures the filesystem walk behavior.
Source Files
¶
- binaries.go
- binary_analyze_schema.go
- binary_scanner.go
- bun_edges.go
- cargo_installed.go
- composer_installed.go
- depgraph.go
- detector.go
- enrich.go
- eol_severity.go
- from_cli_sca.go
- gate.go
- gates.go
- go_installed.go
- hashlookup.go
- hex_installed.go
- installed_common.go
- installed_edges.go
- java_installed.go
- lock_edges.go
- malware_bazaar.go
- npm_installed.go
- npm_workspace.go
- nuget_installed.go
- parse_bridge.go
- pip_installed.go
- pub_installed.go
- resolve.go
- results.go
- ruby_installed.go
- specifier.go
- swift_installed.go
- vdb_lookup.go
- verdict.go
- verify.go
- version_check.go
- walker.go