workstation

package
v8.180.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 31 Imported by: ? 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 workstation inspects the local machine against the manifest released with devctl: whether the CLIs, OpenSSH, TLS libraries, the Teleport and VPN clients and the kubeconfig's credential plugins offer hybrid post-quantum key exchange, and which SSH keys are in use. It is read-only: it reads files, runs tools to print their versions, reads the Teleport cluster's public ping endpoint and, when a key is weak, the public SSH keys of the user's GitHub account; it never installs, changes or deletes anything and sends no results anywhere.

Index

Constants

View Source
const (
	KindGoBinary = "go-binary"
	KindOpenSSH  = "openssh"
	KindSSHKex   = "openssh-kex"
	KindOpenSSL  = "openssl"
	KindCurl     = "curl"
	KindGitHTTPS = "git-https"
	KindTeleport = "teleport"
	// KindKubeconfig: the credential plugins the kubeconfig runs.
	KindKubeconfig = "kubeconfig"
	KindVPN        = "vpn"
	KindCloudCLI   = "cloud-cli"
	KindSSHKeys    = "ssh-keys"
	// KindEnvironment: credentials in the environment.
	KindEnvironment = "environment"
)

Kinds of check: what the result is about. The skill orders findings by kind.

View Source
const (
	GitHubAuthentication = "authentication"
	GitHubSigning        = "signing"
	GitHubBoth           = "both"
)

GitHub key uses, as Key.GitHub reports them.

View Source
const Command = "workstation check"

Command is the command whose document this package writes.

Variables

This section is empty.

Functions

func RenderTable

func RenderTable(w io.Writer, results []Result, verbose bool) error

RenderTable writes the results for a person: each check that fails, then each that warns, with its problems and the fix to copy, and one line counting the checks that are ok or skipped. verbose lists those first, one line each with what was found. --output json has the details of every check. Every block starts with an empty line, so none sits against what was printed before it.

Types

type Checker

type Checker struct {
	Manifest Manifest
	OS       string
	Arch     string
	// Getenv reads PATH, PATHEXT and HOME-like variables.
	Getenv func(string) string
	// Home is the user's home directory, for ~/.ssh.
	Home string
	Run  Runner
	// ReadBuildInfo reads a Go binary's build information without running
	// it.
	ReadBuildInfo func(path string) (*buildinfo.BuildInfo, error)
	HTTP          *http.Client
	// ImportedLibraries lists the dynamic libraries a Mach-O binary links.
	ImportedLibraries func(path string) ([]string, error)
	// GitHubLogin is the user's GitHub login and a token to read with, or
	// none; GitHubAPIURL is where the public SSH keys of that login are
	// read.
	GitHubLogin  func(ctx context.Context) (login, token string, err error)
	GitHubAPIURL string
	// Environ is the environment devctl runs with, KEY=value each.
	Environ func() []string
	// ParentName is the name of the program that started devctl, or "".
	ParentName func(ctx context.Context) string
}

Checker runs the checks. Its fields are the machine it reads; New fills them with the real one.

func New

func New(m Manifest) *Checker

New is a Checker of this machine.

func (*Checker) Check

func (c *Checker) Check(ctx context.Context) []Result

Check runs every check, in the order the document lists them.

type CloudCLIs

type CloudCLIs struct {
	MinOpenSSLVersion string `json:"minOpenSSLVersion"`
	Tools             []Tool `json:"tools"`
}

type Copy

type Copy struct {
	Path string `json:"path"`
	// Target is the file a symlink resolves to; empty when Path is none.
	Target string `json:"target,omitempty"`
	// GoVersion is the Go release the copy was built with, from its build
	// information; empty when it is not a Go binary.
	GoVersion string `json:"goVersion,omitempty"`
	// Version is the tool's version: its main module's version, or what
	// the tool printed.
	Version string `json:"version,omitempty"`
	// HybridKex: the copy's crypto/tls offers X25519MLKEM768 by default.
	HybridKex bool `json:"hybridKex"`
	// Shadowed: an earlier copy on PATH runs instead.
	Shadowed bool `json:"shadowed"`
	// Error is why the build information could not be read.
	Error string `json:"error,omitempty"`
	// Script: the copy is a script, such as a version manager's shim.
	Script bool `json:"script,omitempty"`
}

Copy is one copy of a tool on PATH.

type CredentialFormat added in v8.180.0

type CredentialFormat struct {
	Name    string `json:"name"`
	Pattern string `json:"pattern"`
}

CredentialFormat is a credential's format: a regular expression of its value.

type Document

type Document struct {
	agentcli.Envelope
	DevctlVersion string   `json:"devctlVersion"`
	OS            string   `json:"os"`
	Arch          string   `json:"arch"`
	Summary       Summary  `json:"summary"`
	Checks        []Result `json:"checks"`
}

Document is the JSON document of devctl workstation check.

type Environment added in v8.180.0

