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 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
- func RenderTable(w io.Writer, results []Result, verbose bool) error
- type Checker
- type CloudCLIs
- type Copy
- type Document
- type Fix
- type GitHubKeys
- type GoBinaries
- type Key
- type Manifest
- type OpenSSH
- type OpenVPN
- type PathTool
- type PerOS
- type Result
- type Runner
- type SSHKeys
- type Status
- type Summary
- type TLS
- type Teleport
- type Tool
- type Tunnelblick
- type VPN
Constants ¶
const ( KindGoBinary = "go-binary" KindOpenSSH = "openssh" KindSSHKex = "openssh-kex" KindOpenSSL = "openssl" KindCurl = "curl" KindGitHTTPS = "git-https" KindTeleport = "teleport" KindVPN = "vpn" KindCloudCLI = "cloud-cli" KindSSHKeys = "ssh-keys" )
Kinds of check: what the result is about. The skill orders findings by kind.
const ( GitHubAuthentication = "authentication" GitHubSigning = "signing" GitHubBoth = "both" )
GitHub key uses, as Key.GitHub reports them.
const Command = "workstation check"
Command is the command whose document this package writes.
Variables ¶
This section is empty.
Functions ¶
func RenderTable ¶
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
}
Checker runs the checks. Its fields are the machine it reads; New fills them with the real one.
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 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 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 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"`
}
Manifest is what a workstation must meet: the minimums and the fix for each check, per OS.
func DefaultManifest ¶
DefaultManifest is the manifest released with this devctl.
func ParseManifest ¶
ParseManifest reads a manifest, refusing unknown fields and versions that do not parse.
type PathTool ¶
PathTool is installed with Install and then put first on PATH: BinDir, a shell expression, in the profile of the user's shell.
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"`
}
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.
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 VPN ¶
type VPN struct {
MinOpenSSLVersion string `json:"minOpenSSLVersion"`
Tunnelblick Tunnelblick `json:"tunnelblick"`
OpenVPN OpenVPN `json:"openvpn"`
}