hostcmd

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 21 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 hostcmd implements the host-inventory command line: `run`, `plugins` and `version`. It is shared by two programs:

  • cmd/cipherhorizon-collector, the small program to deploy on endpoints. It links only this package's dependencies: no web server, no database, no TLS scanner;
  • cmd/cipherhorizon, the full product, whose `run` command is this same code.

Keeping it in its own package is what lets the collector stay small and auditable (internal/archtest fails the build if the collector links the server, the store or the scanner).

Index

Constants

View Source
const (
	ExitOK         = 0 // success
	ExitFatal      = 1 // nothing was produced: bad usage, bad config, I/O error, interrupted
	ExitIncomplete = 2 // a CBOM was written, but a sensor failed or a budget was hit
)

Exit codes.

Variables

This section is empty.

Functions

func Main

func Main(ctx context.Context, args []string, env Env) int

Main is the collector program's whole command line: run, plugins, version, help.

func Plugins

func Plugins(env Env) int

Plugins implements `plugins`: list the built-in sensors and the methods they use.

func Run

func Run(ctx context.Context, args []string, env Env) int

Run implements `run`: discover the host's cryptography and write a CBOM.

func Usage

func Usage(w io.Writer, prog string)

Usage prints the help for the host commands.

Types

type Env

type Env struct {
	Stdout io.Writer // the CBOM goes here unless an output file is configured
	Stderr io.Writer // progress, warnings and the PQC summary

	// Prog is the program name used in messages ("cipherhorizon" by default).
	Prog string

	Registry  *sense.Registry  // nil means sense.Default
	Now       func() time.Time // nil means time.Now
	NewSerial func() string    // nil means a random UUID
	Hostname  func() (string, error)

	// OS is the host's operating system family, "linux" or "windows"; empty means
	// this process's own. Tier reports the privilege of the run ("user" or
	// "admin"); nil means the process's real privilege. Both exist so tests are
	// deterministic on any machine.
	OS   string
	Tier func() string
}

Env carries everything the commands need from the outside world.

Jump to

Keyboard shortcuts

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