type Environment struct {
	// Formats are credential formats, matched against every value.
	Formats []CredentialFormat `json:"formats"`
	// Names is a regular expression of names a credential goes by, for a
	// value in no known format.
	Names string `json:"names"`
	// IgnoreNames are variables that hold no credential of the person's.
	IgnoreNames []string `json:"ignoreNames"`
	// MinLength is the shortest value judged by its name.
	MinLength int `json:"minLength"`
	// References are prefixes of values that point at a secret instead of
	// holding it (op://).
	References []string `json:"references"`
	// Wrappers are programs that run a command with the secrets they
	// resolve in its environment: under one, the check is skipped.
	Wrappers []string `json:"wrappers"`
	// Fix is what to do, per OS; Instead what a variable is replaced
	// with, by its name.
	Fix     PerOS             `json:"fix"`
	Instead map[string]string `json:"instead"`
}

Environment says which environment variables hold credentials.

type Fix

type Fix struct {
	// Commands are run in order, as one block; empty when the fix is not
	// a command (a setting in an app).
	Commands []string `json:"commands"`
	// Text is an instruction when there is no command, or what to know
	// about the commands.
	Text string `json:"text,omitempty"`
}

Fix is what to do about a check that warns or fails.

type GitHubKeys

type GitHubKeys struct {
	Authentication string `json:"authentication"`
	Signing        string `json:"signing"`
}

GitHubKeys are the API paths of a user's public SSH keys.

type GoBinaries

type GoBinaries struct {
	MinGoVersion string `json:"minGoVersion"`
	Tools        []Tool `json:"tools"`
}

type Key

type Key struct {
	// Source is the .pub file, or "agent".
	Source string `json:"source"`
	// File is the key's file: the .pub file, for a key in the agent the
	// .pub file with its fingerprint or else the path the agent names it
	// by; empty when unknown.
	File string `json:"file,omitempty"`
	Type string `json:"type"`
	Bits int    `json:"bits,omitempty"`
	// Comment is the agent's name for a key in the agent: its file, or what
	// the program that added it calls it.
	Comment     string `json:"comment,omitempty"`
	Fingerprint string `json:"fingerprint"`
	Certificate bool   `json:"certificate"`
	// Certified: a certificate for the key is in the agent, so whoever
	// issued it (Teleport) replaces the key with it; it is not flagged.
	Certified bool `json:"certified"`
	// Weak: an RSA key under the minimum, or a DSA key.
	Weak bool `json:"weak"`
	// GitHub is how the key is registered on the user's GitHub account:
	// authentication, signing, both, or empty when it is not or the
	// account could not be read. Read only when a key is weak.
	GitHub string `json:"github,omitempty"`
}

Key is one SSH public key.

type Manifest

type Manifest struct {
	GoBinaries GoBinaries `json:"goBinaries"`
	OpenSSH    OpenSSH    `json:"openssh"`
	TLS        TLS        `json:"tls"`
	Teleport   Teleport   `json:"teleport"`
	VPN        VPN        `json:"vpn"`
	CloudCLIs  CloudCLIs  `json:"cloudCLIs"`
	SSHKeys    SSHKeys    `json:"sshKeys"`
	// Environment is the check for credentials in the environment.
	Environment Environment `json:"environment"`
}

Manifest is what a workstation must meet: the minimums and the fix for each check, per OS.

func DefaultManifest

func DefaultManifest() (Manifest, error)

DefaultManifest is the manifest released with this devctl.

func ParseManifest

func ParseManifest(b []byte) (Manifest, error)

ParseManifest reads a manifest, refusing unknown fields and versions that do not parse.

type OpenSSH

type OpenSSH struct {
	MinVersion string `json:"minVersion"`
	Kex        string `json:"kex"`
	Host       string `json:"host"`
	Install    PerOS  `json:"install"`
	ConfigFix  PerOS  `json:"configFix"`
}

type OpenVPN

type OpenVPN struct {
	Instructions PerOS `json:"instructions"`
}

type PathTool

type PathTool struct {
	Install PerOS `json:"install"`
	BinDir  PerOS `json:"binDir,omitempty"`
}

PathTool is installed with Install and then put first on PATH: BinDir, a shell expression, in the profile of the user's shell.

type PerOS

type PerOS map[string]string

PerOS is a command or instruction keyed by GOOS.

type Plugin added in v8.179.0

type Plugin struct {
	// Kubeconfig is the file whose users run it.
	Kubeconfig string `json:"kubeconfig"`
	// Command is the plugin as the kubeconfig names it, without its
	// arguments, which can carry a secret: "kubectl oidc-login" for a
	// kubectl plugin.
	Command string `json:"command"`
	// Users are the kubeconfig's users that run it.
	Users []string `json:"users"`
	// Path is the file kubectl runs; empty when there is none.
	Path string `json:"path,omitempty"`
	// Target, GoVersion, HybridKex, Error and Script are as for a Copy.
	Target    string `json:"target,omitempty"`
	GoVersion string `json:"goVersion,omitempty"`
	HybridKex bool   `json:"hybridKex"`
	Error     string `json:"error,omitempty"`
	Script    bool   `json:"script,omitempty"`
}

