machinefacts

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 32 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 machinefacts turns the plain-text facts file written by the inventory scripts (cipherhorizon-inventory.ps1 and cipherhorizon-inventory.sh) into a CycloneDX CBOM.

The scripts only gather facts a person can read before uploading: the host's name, operating system and privilege, the crypto-relevant packages installed, and public certificates. The judgement (what a package can do, what a certificate's algorithms mean) is made here, by the same sensors, knowledge base and CBOM builder the Go collector uses, so a script inventory and a collector inventory say the same thing about the same machine.

The format is one fact per line, fields separated by tabs:

cipherhorizon-machine-facts	1
script	<name>	<version>
host	name|os|os-version|privilege|collected	<value>
os-release	<base64 of /etc/os-release>
package-manager	dpkg|rpm|apk
package	dpkg|rpm|apk	<name>	<version>	<arch>
cert-file	<absolute path>	<base64 of the file>
store-cert	LocalMachine|CurrentUser	<store>	yes|no|unknown	<base64 DER>
note	<text>

Everything in the file came from the machine and is treated as untrusted: sizes are bounded, and nothing that looks like private key material is kept.

Index

Constants

View Source
const Header = "cipherhorizon-machine-facts"

Header is the first line of every facts file.

View Source
const (
	MaxBytes = 32 << 20
)

Limits on one facts file.

Variables

This section is empty.

Functions

func Engine

func Engine(name string) ([]byte, error)

Engine returns an engine's text without signatures (as kept in the repository).

func IsFacts

func IsFacts(b []byte) bool

IsFacts reports whether b starts like a facts file.

func ToCBOM

func ToCBOM(ctx context.Context, f *Facts, o Options) (*cdx.BOM, error)

ToCBOM converts facts into a CycloneDX CBOM with post-quantum annotations, using the collector's sensors on an in-memory copy of what the script gathered. Only sensors fed from the facts are registered: nothing on the server's own machine is ever read.

Types

type CertFile

type CertFile struct {
	Path string // host-relative, without the leading slash
	Data []byte
}

CertFile is one certificate file found on a Linux host.

type Facts

type Facts struct {
	Script, ScriptVersion string
	Name, OS, OSVersion   string
	Privilege             string // user | admin
	Collected             string
	OSRelease             []byte
	Managers              []string // the package managers the script asked, even when they listed nothing
	Packages              []Package
	CertFiles             []CertFile
	StoreCerts            []StoreCert
	Notes                 []string
	// Dropped counts entries refused while parsing (private key material, bad encoding, limits).
	Dropped int

	// Version 2 (signature-driven engines): what each signature returned beyond packages and
	// certificates, how many facts each produced, and the ones that could not run.
	Items       []Item
	Ran         map[string]int
	Skipped     map[string]string
	SignatureDB string
}

Facts is a parsed facts file.

func Parse

func Parse(b []byte) (*Facts, error)

Parse reads a facts file.

type Item

type Item struct {
	Sig    string   // the signature id
	Kind   string   // registry | file | program | line
	Fields []string // registry: key, name, value; file: path, size, sha256, version, product; program: name, version, publisher; line: path, text
}

Item is one registry value, file, installed program or configuration line a signature returned.

type Options

type Options struct {
	ToolVersion string
	Now         func() time.Time
}

Options describe the conversion.

type Package

type Package struct {
	Manager, Name, Version, Arch string
}

Package is one installed package.

type Script

type Script struct {
	Name       string `json:"name"`
	Platform   string `json:"platform"`
	Run        string `json:"run"`    // the command that runs it
	SHA256     string `json:"sha256"` // of the bytes served
	Size       int    `json:"size"`
	Signatures int    `json:"signatures"` // how many signatures it carries
	DBVersion  string `json:"signatureDb"`
	// contains filtered or unexported fields
}

Script is one inventory script as the server hands it out: the engine from this repository with the current signature database for its platform written in between its markers, so what a person reads is what runs.

func Scripts

func Scripts() []Script

Scripts lists the inventory scripts with the current signatures embedded.

func (Script) Body

func (s Script) Body() []byte

Body is the script's text.

type StoreCert

type StoreCert struct {
	Location, Store, PrivateKey string
	DER                         []byte
}

StoreCert is one certificate from a Windows certificate store.

Jump to

Keyboard shortcuts

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