inventory

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	Loaded      = "loaded"
	StaleLoaded = "stale-loaded"
)

States.

Variables

This section is empty.

Functions

func MappedPaths

func MappedPaths(root string) map[string]bool

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 Process

type Process struct {
	PID int    `json:"pid"`
	Exe string `json:"exe,omitempty"`
}

Process is one running process.

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.

func Scan

func Scan(root string, idx binpkg.OwnerIndex) Result

Scan reads root/proc. root is "/" on the host, or a mounted /proc's parent in tests. idx maps installed files to packages (binpkg.BuildOwnerIndex).

Jump to

Keyboard shortcuts

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