Plugin is a credential plugin a kubeconfig runs: the program kubectl runs to sign in to a user's clusters.

type Result

type Result struct {
	// ID is unique in the document: the kind, and /<tool> for checks of
	// one tool (go-binary/flux, cloud-cli/aws).
	ID     string `json:"id"`
	Kind   string `json:"kind"`
	Status Status `json:"status"`
	// Title names what the check is about, for a person: flux, curl, SSH
	// keys.
	Title string `json:"title"`
	// Path is the file the check is about: the copy that runs, the app;
	// empty when there is none.
	Path string `json:"path,omitempty"`
	// Found says what was found, in one line.
	Found string `json:"found"`
	// Problems say what is wrong, one sentence each; empty on ok and
	// skipped.
	Problems []string `json:"problems"`
	// Notes are further information, one sentence each.
	Notes []string `json:"notes"`
	// Fix is what to do on this OS; absent on ok and skipped.
	Fix *Fix `json:"fix,omitempty"`
	// Copies: for go-binary, every copy of the tool on PATH in PATH order.
	Copies []Copy `json:"copies,omitempty"`
	// Keys: for ssh-keys, every public key found.
	Keys []Key `json:"keys,omitempty"`
	// Plugins: for kubeconfig, every credential plugin its users run.
	Plugins []Plugin `json:"plugins,omitempty"`
	// Variables: for environment, every variable that holds a credential,
	// without its value.
	Variables []Variable `json:"variables,omitempty"`
}

Result is one check's outcome.

type Runner

type Runner func(ctx context.Context, name string, args ...string) (stdout, stderr string, err error)

Runner runs a tool and returns its stdout and stderr. A non-zero exit is an error carrying both outputs.

type SSHKeys

type SSHKeys struct {
	MinRSABits    int        `json:"minRSABits"`
	GitHubKeyType string     `json:"gitHubKeyType"`
	HybridKeyType string     `json:"hybridKeyType"`
	GitHubKeys    GitHubKeys `json:"gitHubKeys"`
}

type Status

type Status string

Status is a check's outcome.

const (
	// StatusOK: the check passed.
	StatusOK Status = "ok"
	// StatusWarn: something to update, without failing the check: an
	// outdated version, a shadowed copy, a weak key.
	StatusWarn Status = "warn"
	// StatusFail: no hybrid key exchange, or below a required minimum.
	StatusFail Status = "fail"
	// StatusSkipped: the tool is not installed, or the check does not
	// apply on this OS.
	StatusSkipped Status = "skipped"
)

type Summary

type Summary struct {
	OK      int `json:"ok"`
	Warn    int `json:"warn"`
	Fail    int `json:"fail"`
	Skipped int `json:"skipped"`
}

Summary counts the results by status.

func Summarize

func Summarize(results []Result) Summary

Summarize counts results by status.

type TLS

type TLS struct {
	MinOpenSSLVersion string   `json:"minOpenSSLVersion"`
	OpenSSL           PathTool `json:"openssl"`
	Curl              PathTool `json:"curl"`
	GitHTTPS          PerOS    `json:"gitHTTPS"`
}

type Teleport

type Teleport struct {
	PingURL string `json:"pingURL"`
	// Update is the fix when the cluster updates client tools.
	Update PerOS `json:"update"`
	// Install and Instructions put the cluster's client version in place
	// when it does not; {version} is that version.
	Install      PerOS `json:"install"`
	Instructions PerOS `json:"instructions"`
}

type Tool

type Tool struct {
	Name string `json:"name"`
	// MinGoVersion overrides [GoBinaries.MinGoVersion].
	MinGoVersion string `json:"minGoVersion,omitempty"`
	// MinVersion is the tool's own version the first copy on PATH must meet:
	// read from its build information or, when that has none, from the
	// output of the tool run with VersionArgs.
	MinVersion  string   `json:"minVersion,omitempty"`
	VersionArgs []string `json:"versionArgs,omitempty"`
	Install     PerOS    `json:"install,omitempty"`
	Docs        string   `json:"docs,omitempty"`
}

Tool is a CLI looked up on PATH.

type Tunnelblick

type Tunnelblick struct {
	App        string `json:"app"`
	MinVersion string `json:"minVersion"`
	Install    PerOS  `json:"install"`
	BuildFix   PerOS  `json:"buildFix"`
}

type VPN

type VPN struct {
	MinOpenSSLVersion string      `json:"minOpenSSLVersion"`
	Tunnelblick       Tunnelblick `json:"tunnelblick"`
	OpenVPN           OpenVPN     `json:"openvpn"`
}

type Variable added in v8.180.0

type Variable struct {
	Name string `json:"name"`
	// Format is the credential format its value has; empty when it is
	// judged by its name.
	Format string `json:"format,omitempty"`
	// SetIn are the shell startup files that set it, with the line:
	// ~/.zshrc:12.
	SetIn []string `json:"setIn"`
}

Variable is an environment variable that holds a credential. Its value is never in a result.

Jump to

Keyboard shortcuts

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