hostinfo

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 9 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 hostinfo identifies the machine being inventoried and the privilege the run has: the two facts every report about a host needs and no sensor should have to work out for itself.

Everything platform-specific is behind build tags in tier_*.go and machineid_*.go; the rest is ordinary Go that compiles and is tested everywhere.

Index

Constants

View Source
const (
	TierUser  = "user"
	TierAdmin = "admin"
)

Privilege tiers. The default and complete-in-itself tier is user; elevation is the operator's choice and is never taken by the tool (ADR-0009).

Variables

View Source
var ErrNoMachineID = errors.New("hostinfo: no machine id available")

ErrNoMachineID means the platform offers no stable machine identifier.

Functions

func CurrentTier

func CurrentTier() string

CurrentTier reports whether the process is root. Being root is the admin tier; any other user is the user tier. The tool never escalates.

func Describe

func Describe(fsys fs.FS, osFamily, name, tier string) evidence.Host

Describe builds the evidence.Host for a scan of fsys on the given OS family. name is the host name to record (already resolved by the caller) and tier the privilege tier of the run (CurrentTier in production; injected in tests).

On Windows the machine id and OS version come from the running system, because a Windows scan is always of the live machine; elsewhere they come from the host filesystem, so a host mounted into a container is identified rather than the container.

func HostLabel

func HostLabel(machineID string) string

HostLabel turns a platform machine id into the label used when the host name is redacted. It is stable per machine and one-way: the raw machine id is never emitted. The 12 hex digits are 48 bits, ample to tell hosts apart.

func LinuxMachineID

func LinuxMachineID(fsys fs.FS) (string, error)

LinuxMachineID reads /etc/machine-id (or the D-Bus fallback) from the host filesystem.

func PlatformMachineID

func PlatformMachineID() (string, error)

PlatformMachineID is not used off Windows (Linux reads /etc/machine-id from the host filesystem, so a mounted host is identified, not the scanner).

func PlatformOSVersion

func PlatformOSVersion() string

PlatformOSVersion is empty off Windows: the version comes from os-release.

Types

type OSRelease

type OSRelease struct {
	ID        string // e.g. "ubuntu": the purl namespace
	VersionID string // e.g. "24.04"; absent on Debian testing/sid
	Name      string // e.g. "Ubuntu"
}

OSRelease holds the os-release(5) fields the tool uses.

func ReadOSRelease

func ReadOSRelease(fsys fs.FS) OSRelease

ReadOSRelease reads os-release(5) from the host, preferring /etc and falling back to /usr/lib as the specification says. A missing file is not an error: it yields the zero value and callers omit what depends on it rather than guess.

Jump to

Keyboard shortcuts

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