Documentation
¶
Overview ¶
Package inventory answers which installed packages are actually in use on a host, from what running processes have mapped into memory.
Three states matter, and installed-only is not one a scanner can tell apart from the other two:
- loaded: a running process maps a file the package installed, so a vulnerability in it is reachable from a live process.
- stale-loaded: a process maps a file that has since been replaced or deleted on disk ("(deleted)" in its maps). The package on disk may be fixed while the process still runs the old code; it needs a restart, and a disk scan reports it as fixed.
- neither: installed and not mapped by anything right now.
Mappings of anonymous memory files (memfd:) with execute permission are reported separately: code run from a memfd never touches the filesystem, which is how fileless malware avoids a disk scan. JIT runtimes and browsers do it too, so the list is a lead to check, not a verdict.
Index ¶
Constants ¶
const ( Loaded = "loaded" StaleLoaded = "stale-loaded" )
States.
Variables ¶
This section is empty.
Functions ¶
func MappedPaths ¶
MappedPaths is every file a running process has mapped under root/proc, with the merged-/usr twins lookup tries, so binpkg.BuildOwnerIndexFor can keep only what Scan will ask about.
Types ¶
type Package ¶
type Package struct {
Name string `json:"name"`
Version string `json:"version"`
Ecosystem string `json:"ecosystem"`
State string `json:"state"`
Processes []Process `json:"processes"`
Files []string `json:"files"`
// ProcessCount is how many processes map the package. Processes holds at
// most a few of them as examples; this is the true number.
ProcessCount int `json:"processCount"`
}
Package is one package some process maps.
type Result ¶
type Result struct {
Packages []Package `json:"packages"`
// Unowned are executable files mapped by a process that no package
// installed, at most 50.
Unowned []string `json:"unowned,omitempty"`
// MemfdExec are processes running code mapped from an anonymous memory
// file.
MemfdExec []Process `json:"memfdExec,omitempty"`
Processes int `json:"processes"`
// Unreadable counts processes whose maps could not be read (another
// user's, without the privilege to read them). A scan with many is
// incomplete, and says so.
Unreadable int `json:"unreadable"`
// Unattributed counts processes in another mount namespace (a container):
// their mapped files are not the host's, so they are not matched to host
// packages.
Unattributed int `json:"unattributed"`
}
Result is one scan.